I will use the following software:
- Web Server: Apache 2.2.10
- PHP 5.2.6
- Ruby
- Python
- Database Server: MySQL 5.0.67
- Mail Server: Postfix
- DNS Server: BIND9 (chrooted)
- FTP Server: proftpd
- POP3/IMAP server: Dovecot
- Webalizer for web site statistics
In the end you should have a system that works reliably, and if you like you can install the free webhosting control panel ISPConfig (i.e., ISPConfig runs on it out of the box).
I want to say first that this is not the only way of setting up such a system. There are many ways of achieving this goal but this is the way I take. I do not issue any guarantee that this will work for you!
1 Requirements
To install such a system you will need the following:
- Download the Fedora 10 DVD iso image from a mirror near you (the list of mirrors can be found here: http://mirrors.fedoraproject.org/publiclist/Fedora/10/), e.g. http://fedora.tu-chemnitz.de/pub/linux/fedora/linux/releases/10/Fedora/i386/iso/Fedora-10-i386-DVD.iso
- an Internet connection...
2 Preliminary Note
In this tutorial I use the hostname server1.example.com with the IP address 192.168.0.100 and the gateway 192.168.0.1. These settings might differ for you, so you have to replace them where appropriate.
3 Install The Base System
Boot from your Fedora 10 DVD. Select Install or upgrade an existing system:
It can take a long time to test the installation media so we skip this test here:
The welcome screen of the Fedora installer appears. Click on Next:
Choose your language next:
Select your keyboard layout:
I'm installing Fedora 10 on a fresh system, so I answer Yes to the question Would you like to initialize this drive, erasing ALL DATA?:
Fill in the hostname of the server:
Choose your time zone:
Give root a password:
Next we do the partitioning. Select Remove Linux partitions on selected drives and create default layout. This will give you a small /boot partition and a large / partition which is fine for our purposes:
Select Write changes to disk:
The hard drive is being formatted:
Now we select the software we want to install. Uncheck Office and Productivity and check Software Development and Web server instead. Then check Customize now. Afterwards, select the additional repositories Fedora 10 - i386 and Fedora 10 - i386 - Updates (if you are on an x86_64 system, the names are probably Fedora 10 - x86_64 and Fedora 10 - x86_64 - Updates):
As the last two repositories need an Internet connection, a new window pops up where you have to configure your network card. Select Enable IPv4 support, but disable Use dynamic IP configuration (DHCP); then give your network card a static IP address and netmask (in this tutorial I'm using the IP address 192.168.0.100 and netmask 255.255.255.0 for demonstration purposes; if you are not sure about the right values, http://www.subnetmask.info might help you). Also fill in your gateway (e.g. 192.168.0.1) and one nameserver (e.g. 145.253.2.75):
When I clicked on OK, I got an error message saying that the network configuration had failed, but despite this, details for the last two repositories were retrieved, and the checkboxes in front of the two repositories got marked, which means that the network connection is working, and the error message was wrong (might be a bug in the installer). Click on Next:
Now we must select the package groups we want to install. Select Editors, Text-based Internet, Development Libraries, Development Tools, DNS Name Server, FTP Server, Mail Server, MySQL Database, Server Configuration Tools, Web Server, Administration Tools, Base, Hardware Support, Java, System Tools (unselect all other package groups) and click on Next:
The installation begins. This will take a few minutes:
Finally, the installation is complete, and you can remove your DVD from the computer and reboot it:
After the reboot, you will see this screen. Select Firewall configuration and hit Run Tool:
I want to install ISPConfig at the end of this tutorial which comes with its own firewall. That's why I disable the default Fedora firewall now. Of course, you are free to leave it on and configure it to your needs (but then you shouldn't use any other firewall later on as it will most probably interfere with the Fedora firewall).
Hit OK afterwards:
Confirm your choice by selecting Yes:
Next select Network configuration:
If you did not configure your network card during the installation (either because you did not select the additional online repositories or because the installer really failed to bring up your network card), you can do that now by going to Edit a device params:
Select your network interface (usually eth0):
Then fill in your network details - disable DHCP and fill in a static IP address, a netmask, and your gateway, then hit Ok:
Next select Save:
What you should do in all cases (regardless of whether you configured your network connection during the installation or just now) is specify nameservers (during the intial installation, you could fill in just one nameserver, therefore you should specify at least a second one now). Select Edit DNS configuration:
Now you can fill in additional nameservers and hit Ok:
Hit Save&Quit afterwards...
... and leave the Choose a Tool window by selecting Quit:
You should run
ifconfig
now to check if the installer got your IP address right. If it did not, restart the NetworkManager...
/etc/init.d/NetworkManager restart
... and if that still doesn't help, reboot the system:
reboot
If the IP address is still not correct, run
system-config-network
and redo the network configuration.
Now, on to the configuration...
4 Adjust /etc/hosts
Next we edit /etc/hosts. Make it look like this:
vi /etc/hosts
# Do not remove the following line, or various programs |
It is important that you add a line for server1.example.com and remove server1.example.com and server1 from the 127.0.0.1 line.
5 Configure The Firewall
(You can skip this chapter if you have already disabled the firewall at the end of the basic system installation.)
I want to install ISPConfig at the end of this tutorial which comes with its own firewall. That's why I disable the default Fedora firewall now. Of course, you are free to leave it on and configure it to your needs (but then you shouldn't use any other firewall later on as it will most probably interfere with the Fedora firewall).
Run
system-config-firewall
and disable the firewall.
To check that the firewall has really been disabled, you can run
iptables -L
afterwards. The output should look like this:
[root@server1 ~]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
[root@server1 ~]#
6 Disable SELinux
SELinux is a security extension of Fedora that should provide extended security. In my opinion you don't need it to configure a secure system, and it usually causes more problems than advantages (think of it after you have done a week of trouble-shooting because some service wasn't working as expected, and then you find out that everything was ok, only SELinux was causing the problem). Therefore I disable it (this is a must if you want to install ISPConfig later on).
Edit /etc/selinux/config and set SELINUX=disabled:
# This file controls the state of SELinux on the system. |
Afterwards we must reboot the system:
7 Install Some Software
Next we update our existing packages on the system:
Now we install some software packages that are needed later on:
yum install fetchmail wget bzip2 unzip zip nmap openssl lynx fileutils ncftp gcc gcc-c++
8 Quota
To install quota, we run this command:
Edit /etc/fstab and add ,usrquota,grpquota to the / partition (/dev/VolGroup00/LogVol00):
# |
9 Install A Chrooted DNS Server (BIND9)
To install a chrooted BIND9, we do this:
Next, we change a few permissions and start BIND:
10 MySQL (5.0)
yum install mysql mysql-devel mysql-server
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
Now check that networking is enabled. Run
It should show something like this:
[root@server1 ~]# netstat -tap | grep mysql
tcp 0 0 *:mysql *:* LISTEN 2407/mysqld
[root@server1 ~]#
If it does not, edit /etc/my.cnf and comment out the option skip-networking:
[...] |
and restart your MySQL server:
to set a password for the user root (otherwise anybody can access your MySQL database!).
If the last command throws an error at you...
... we can set the password as follows: connect to MySQL:
Type in the password for the MySQL root user. Then, on the MySQL shell, do this:
to make sure that all rows where the user is root have a password.
If everything is looking ok, run
... and leave the MySQL shell:
11 Postfix With SMTP-AUTH And TLS
Now we install Postfix and Dovecot (Dovecot will be our POP3/IMAP server):
Now we configure SMTP-AUTH and TLS:
pwcheck_method: saslauthd |
Afterwards we create the certificates for TLS:
chmod 600 smtpd.key
openssl req -new -key smtpd.key -out smtpd.csr
openssl x509 -req -days 3650 -in smtpd.csr -signkey smtpd.key -out smtpd.crt
openssl rsa -in smtpd.key -out smtpd.key.unencrypted
Next we configure Postfix for TLS:
postconf -e 'myhostname = server1.example.com'
queue_directory = /var/spool/postfix |
Now start Postfix, saslauthd, and Dovecot:
To see if SMTP-AUTH and TLS work properly now run the following command:
After you have established the connection to your Postfix mail server type
to return to the system's shell.
11.1 Maildir
postconf -e 'home_mailbox = Maildir/'
postconf -e 'mailbox_command ='
/etc/init.d/postfix restart
12 Apache2 With PHP, Ruby, Python
Now we install Apache with PHP5 (this is PHP 5.2.6):
Then edit /etc/httpd/conf/httpd.conf:
[...] |
Now configure your system to start Apache at boot time:
chkconfig --levels 235 httpd on
12.1 Disable PHP Globally
(If you do not plan to install ISPConfig on this server, please skip this section!)
# |
12.2 Ruby
Starting with version 2.2.20, ISPConfig has built-in support for Ruby. Instead of using CGI/FastCGI, ISPConfig depends on mod_ruby being available in the server's Apache.
For Fedora 10, there's no mod_ruby package available, so we must compile it ourselves. First we install some prerequisites:
yum install httpd-devel ruby ruby-devel
Next we download and install mod_ruby as follows:
cd /tmp
wget http://www.modruby.net/archive/mod_ruby-1.3.0.tar.gz
tar zxvf mod_ruby-1.3.0.tar.gz
cd mod_ruby-1.3.0/
./configure.rb --with-apr-includes=/usr/include/apr-1
make
make install
Finally we must add the mod_ruby module to the Apache configuration, so we create the file /etc/httpd/conf.d/ruby.conf...
vi /etc/httpd/conf.d/ruby.conf
LoadModule ruby_module modules/mod_ruby.so |
... and restart Apache:
/etc/init.d/httpd restart
You can find more details about mod_ruby in this article.
12.3 Installing mod_python
To install mod_python, we simply run...
yum install mod_python
... and restart Apache afterwards:
/etc/init.d/httpd restart
13 ProFTPd
ISPConfig has better support for proftpd than vsftpd, so let's remove vsftpd and install proftpd:
yum remove vsftpd
yum install proftpd
Now we can create the system startup links for Proftpd and start it:
chkconfig --levels 235 proftpd on
/etc/init.d/proftpd start
14 Webalizer
To install webalizer, just run
yum install webalizer
15 Synchronize The System Clock
If you want to have the system clock synchronized with an NTP server do the following:
yum install ntp
chkconfig --levels 235 ntpd on
ntpdate 0.pool.ntp.org
/etc/init.d/ntpd start
16 Install Some Perl Modules
ISPConfig comes with SpamAssassin which needs a few Perl modules to work. We install the required Perl modules with a single command:
yum install perl-HTML-Parser perl-DBI perl-Net-DNS perl-Digest-SHA1 perl-ExtUtils-AutoInstall
17 ISPConfig
The configuration of the server is now finished. You can now install ISPConfig on it, following these instructions: http://www.ispconfig.org/manual_installation.htm
17.1 A Note On SuExec
If you want to run CGI scripts under suExec, you should specify /var/www as the web root for websites created by ISPConfig as Fedora's suExec is compiled with /var/www as Doc_Root. Run
/usr/sbin/suexec -V
and the output should look like this:
[root@server1 ~]# /usr/sbin/suexec -V
-D AP_DOC_ROOT="/var/www"
-D AP_GID_MIN=100
-D AP_HTTPD_USER="apache"
-D AP_LOG_EXEC="/var/log/httpd/suexec.log"
-D AP_SAFE_PATH="/usr/local/bin:/usr/bin:/bin"
-D AP_UID_MIN=500
-D AP_USERDIR_SUFFIX="public_html"
[root@server1 ~]#
So if you want to use suExec with ISPconfig, don't change the default web root (which is /var/www) if you use expert mode during the ISPConfig installation (in standard mode you can't change the web root anyway so you'll be able to use suExec in any case).
18 Links
- Fedora: http://fedoraproject.org
- ISPConfig: http://www.ispconfig.org