Chapter 2. Basic setup

When setting up an Apache virtual server, we need to know a thing about apache.

When we setup a virtual server, the first thing to do is to prepare the config files.

I like to seperate all virtualhost directives to a file of it's own. In Debian - and apache in general - this is made easy by the include function.

Using the include function, I replace all of section 3 in the /etc/apache/httpd.conf with include /etc/apache/vhosts.conf, and then I create the /etc/apache/vhosts.conf file with the following content:


NameVirtualHost 192.168.228.14:80
NameVirtualHost 62.242.188.206:80

<VirtualHost 62.242.188.206:80 192.168.228.14:80>
	ServerAdmin  www@hoejte.dk
	ServerName   5xx.hoejte.dk
	ErrorLog     /var/log/apache/5xx/error.log
	TransferLog  /var/log/apache/5xx/access.log
	DocumentRoot /home/www/5xx/html
</VirtualHost>

The above is the basic virtual server, which catches all of the servers not matched in the following definitions. The content of the server is just a static page referencing all the virtual servers on the machine.

The next job is to define a server for an user on the system.


<VirtualHost 62.242.188.206:80 192.168.228.14:80>
	ServerAdmin  www@hoejte.dk
	ServerName   test.hoejte.dk
	ServerAlias  www.test.hoejte.dk
	ErrorLog     /var/log/apache/test/error.log
	TransferLog  /var/log/apache/test/access.log
	DocumentRoot /home/www/test/public_html
	php_admin_value open_basedir   /home/www/test
	php_admin_value include_path   .:/home/www/test/php_include
	php_admin_value upload_tmp_dir /home/www/test/upload
</VirtualHost>

As it is seen, it is exactly the same as the 5xx server, except that we have added some php limitations.

The next thing that should be noticed is that I have placed all my www users in the /home/www directory.

That's really all there is to it. Just remember to create the log directories, and prepare the users home directory with the required directories. The actual site creation is up to the user.