Setup New CentOS 6.2 Web Server
By Shay Anderson on November 2012
In the following article I explain how to setup a basic Web server on a new install of CentOS 6 (in my case CentOS 6.2).
Install Nano
First, I use the text editor nano, so I needed to install this editor first: >> yum install nano
Setup Apache Configuration File
Next, I want to disable Indexes for directory options, this means that someone can’t view the ‘Index Of’ or listing of files in my Web directories. To do this edit the ‘/etc/httpd/conf/httpd.conf’ and add ‘-Indexes’ to this line:
[...]
Options FollowSymLinks -Indexes
[...]
Also, add ‘-Indexes’ to this line:
[...]
Options FollowSymLinks -Indexes
[...]
Setup Root Password
I like to use simple passwords for the root user, if you want to use simple passwords you must edit the ‘/etc/pam.d/system-auth’ file, change these 2 lines: password requisite pam_cracklib.so try_first_pass retry=3 type=
password sufficient pam_unix.so try_first_pass use_authtok nullok sha512 shadowTo this (comment out the first line and remove ‘use_authtok’ from the second line): #password requisite pam_cracklib.so try_first_pass retry=3 type=
password sufficient pam_unix.so try_first_pass nullok sha512 shadowSave the file and now change the root password: >> passwd root
Enter new UNIX password:
Setup Timezone
I am setting up my server on the east coast, so I need to change my server timezone to east coast (or the New York timezone). To check your server date/time and timezone use this command: >> date
Fri Nov 5 22:02:30 CST 2012Now, to change the timezone first create a backup of ‘/etc/localtime’: >> cp -v /etc/localtime /etc/localtime.BAKNext, remove the ‘/etc/localtime’ file: >> rm -fv /etc/localtime Finally, create a link to the correct timezone (in my case New York): >> ln -s /usr/share/zoneinfo/America/New_York /etc/localtimeYou can check all available timezones in the ‘/usr/share/zoneinfo/America’ directory.
Install FTP Server (vsftpd)
Next, install a FTP server (in this example I install vsftpd): >> yum install vsftpdAdd a user for FTP access (-d switch sets the default directory for user, in this case I am setting it to the ‘/var/www/html’ directory for Web server purposes): >> useradd -d /var/www/html ftpuserAdd a password for the user: >> passwd ftpuserNow, edit the ‘/etc/passwd’ file so we can block the ‘ftpuser’ user from SSH access, make sure the ‘ftpuser’ line looks something like: ftpuser:x:500:500::/home/ftpuser:/sbin/nologinNext, edit the vsftpd configuration file ‘/etc/vsftpd/vsftpd.conf’ file and turn anonymous OFF: # Allow anonymous FTP? (Beware – allowed by default if you comment this out).
anonymous_enable=NOIn the same file make sure these settings look like: chroot_local_user=YES
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd/chroot_list
Then create ‘chroot_list’ file: >> touch /etc/vsftpd/chroot_listSave the file and restart vsftpd: >> service vsftpd restartNow, you should be able to access your server via FTP using the ‘ftpuser’ account.
Finally, setup vsftpd to auto startup with the server is booted: >> chkconfig vsftpd onYou can check if vsftpd is set on with: >> chkconfig –list
Install PHP 5.3
Next, install PHP 5.3: >> yum install php.x86_64Check the install with: >> php -v
PHP 5.3.3 (cli) (built: Jul 3 2012 16:53:21)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend TechnologiesRestart Apache: >> service httpd restart
http://www.shayanderson.com/linux/setup-new-centos-62-web-server.htm