People familiar with my previous instruction sets will notice that I have changed the layout of the files. I believe this new format to be slightly better.
su root
cd /usr/local/etc
/usr/local/downloadsIf you like this idea and don't already do it you might need to create the directory:
mkdir /usr/local/downloadsHere are the ftp commands to get the file:
cd /usr/local/downloads ftp ftp.apache.org cd dist bin get apache_1.3.14.tar.gz bye
tar xzf apache_1.3.14.tar.gz -C ../etc
cd /usr/local/etc ln -s apache_1.3.14 httpdI've decided to start using httpd for the link since that's what everyone else seems to do.
All of the version specific (1.3.14) binaries and files are stored in:
/usr/local/etc/apache_1.3.14We currently have:
/usr/local/etc/httpdlinked to this directory specifying it as the current version. In theory when we upgrade Apache in the future we can just install it side by side and then switch over the httpd link to the newly installed version.
We will be placing all of our non-version specific files such as configuration files, log files and the web pages in:
/wwwWe will have a few directories here to maintain this structure:
/www /www/conf -- configuration files /www/logs -- web server logs /www/logs/mysite.com -- log files for mysite.com /www/logs/mycharity.org -- log files for mycharity.com /www/servers -- sites /www/servers/mysite.com -- web pages for mysite.com /www/servers/mycharity.org -- web pages for mycharity.com
cd / mkdir wwwIf you have space issues or a super fast disk you would like to use then you might like to create /www as a link to the preferred location. For example:
cd /u01 mkdir www cd / ln -s /u01/www www
cd /www mkdir conf logs servers
cd /usr/local/etc/httpd ./configure --prefix=/usr/local/etc/httpd --sysconfdir=/www/conf --enable-module=rewrite --enable-module=statusThis sets up the installation with the apache binaries in /usr/local/etc/httpd and puts the configuration files in /www/conf. It also sets up status reporting and the rewrite module allows url redirection and rewriting.
If you want to go really nuts with your apache installation, adding extra modules and so on then check out the options by using:
./configure --help
make
make installOne nice thing here is that if you are installing a new apache, it will not override the existing configuration files. Of course, this can also be a gotcha if you want to wipe the old installation completely...
top
top gives a list of all processes that are currently running on the machine. Make sure that you size the xterm window so that you can see all of the processes (lines) that are listed. Apache is running if you can see a number of lines that look something like:
475 nobody 0 0 1388 1388 1232 S 0 0.0 1.0 0:00 httpd
If you want to see what Apache is doing on your machine the simplest way is to point your browser (on the same machine) at it:
http://localhost
/www/conf/httpd.conf
Go there now with:
cd /www/conf
/etc/httpd/conf/httpd.confIf you are upgrading and you want to keep your old configuration file (and it is from a compatible Apache version) then just copy it over the new one:
cp /etc/httpd/conf/httpd.conf .You may also need to use your existing access and srm config files:
cp /etc/httpd/conf/access.conf . cp /etc/httpd/conf/srm.conf .
If you want to run Apache on a different port to the default (80) then change the number on line 238. Ports less than 1024 will require Apache to be started as root. Port 80 is probably the easiest to use since all other ports have to be specified explicitly in the web browser, eg: http://localhost:81.
Port 80
You may want to change the server admin email address on line 260:
ServerAdmin nathan@synop.com
You should specify your machine name on line 278, you may just have to remove the # comment marker. If you configure virtual hosts as outlined below then Apache will use the virtual server you name here as the default documents for the site.
ServerName synop.com
You should set the document root on line 285:
DocumentRoot "/www/servers"
And on line 310:
<Directory "/www/servers">
If you want to be able to change the Apache configuration on a per directory basis then the use of .htaccess files needs to be allowed. To enable this set AllowOverride to All on line 326:
AllowOverride All
The default file to serve in directories is index.html. You can change this or add new file names (in order or importance) on line 365:
DirectoryIndex index.html index.htm
If you don't get a large number of hits and you want to know where your visitors are from then turn host name look ups on at line 450. Turning this on does place extra load on your server as it has to look up the host name corresponding to the IP address of all your visitors.
HostnameLookups On
One of the things that a browser sends to the web server when requesting a web page is the host name of the server that it is connecting to. Apache catches all the HTTP requests that come to this machine (on the ports it was told to listen to). It then examines the host name included in the request and uses that to determine the virtual host configuration it should utilize.
In the Apache configuration file we must specify each IP address and port combination for which we will be specifying virtual host domains. So, for the example above we would add this to the end of the httpd.conf file:
NameVirtualHost 216.167.19.49:80It is important to note that you cannot use an IP address unless your machine has been configured to use it. If you are setting up a single development machine then you should probably just use the address 127.0.0.1 which always refers to the local machine.
NameVirtualHost 216.167.19.48:80
cd /www/servers
mkdir synop.com mkdir e-gineer.comSo, for example, the e-gineer home page is located at:
/www/servers/e-gineer.com/index.phtmlThe instructions you are reading right now live at:
/www/servers/e-gineer.com/instructions/install-apache1xx-on-linux.phtml
cd /www/logs mkdir synop.com mkdir e-gineer.com
127.0.0.1 ws01.synop.com localhost dev.synop.com dev.e-gineer.com aolserver.doc apache.doc php.doc solid.doc mysql.docYou can see that I have also created dummy domains for the documentation of various products. By creating virtual hosts to handle these domains I can just fire up Netscape and type in apache.doc for easy off-line access to the manual.
ping dev.synop.com
PING ws01.synop.com (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.2 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.1 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.1 ms 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.1 ms --- ws01.synop.com ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 0.1/0.1/0.2 ms
ping apache.doc
PING ws01.synop.com (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.2 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.1 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.1 ms 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.1 ms --- ws01.synop.com ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 0.1/0.1/0.2 ms
/www/conf/httpd.confThe example in the default configuration file is fairly self explanatory. We just add the virtual host entries to the end of the httpd.conf file. Here are the entries on my development machine:
NameVirtualHost 127.0.0.1:80 # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # #<VirtualHost ip.address.of.host.some_domain.com> # ServerAdmin webmaster@host.some_domain.com # DocumentRoot /www/docs/host.some_domain.com # ServerName host.some_domain.com # ErrorLog logs/host.some_domain.com-error_log # CustomLog logs/host.some_domain.com-access_log combined #</VirtualHost> #<VirtualHost _default_:*> #</VirtualHost> <VirtualHost 127.0.0.1:80> ServerAdmin webmaster@synop.com DocumentRoot /www/servers/synop.com ServerName dev.synop.com ErrorLog /www/logs/synop.com/error-log CustomLog /www/logs/synop.com/access-log combined </VirtualHost> <VirtualHost 127.0.0.1:80> ServerAdmin webmaster@synop.com DocumentRoot /www/servers/e-gineer.com ServerName dev.e-gineer.com ErrorLog /www/logs/e-gineer.com/error-log CustomLog /www/logs/e-gineer.com/access-log combined </VirtualHost> <VirtualHost 127.0.0.1:80> ServerAdmin webmaster@synop.com DocumentRoot /www/servers/apache.doc ServerName apache.doc ErrorLog /www/logs/apache.doc/error-log CustomLog /www/logs/apache.doc/access-log combined </VirtualHost> <VirtualHost 127.0.0.1:80> ServerAdmin webmaster@synop.com DocumentRoot /www/servers/php.doc ServerName php.doc ErrorLog /www/logs/php.doc/error-log CustomLog /www/logs/php.doc/access-log combined </VirtualHost> <VirtualHost 127.0.0.1:80> ServerAdmin webmaster@synop.com DocumentRoot /www/servers/mysql.doc ServerName mysql.doc ErrorLog /www/logs/mysql.doc/error-log CustomLog /www/logs/mysql.doc/access-log combined </VirtualHost> <VirtualHost 127.0.0.1:80> ServerAdmin webmaster@synop.com DocumentRoot /www/servers/aolserver.doc ServerName aolserver.doc ErrorLog /www/logs/aolserver.doc/error-log CustomLog /www/logs/aolserver.doc/access-log combined </VirtualHost> <VirtualHost 127.0.0.1:80> ServerAdmin webmaster@synop.com DocumentRoot /www/servers/solid.doc ServerName solid.doc ErrorLog /www/logs/solid.doc/error-log CustomLog /www/logs/solid.doc/access-log combined </VirtualHost>
killall httpd
cd /usr/local/etc/httpd/bin ./apachectl start
./apachectl help