Apache Settings Virtualhost

Here an example of a setting for Apache virtualhost

  1. First of all install apache2 if is not installed
  2. then chose www-data as owner of the directory var/www recursively
  3. create the directory www.esempio.it
  4. create the directory www.esempio.it/cgi-bin
  5. for log files create the directory /var/log/www.esempio.it

[shell]
apt-get install apache2
chown -R www-data:www-data /var/www
mkdir /var/www/www.esempio.it
mkdir /var/www/www.esempio.it/cgi-bin
mkdir /var/log/www.esempio.it
[/shell]

Now create the config file in apache2 dir

[shell]
vi /etc/apache2/site-available/www.esempio.it
[/shell]
inside www.esempio.it you have all these elements >>>

<VirtualHost *:80> # it could be also <VirtualHost *:8080>

ServerAdmin [email protected]
ServerName www.esempio.it
ServerAlias esempio.it
 
DirectoryIndex index.html index.htm index.php
DocumentRoot /var/www/www.esempio.it/www/

CGI Directory

[bash]
ScriptAlias /cgi-bin/ /var/www/www.esempio.it/cgi-bin/
Options +ExecCGI
[/bash]

Logfiles

ErrorLog /var/log/www.esempio.it/error.log
CustomLog /var/log/www.esempio.it/access.log combined
</VirtualHost>

Create link from available-site to enabled-site using these useful Debian command a2dissite and a2ensite:

remove default settings
[shell]
a2dissite default
[/shell]
add your new site setting
[shell]
a2ensite www.esempio.it
[/shell]