Apache installation

As root, issue the command:

apt-get install apache2

This will download and install the required packages for installing and starting the Apache server. That's all ! If the server is installed on your host system, simply check everything is okay by directing your favourite web browser to the URL : http://localhost/.

You should be able to read the simple message : It works !

If your web server has been installed on a guest virtual system, and you configured a virtual network like in this previous article, you should be able to access it through this URL:

User home pages

You can enable your Unix users to have their own web pages. The root directory for each user, if present, will be $HOME/public_html. The URL for each of the users home pages will be http://your-web-server-url.com/~username/.

User home pages are deactivated by default. To enable them, issue the commands:

a2enmod userdir
/etc/init.d/apache2 reload

PHP module

PHP is the most used scripting language for web applications (just like this blog infrastructure for instance). Install it and activate it using the single command:

apt-get install libapache2-mod-php5

Virtual host setup

The web server running this blog handles different websites from the same IP address. The website to be served depends on the virtual host name from which the web server is accessed. You will have to set up each of the servers separately in different configuration files, put into the /etc/apache2/sites-available directory. For this blog, for instance, I created a /etc/apache2/sites-available/blog file, containing the following:

<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName blog.ouasse.ath.cx
DocumentRoot /home/ouasse/www/dotclear

ErrorLog /var/log/apache2/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined

It simply maps all accesses from the http://blog.ouasse.ath.cx/ URL to the local /home/ouasse/www/dotclear directory, which has been configured with www-data group rights.

After having created such a website configuration file, activate it using the commands:

a2ensite filename

Where filename is the name of the configuration file. For the example above, I would have used the blog value.


That's all ! As you have seen, Apache2 base installation is quite straightforward. In future articles I may talk about configuring Apache for doing funny stuff like virtual hostname-based websites, and installing full applications such as the Doctclear blog infrastructure which I use for running this blog.