Basic configuration on Fedora Server 25 x86_64

Download

http://download.fedoraproject.org/pub/fedora/linux/releases/25/Server/x86_64/iso/

Brief Introduction

It’s not different if you are familiar with CentOS because it uses systemd. And normally, you will encourage to use systemctl for instance, “systemctl start named“command instead of just “service named start“.

Initial Setup

Set hostname:

Edit file /etc/hostname

yourhostname.yourdomain

By default, it comes with “vi”, if you want to use vim, you can install “dnf -y install vim” or if you are familiar with “yum”, you can still use “yum -y install vim”, but to do so, you need Internet connection.

Set IP configuration

Edit file /etc/sysconfig/network-scripts/ifcfg-ensxx

+ To assign statically:

TYPE=”Ethernet”

BOOTPROTO=”static

NAME=”ens33″

UUID=”7abfe54d-b855-485a-ba95-430cca3ed830″

DEVICE=”ens33″

ONBOOT=”yes”

DNS1=”192.168.255.100″

GATEWAY=”192.168.255.2″

HOSTNAME=”fedora.abc.kh”

HWADDR=”00:0c:29:79:58:26″

IPADDR=”192.168.255.100″

NETMASK=”255.255.255.0″

NM_CONTROLLED=”yes”

+ To use DHCP: (Follow default configuration)

BOOTPROTO=”dhcp”

Install software

Example install “vim

First you need to update list, issue command “dnf -y update“, now you can start any installation like “dnf -y install vim

Note: If you use proxy, the way to configure your system to use proxy is as the following:

Edit file /etc/dnf/dnf.conf

[main]

gpgcheck=1

installonly_limit=3

clean_requirements_on_remove=True

proxy=http://yourProxyServer:YourProxyPort

proxy_username=yourUsername

proxy_password=yourPassword

 

Domain Name System (DNS) with bind

Install packages required for DNS

$dnf -y install bind bind-utils

Edit file /etc/resolv.conf

search mail.abc.kh

nameserver 192.168.255.100 #yourServerAddress

 

Main configuration: /etc/named.conf

options {

listen-on port 53 { 192.168.255.100; };

listen-on-v6 port 53 { none; };

directory “/var/named”;

dump-file “/var/named/data/cache_dump.db”;

statistics-file “/var/named/data/named_stats.txt”;

memstatistics-file “/var/named/data/named_mem_stats.txt”;

allow-query { localhost; any; };

forwarders {202.28.162.1;}; //your external (ISP) DNS

};

zone “.” IN {

type hint;

file “named.ca”;

};

zone “abc.kh” IN {

type master;

file “abc.kh.zone“;

};

zone “255.168.192.in-addr.arpa” IN{

type master;

file “255.zone“;

};

 

Configure Zone files

Location: /var/named

+ Forward zone: abc.kh.zone (filename)

$TTL 1D

abc.kh. IN SOA mail.abc.kh. root (

0 ; serial

1D ; refresh

1H ; retry

1W ; expire

3H ) ; minimum

IN NS mail.abc.kh.

mail IN A 192.168.255.100

IN MX 10 mail.abc.kh.

+ Reverse zone: 255.zone (filename)

$TTL 1D

255.168.192.in-addr.arpa. IN SOA mail.abc.kh. root (

0 ; serial

1D ; refresh

1H ; retry

1W ; expire

3H ) ; minimum

100.168.192.in-addr.arpa. IN NS mail.abc.kh.

100 IN PTR mail.abc.kh.

100 IN PTR abc.kh.

 

Start/reload service and test result

$systemctl start named or systemctl reload named

$nslookup mail.abc.kh (test against your records, or can test outside like nslookup google.com)

 

    

SMTP server with postfix

Install Postfix.

dnf -y install postfix

Configure SMTP Authentication to use Dovecot’s SASL function.

Edit file /etc/postfix/main.cf

# line 95: uncomment and specify hostname

myhostname = mail.abc.kh

# line 102: uncomment and specify domain name

mydomain = abc.kh

# line 118: uncomment

myorigin = $mydomain

# line 135: change

inet_interfaces = all

# line 138: change it if use only IPv4

inet_protocols = ipv4

# line 183: add

mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain

# line 283: uncomment and specify your local network

mynetworks = 127.0.0.0/8, 192.168.255.0/24

# line 438: uncomment (use Maildir)

home_mailbox = Maildir/

