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

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

Now create the config file in apache2 dir

vi /etc/apache2/site-available/www.esempio.it
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

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


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

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

remove default settings
a2dissite default
add your new site setting
a2ensite www.esempio.it