Apache HTTP Web server configuration:
This tutorial is for the Apache HTTP web server (Version 1.3 and 2.0). See the YoLinux list of Linux HTTP servers for a list of other web servers for the Hyper Text Transport Protocol.
The Apache web server configuration file is: /etc/httpd/conf/httpd.conf
Web pages are served from the directory as configured by the DocumentRoot directive. The default directory location is:
Â Â Linux distribution Apache web server "DocumentRoot"
Â Â Red Hat 7.x-9, Fedora Core, Red Hat Enterprise 4/5/6, CentOS 4/5/6 /var/www/html/
Â Â Red Hat 6.x and older /home/httpd/html/
Â Â Suse 9.x /srv/www/htdocs/
Â Â Ubuntu (dapper 6.06) / Debian /var/www/html
Â Â Ubuntu (hardy 8.04/natty 11.04) / Debian /var/www
The default home page for the default configuration is index.html. Note the pages should not be owned by user apache as this is the process owner of the httpd web server daemon. If the web server process is comprimised, it should not be allowed to alter the files. The files should of course be readable by user apache.
Apache may be configured to run as a host for one web site in this fashion or it may be configured to serve for multiple domains. Serving for multiple domains may be achieved in two ways:
Â Â Virtual hosts: One IP address but multiple domains - "Name based" virtual hosting.
Â Â Multiple IP based virtual hosts: One IP address for each domain - "IP based" virtual hosting.
[Potential Pitfall] The default umask for directory creation is correct by default but if not use: chmod 755 /home/user1/public_html
[Potential Pitfall] When creating new "Directory" configuration directives, I found that placing them by the existing "Directory" directives to be a bad idea. It would not use the .htaccess file. This was because the statement defining the use of the .htaccess file was after the "Directory" statement. Previously in RH 6.x the files were separated and the order was defined a little different. I now place new "Directory" statements near the end of the file just before the "VirtualHost" statements.
For users of Red Hat 7.1, the GUI configuration tool apacheconf was introduced for the crowd who like to use pretty point and click tools.
Files used by Apache:
Â Â Start/stop/restart script:
Â Â Â Â Red Hat/Fedora/CentOS: /etc/rc.d/init.d/httpd
Â Â Â Â SuSE 9.3: /etc/init.d/apache2
Â Â Â Â Ubuntu (dapper 6.06/hardy 8.04/natty 11.04) / Debian: /etc/init.d/apache2
Â Â Apache main configuration file:
Â Â Â Â Red Hat/Fedora/CentOS: /etc/httpd/conf/httpd.conf
Â Â Â Â SuSE: /etc/apache2/httpd.conf
Â Â Â Â (Need to add directive: ServerName host-name)
Â Â Â Â Ubuntu (dapper 6.06/hardy 8.04/natty 11.04) / Debian: /etc/apache2/apache2.conf
Â Â Apache suplementary configuration files:
Â Â Â Â Red Hat/Fedora/CentOS: /etc/httpd/conf.d/component.conf
Â Â Â Â SuSE: /etc/apache2/conf.d/component.conf
Â Â Â Â Ubuntu (dapper 6.06/hardy 8.04/natty 11.04) / Debian:
Â Â Â Â Â Â Virtual domains: /etc/apache2/sites-enabled/domain
Â Â Â Â Â Â (Create soft link from /etc/apache2/sites-enabled/domain to /etc/apache2/sites-available/domain to turn on. Use command a2ensite)
Â Â Â Â Â Â Additional configuration directives: /etc/apache2/conf.d/
Â Â Â Â Â Â Modules to load: /etc/apache2/mods-available/
Â Â Â Â Â Â (Soft link to /etc/apache2/mods-enabled/ to turn on)
Â Â Â Â Â Â Ports to listen to: /etc/apache2/ports.conf
Â Â /var/log/httpd/access_log and error_log - Red Hat/Fedora Core Apache log files
Â Â (Suse: /var/log/apache2/)