Ubuntu 10.04 (Lucid) x64 Apache image notes


Ubuntu 10.04 (Lucid) x64 Apache image notes

For more details on operating system please read the Ubuntu 10.04 (Lucid) x64 image instruction.
Linux with Apache installed

Apache Apache Hypertext Transfer Protocol Server.

The service version (shown in native reported format ) is:

# /usr/sbin/apache2 -V
Server version: Apache/2.2.14 (Ubuntu)
Server built:   Apr 13 2010 20:22:19
Server's Module Magic Number: 20051115:23
Server loaded:  APR 1.3.8, APR-Util 1.3.9
Compiled using: APR 1.3.8, APR-Util 1.3.9
Architecture:   64-bit
Server MPM:     Worker
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)

Apache server is configured to start at the VM boot time.

Troubleshooting Apache

If you get this error:

apache2: Could not determine the server’s fully qualified domain name, using for ServerName

then use a text editor such as vim to create a new file

# vim /etc/apache2/conf.d/fqdn

then add

ServerName localhost

to the file and save. This can all be done in a single command with the following:

echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn

Virtual Hosts

Apache2 has the concept of sites, which are separate configuration files that Apache2 will read. These are available in /etc/apache2/sites-available. By default, there is one site available called default this is what you will see when you browse to http://localhost or You can have many different site configurations available, and activate only those that you need.

As an example, we want the default site to be /home/user/public_html/. To do this, we must create a new site and then enable it in Apache2.
To create a new site:

  • Copy the default website as a starting point.
    # sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mysite
  • Edit the new configuration file in a text editor vim, for example:
    # vim /etc/apache2/sites-available/mysite
  • Change the DocumentRoot to point to the new location. For example, /home/user/public_html/
  • Change the Directory directive, replace to
  • You can also set separate logs for each site. To do this, change the ErrorLog and CustomLog directives. This is optional, but handy if you have many sites
  • Save the file
  • Now, we must deactivate the old site, and activate our new one. Ubuntu provides two small utilities that take care of this: a2ensite (apache2enable site) and a2dissite (apache2disable site).

    # sudo a2dissite default && sudo a2ensite mysite

    Finally, we restart Apache2:

    sudo /etc/init.d/apache2 restart

    If you have not created /home/user/public_html/, you will receive an warning message

    To test the new site, create a file in /home/user/public_html/:

    # echo 'Hello! It is working!' > /home/user/public_html/index.html

    Finally, browse to http://localhost/

    For more server settings, please check configuration files from /etc/apache2/conf.d/ and /etc/apache2/sites-enabled/ directories.