@1405010304geshuaishuai
2016-09-14T03:01:03.000000Z
字数 8677
阅读 453
Server
Linux
- SSH Server
- FTP Server
- Web Server
- E-mail Server
- Install software such as openssh or something like that and test.
- Install open-source or free FTP Server
- Create Admin, Ordinary user account and allocate different authorization
- Insatll open-source or free Web Server
- Design a personal homepage
- Install open-source or free E-mail Server
- Create and manage user's E-mail
- For SSH Server: My Linux OS has been already installed with SSH Server before I use it so I'll skip this step.
- For FTP Server: I'll install vsftpd on my Linux
- For Web Server: Installing Apache2, Mysql server and PHP on Linux(LAMP)
- For Email Server: To setup mail server in CentOS 6 (postfix-dovecot)
Step 1 >> Isuue the below command to install vsftpd
# yum -y install vsftpd
Vsftpd package installation is completed.
Step 2 >> After installation, now open /etc/vsftpd/vsftpd.conf which is the config file for vsftpd(FTP server).
Replace YES to NO in the below line.
anonymous_enable=NO
Find and uncomment the below lines
local_enable=YES
write_enable=YES
and uncomment this line to limit the users to their home directories.
chroot_local_user=YES
Step 3 >> Create a folder where you want to store FTP data. In my case I'm going to create in /(root folder) like below.
# mkdir /pub
Step 4 >> Now start creating users for accessing ftp server.
# useradd -d /pub test
# passwd test
You just created username test with home directory /pub.
Step 5 >> Start vsftpd service by issuing the below command.
# service vsftpd start
and type this below command to start service automatically while booting.
# chkconfig --levels 235 vsftpd on
Step 6 >> That's it, now we can check the FTP access. Create some files in /pub folder.
You can use winscp tool to upload/download files from FTP server.
also,you can use browser to download files from FTP server.
Troubleshooting:
If you not able to connect ftp server, Disable the firewall(iptables) and selinux service on your ftp server.
Disable firewall(iptables)>>
# service iptables stop
# chkconfig iptables off
Disable Selinux >> open the file /etc/selinux/config and find the line
SELINUX=enforcing
and replace with
SELINUX=disabled
now reboot the server and try again.
In this tutorial we can see the step by step installation of Apache webserver along with mysql and php enabled.
Update yum repositories and packages by typing the below command
# yum update
After updating repositories, we can start installing packages one by one.
Apache2 package installation and configuration is very simple.
Step 1 >> just type the command
# yum install httpd
This command will install httpd package along with dependencies
After installing the package.
Step 2 >> Open the file /etc/httpd/conf/httpd.conf.
Find "#ServerName www.example.com:80"(line no:276).
#
#ServerName www.example.com:80
and add this line below. "ServerName youripaddress:80"
#
#ServerName www.example.com:80
ServerName 192.168.1.102:80
Step 3 >> Now start apache service
# service httpd start
and type this below command to start apache service automatically while booting.
# chkconfig --levels 235 httpd on
Step 4 >> Now you have successfully configured apache web server. Open your browser and type the ip address in the address bar and hit enter. You can see the test page of your web server.
Testing your page:
Goto the default apache root path /var/www/html. Create a new file index.html and paste the below code and save it.
Welcome to my webserver
Again open the webserver ip address in the browser. You can see the index page created by you.
Step 1 >> just type the command to install mysql server and client packages along with dependencies.
# yum install mysql-server
After installation packages and dependencies.
Step 2 >> Start mysql service
# service mysqld start
and type this below command to start mysql server automatically while booting.
# chkconfig --levels 235 mysqld on
Step 3 >> Create a new root password for mysqlserver
# mysqladmin -u root password '********'
Step 4 >> Test your mysql server by login as root
# mysql - u root -p(press enter)
Enter password:(Type your mysql root password and press enter)
Now you can see the mysql prompt.
Step 1 >> Install php package along with php-mysql.
# yum install php php-mysql
After installing php, create a php info file to test your php configuration.
Step 2 >> Goto the default apache root path /var/www/html. Create a new file phpinfo.php and paste the below code and save it.
<?php
phpinfo();
?>
Step3 >> Restart apache service
# service httpd restart
Step 4 >> open the filepath in the browser(http://192.168.1.102/phpinfo.php
).
you can see the php information page as below.
Finally apache2, php and mysql has been configured perfectly. Few more steps need to be performed to check the database connectivity.
Testing All together:
We need to test mysql database connectivity in php.
Step 1 >> Create a new file dbtest.php in the apache root path(/var/www/html) and paste the below code. Replace "password" with your mysql root password.
<?php
$con = mysql_connect("localhost","root","password");
if(!$con)
{
die('Could not connect: '.mysql_error());
}
else
{
echo "Congrats! connection established successfully";
}
mysql_close($con)
?>
Step 2 >> open the filepath in the browser(http://192.168.1.102/dbtest.php
). You can see the page as below.
>>Postfix(for sending)
>>Dovecot(for receving)
Step 1 >> Before installation assign a static ip and add a host entry for your domain to that ip in /etc/hosts file like below.
192.168.0.15 geshuai.com
Step 2 >> Issue the below command to install postfix
# yum -y install postfix
Step 3 >> Now issue the below command to install SMTP AUTH packages.
# yum -y install cyrus-sasl cyrus-sasl-devel cyrus-sasl-gasspi cyrus-sasl-md5 cyrus-sasl-plain
Postfix package installation is completed.
Step 4 >> Issue the below commands one by one for creating SSL Cert.
# mkdir /etc/postfix/ssl
# cd /etc/postfix/ssl/
# openssl genrsa -des3 -rand /etc/hosts -out smtpd.key 1024
# chmod 600 smtpd.key
# openssl req -new -key smtpd.key -out smtpd.csr
# openssl x509 -req -days 365 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
# openssl rsa -in smtpd.key -out smtpd.key.unencrypted
# mv -f smtpd.key.unencrypted smtpd.key
# openssl req -new -x509 -extensions v3_ca -keyout cakey.pem -out cacert.pem -days 365
Step 5 >> Now open /etc/postfix/main.cf file.
Find and comment the below lines.
#inet_interfaces = localhost #---> line no 116
#mydestination = $myhostname, localhost.$mydomain, localhost #--> line no 164
and add these lines at the bottom of the line.
myhostname = mail.geshuai.com
mydomain = geshuai.com
myorigin = $mydomain
home_mailbox = mail/
mynetworks = 127.0.0.0/8
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
smtpd_sasl_auth_enable = yes
smtpd_sasl_type = cyrus
smtpd_sasl_security_options = noanonymous
broken_sasl_auth_clients = yes
smtpd_sasl_authenticated_header = yes
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_tls_auth_only = no
smtp_use_tls = yes
smtpd_use_tls = yes
smtp_tls_note_starttls_offer = yes
smtpd_tls_key_file = /etc/postfix/ssl/smtpd.key
smtpd_tls_cert_file = /etc/postfix/ssl/smtpd.crt
smtpd_tls_CAfile = /etc/postfix/ssl/cacert.pem
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
Step 6 >> Now open /etc/postfix/master.cf file and add the below line after smtp
smtps inet n - n - - smtpd
-o smtpd_sasl_auth_enable=yes
-o smtpd_reject_unlisted_sender=yes
-o smtpd_recipient_restrictions=permit_sasl_authenticated,reject
-o broken_sasl_auth_clients=yes
Step 7 >> Now start postfix and saslauthd service
# service postfix start
# service saslauthd start
>>Issue the below commands to start the postfix and saslauthd at startup
# chkconfig --level 235 postfix on
# chkconfig --level 235 saslauthd on
Step 8 >> Now check your smtp connectivity. Just telnet localhost on port 25 and type this command ehlo localhost
If you get this output.. Great .. everything is fine till now.
Step 9 >> Issue this command to install dovecot
# yum -y install dovecot
Step 10 >> After installation open /etc/dovecot/dovecot.conf file and add the below line at the end of the file. Please make sure mail_location and home_mailbox in postfix configuration are using the same name.
protocols = imap pop3
mail_location = maildir:˜/mail
pop_uidl_format=%08Xu%08Xv
Step 11 >> Now start dovecot service
# service dovecot start
>>Issue the below command to start the devecot at startup
# chkconfig --level 235 dovecot on
Step 12 >> Now test your pop3 connectivity.
Yes.. your server is ready to receive mails.
Step 13 >> Now create users to test your configuration.
# useradd -m bobby -s /sbin/nologin
# useradd -m leela -s /sbin/nologin
and create passwords for users created
# passwd bobby
# passwd leela
Step 14 >> Test your configuration in thunderbird. Refer the below image for configuration details
Step 15 >> Now you can send and receive mails using the server.
Your mail server is ready ...