# line 593: add

smtpd_banner = $myhostname ESMTP

# add follows to the end

# limit an email size for 10M

message_size_limit = 10485760

# limit a mailbox for 1G

mailbox_size_limit = 1073741824

# SMTP-Auth settings

smtpd_sasl_type = dovecot

smtpd_sasl_path = private/auth

smtpd_sasl_auth_enable = yes

smtpd_sasl_security_options = noanonymous

smtpd_sasl_local_domain = $mydomain

smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject

 

Start & enable postfix service

$ systemctl start postfix

$ systemctl enable postfix

POP/IMAP Server with dovecot

Install dovecot

dnf -y install dovecot

Configure dovecot to provide SASL function to Postfix.

Edit file /etc/dovecot/dovecot.conf

# line 24: uncomment

protocols = imap pop3 lmtp

# line 30: uncomment and change ( if not use IPv6 )

listen = *, ::

Edit file /etc/dovecot/conf.d/10-auth.conf

# line 10: uncomment and change ( allow plain text auth )

disable_plaintext_auth = no

# line 100: add

auth_mechanisms = plain login

Edit file /etc/dovecot/conf.d/10-mail.conf

# line 30: uncomment and add

mail_location = maildir:~/Maildir

Edit file /etc/dovecot/conf.d/10-master.conf

# line 96-98: uncomment and add like follows

# Postfix smtp-auth

unix_listener /var/spool/postfix/private/auth {

mode = 0666


user = postfix

group = postfix

}

Edit file /etc/dovecot/conf.d/10-ssl.conf

# line 8: change (not require SSL)

ssl = no

 

Start and enable service

$ systemctl start dovecot

$ systemctl enable dovecot

 

DONE! Make sure your DNS is properly configured & your firewall is disable. (systemctl disable firewall)

 

Configure email client (Outlook) to use email

On server, test create two users: user1, user2 and satya

$ useradd -m user1 && useradd -m user2

$ passwd user1

$ passwd user2

 

Configure email client

On client, make sure the connection is fine and your dns is working (nslookup)

 

More Settings… and make sure you got 2 ticks

 

Test send an email from user2 to user satya

Send:

Receive:

Webmail with Squirrelmail

Download SquirrelMail for Fedora x86_64

ftp://rpmfind.net/linux/fedora/linux/releases/25/Everything/x86_64/os/Packages/s/squirrelmail-1.4.22-17.fc24.noarch.rpm

 

Install require packages

If you download from other machine, you can copy via SCP to your server.

Try to install, you will know what required by SquirrelMail

Now, let install those packages:

$ dnf -y install httpd hunspell-en mod_php php-mbstring tmpwatch

Then let try again, it must be fine.

Some information to know:

  • SquirrelMail is installed in /usr/share/squirrelmail.
  • Config files are in /etc/squirrelmail
  • A config file for httpd is added to /etc/http/conf.d. This aliases /webmail to the SquirrelMail install directory.
  • A cron job is set up to purge the attachments directory daily in /etc/cron.daily/squirrelmail.cron.
  • Run /usr/share/squirrelmail/config/conf.pl

 

So let run:

/usr/share/squirrelmail/config/conf.pl

Enter 1 , then follow the numbering and menu to edit as you wish as example below:

The most important part is option #2 Server Settings

Don’t forget to enter S to save, then if you’re sure you complete everything, then Q to exit

All you need to do with SquirrelMail is done.

Now let start the httpd service…

 

Start web server with httpd

Because we installed already, then just start service

$ systemctl start httpd && systemctl enable httpd

From client, let test access via browser

By default, SquirrelMail configured itself to use HTTPS, so for my case, I don’t want HTTPS anymore, just normal HTTP is fine.

What you need to do is to edit file /etc/httpd/conf.d/squirrelmail.conf

Line 24, change on to off

Then restart httpd service again. That’s it.

Test access webmail from client

 

 

 

Thanks you!!!

Read a file line by line in Java

Method 1:

private static void readFile1(File fin) throws IOException { FileInputStream fis = new FileInputStream(fin); //Construct BufferedReader from InputStreamReader BufferedReader br = new BufferedReader(new InputStreamReader(fis)); String line = null; while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); }

Method 2:

private static void readFile2(File fin) throws IOException { // Construct BufferedReader from FileReader BufferedReader br = new BufferedReader(new FileReader(fin)); String line = null; while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); }