Apache Installation Tips for PHP, SQL Server and MySQL Logo Monday, October 23, 2017
By The Voodooman what's new | faq | about

!!! WARNING !!!

This Guide is Deprecated!

Please go to the New Guide here.

Configuration

We're almost at the end of the process. All that remains to be done is to configure Apache to run properly and then your web-site should be up and running.

Preliminaries

The first thing to do is to make sure that the httpd daemon is not already running. You can check this by typing:

ps -xaf

If you see any httpd processes running, then note down the number under the PID column for the first httpd process and type the following at the prompt:

kill PID

where PID is the number that you noted earlier. This will stop the running httpd processes. You can verify that the processes are not running any more by typing 'ps -xaf' again.

TOP


1. Configuring Apache

The next step is to configure the Apache Web Server. To do this, follow the steps in sequence.
Note: The assumption here is that you configured apache with --prefix=/usr/local/apache. If you used --prefix=/usr/local or something else, change the paths accordingly (for instance, you would go to /usr/local/conf instead of /usr/local/apache/conf).
  • cd /usr/local/apache/conf
  • cp httpd.conf httpd.conf.bak
    This backs up the old file, in case you screw things up.
  • Open httpd.conf with your favourite text editor and edit the config files to your requirements. The httpd.conf file is pretty well commented, so it is not too hard to figure out what the various options do. If you want an example, the author's httpd.conf file looks something like this:
    ServerType standalone
    ServerRoot "/usr/local/apache"

    Timeout 30
    KeepAlive Off
    MaxKeepAliveRequests 100
    KeepAliveTimeout 15

    StartServers 5
    MinSpareServers 5
    MaxSpareServers 10
    MaxClients 150
    MaxRequestsPerChild 0

    ResourceConfig /dev/null
    AccessConfig /dev/null

    Port 80
    User nobody
    Group nobody

    ServerAdmin webmaster@yourdomain.com
    ServerName yourwebserver
    DocumentRoot "/usr/local/apache/htdocs"

    <Directory />
    Options FollowSymLinks
    AllowOverride None
    </Directory>

    DirectoryIndex index.php
    UseCanonicalName On

    HostnameLookups Off
    PidFile /usr/local/apache/logs/httpd.pid
    ScoreBoardFile /usr/local/apache/logs/httpd.scoreboard

    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    CustomLog /usr/local/apache/logs/access_log common
    ErrorLog /usr/local/apache/logs/error_log

    ServerSignature Off

    AddType application/x-httpd-php php php3
    #AddHandler imap-file map
    #AddHandler cgi-script pl

    ErrorDocument 403 /error.php
    ErrorDocument 404 /error.php
    ErrorDocument 500 /error.php

    NameVirtualHost 127.0.0.1

    #
    # Domain 1
    #
    <VirtualHost 127.0.0.1>
    ServerAdmin webmaster@yourdomain.com
    DocumentRoot /usr/local/apache/htdocs
    ServerName yourdomain.com
    ServerAlias *.yourdomain.com
    ErrorLog logs/yourdomain.com-error_log
    </VirtualHost>

    #
    # Domain 2
    #
    <VirtualHost 127.0.0.1>
    DocumentRoot /usr/local/apache/htdocs/apache-install
    DirectoryIndex mainpage.php
    ErrorDocument 404 /404page.php
    ErrorDocument 403 /404page.php
    ServerName www.mayukhbose.com
    </VirtualHost>

    Note that if you use the above example, you'll need to adjust the parameters for your own configuration. Pay particular attention to the places that are coloured like this -- you'll definitely need to change those values for your setup. The code above is for two domains that are set up on a single IP address. You can adjust the other parameters as well, such as the logging options, log formats, MinSpareServers etc. to your own requirements. Feel free to experiment!

  • The next step is to stop and start the apache server. To do this, type:

    /usr/local/apache/bin/apachectl stop
    /usr/local/apache/bin/apachectl start

    Every time you make changes to httpd.conf, you'll need to stop and start the apache server for the changes to take effect.
  • TOP

    2. Removing Junk Files

    This is an optional step, but the author usually does it anyway, just to reduce the number of files in the default directory (/usr/local/apache/htdocs/). There are a large number of files installed by default in this directory, which are all in different languages. The author usually removes all of them except for index.html.

    The author also removes all the files in /usr/local/apache/conf/ except for httpd.conf, magic and mime.types. You can do this also, if you wish.

    TOP

    3. Testing

    The following instructions assume that you've actually created the home directories for the domains and put files in there. For example, in httpd.conf, I've specified that the base directory for yourdomain.com is /usr/local/apache/htdocs and that the default document (specified by the DirectoryIndex derivative above) is index.html. For the www.mayukhbose.com domain, I've overridden some default values (the 403, 404 and default documents) and also specified a different base directory. Make sure that you have files in the proper locations as per your own settings. All you have to do is:
  • Make sure apache is running (you did this at the end of step 1.)
  • Use a web browser to hit your domain. If you see the page come up then you've done it all correctly! Congratulations!!!
  • TOP

    <<Previous: Installation ^Up to Mayukh's World^ Next: Credits N Stuff >>

    Apache Installation Walkthrough
    Last updated 12/25/2001