Before we install any packages we should ensure that the correct use-flags are configured so that all required functionality is made available and unnecessary functionality is not included. The www-servers/apache and its dependencies provide a variety of use-flags only some of which will be discussed further here. As usual feel free to add and remove use-flags at will although the minimum set which are required for using this guide in its entirety are shown below.
Once you are confident that the correct use-flags are set for the www-servers/apache package, and any dependencies it may require, you can proceed with the installation by issuing the emerge command shown below.
The default configuration provided with the www-servers/apache package instructs the apache daemon to write any log messages to a file located at /var/log/apache2/error_log. In a production environment it is often desirable to have all logging performed through a central log service which can be configured to perform a variety of tasks such as sending emails to administrators when certain conditions arise. The apache daemon can be configured to use the standard UNIXsyslog service by modifying the configuration as shown below.
ErrorLog /var/log/apache2/error_log
ErrorLog syslog:local1
The default configuration provided with the www-servers/apache package also limits the level of log messages to that of warning, which provides no indication in the logs that the apache is even running. More output can be generated by modifying the LogLevel setting as shown below. We have set the log level to information here which produces plenty of useful output without being as overwhelming as the debug setting. In a production environment the notice log level may be more appropriate.
LogLevel warn
LogLevel info
When the apache package and its dependencies have finished installing the apache daemon can be started and added to the default run-level using the commands shown below.
The default configuration for a new installation of apache already provides a set of files to enable serving a single static web site. If you point a web browser at the network address of the host on which you performed the installation you will see that default page. It is a good idea to check that this is indeed the case at this early stage as troubleshooting will only become more difficult as the configuration becomes more complex.