Title: Manage Apache
Course: CIS 208: Linux/UNIX III: Intermediate System Administration, Networking, and Security ~ For IGNITE Review > Section: Learning Modules

Manage Apache

Apache is the most popular webserver on the Internet.  It is a full featured server and many web applications are written to be run on a LAMP (Linux, Apache, Mysql, PHP) stack.

Apache may be installed alone, with SSL support, or with the entire LAMP stack.

yum install httpd
yum install httpd mod_ssl
yum install httpd mod_ssl mysql-server php php-mysql

The main configuration file for apache is /etc/httpd/conf/httpd.conf.  This file also includes all the .conf files in /etc/httpd/conf.d.  Generally default options are set in the main file, and overrides are set in the include files.  This makes it much easier to manage multiple applications and multiple virtualhosts.

- Section 1 of httpd.conf covers the global environment.  Configurations for performance tuning have reasonable defaults for typical usage.  If performance is an issue on high usage websites, consider tuning the MPM settings.  See the apache website for more information.
- Section 2 of httpd.conf covers the main server and sets the defaults for all virtualhosts.  These are some settings that are often configured.

ServerAdmin
SeverName
UseCanonicalName
DocumentRoot
<Directory " /var/www/html">
CustomLog

- Section 3 of httpd covers the virtualhost settings.  By default no virtualhosts are configured for port 80.  If mod_ssl has been installed, the /etc/httpd/conf.d/ssl.conf file includes the virtualhost for port 443.

Virtualhosts can be configured for each IP address, or they can be named-based.  To use name-based virtualhosts, ensure that each hostname resolves to the IP address of the server, then uncomment the NameVirtualHost *:80 line.  After the NameVirtualHost line, create one or more configurations using the VirtualHost directive.  The example below would create a default virtualhost and a secondary virtualhost.

<VirtualHost *:80>

ServerName www.mysite.com
ServerAlias mysite.com
CustomLogs logs/mysite.com-access common
ErrorLogs logs/mysite.com-errors
</VirtualHost>
<VirtualHost *:80>
ServerName mail.mysite.com
ServerAlias www.mail.mysite.com
DocumentsRoot /var/www/mail
CustomLogs logs/mail.mysite.com-access common
ErrorLogs logs/mail.mysite.com-errors
</VirtualHost>

After updating the configuration for apache, run "service httpd reload".

In a previous module we saw how to configure SSL.  PHP and mysql may need some configuration.  See the documentation for each application to be installed.