Apache is by far the most popular web server on the Internet. As of February 2005 Netcraft has reported more than 68% of sites surveyed use Apache. Due to it's open source nature and wide popularity it stands to reason why shouldn't a guide for apache installation should be made.
This guide is ultimately aimed at the home user who wants to put up a personal webpage from home. With the widespread increase of broadband and Linux, more and more people can start putting up personal webpages for blogging, home-made picture albums, hobby sites, etc.
Average users may think operating your own HTTP server is a lot more difficult and time consuming than it really is but the truth is if you just want to host pictures of the family then it really is not difficult.
Users should consider this guide a general, quick and easy way to get started with Apache. Full-blown websites involve a lot of work in configuring and securing but this guide will make it easy for users to get started with the basics.
Fortunately, Apache is available in portage and users are urged to get the latest version available in portage so that the latest stable bug fixes and security patches are installed.
# emerge sync
Generally, there are going to be a couple USE flags the user should be aware of before emerging Apache. Please enable the following flags that apply.
USE Flag | Description |
---|---|
Please add the appropiate USE flags to your
Compile time will vary from system to system but if you need a general estimate on compile time, an AMD 1.33Ghz Thunderbird with 512mb of RAM takes about 10 min.
# emerge apache
After Apache has been emerged the user should be made aware of how to
configure the Apache server. In this Chapter basic configuration options
will be given. The main configuration file is located at
The first thing users will want to do is to select an IP address and Port for the Apache server to listen in on.
# The listen directive is what is used to choose IP/Port. # Most users only have 1 IP address on their computer so the only # thing that needs to be set is the Port. The following will set # Apache to listen in on Port 80. There is no need to specify # an IP address since there is only 1 available on the computer. Listen 80# If the user would like Apache to listen on another port in addition # to port 80 then add another Listen line. Apache now listens on # Port 8000 and Port 80 if the user kept both lines in the config. Listen 8000# If users have multiple IPs then the following syntax can be used. Listen 192.168.0.20:80 Listen 192.168.0.150:8000
The DocumentRoot directive determines where the HTTP related files will go on the system. Users can change the location of files to whatever they feel.
# This is the default location in the config file DocumentRoot /var/www/localhost/htdocs# The location could be changed to a directory located in a user's # home directory as follows. DocumentRoot /home/user/www
If the user would like Apache to startup each time the Linux system is brought up then adding Apache to the runlevel is needed.
# rc-update add apache2 default
By now the user has the very basics setup for Apache and now all that is
needed is for the user to add whatever files he or she chooses. The document
root for all Apache files is located at
For now the user does not have to place anything in the DocumentRoot location.
HTTP related files can be inserted whenever but for now the default files at
It is now time for the user to start up the Apache server.
# /etc/init.d/apache2 start
Apache can just as easily be brought down with the following command.
# /etc/init.d/apache2 stop
If the user kept the configuration file to default so that Apache listens to port 80 and the DocumentRoot is left untouched then the user can immediately begin to test the newly started server.
Users should open up their favorite browser and enter in 127.0.0.1 into the browser address. The browser should immediately load a default page stating in the first sentence that the installation of the Apache web server is a success.
If the user would like to setup an Apache server for testing and would like to restrict access to just the local computer it can easily be done by using the Listen directive in the apache2.conf.
# 127.0.0.1 is the local loopback address to your computer Listen 127.0.0.1:80
It can be helpful to monitor your apache server for security or debugging
web applications through the error log. By default, the error log is located
in
# Default warning level is "warn" LogLevel warn# Highest warning level is "emerg" LogLevel emerg
Warning Levels from highest to lowest |
---|
To actively monitor the Apache log file on say a desktop, users can use a xterm and execute the following command.
# tail -f /var/log/apache2/error_log
Congratulations to the user for a painless quick start on Apache.
Users are encouraged to check back on this guide for more updates concerning Apache user and configuration. Possible future content include a FAQ.
Please direct all bug reports to Gentoo's