tomazsaraiva
3/24/2018 - 10:17 AM

Apache Configuration for new DEV site

// create directories to serve content inside apache root folder
sudo mkdir -p /var/www/site1.com/public_html

// change directories ownership to add write permissions to our current user
sudo chown -R $USER:$USER /var/www/site1.com/public_html

// add read permissions to the general web directory
sudo chmod -R 755 /var/www

// create sample pages for our site
nano /var/www/site1.com/public_html/index.html

<html>
  <head>
    <title>Welcome to Example.com!</title>
  </head>
  <body>
    <h1>Success!  The example.com virtual host is working!</h1>
  </body>
</html>

// copy the sample apache conf file to configure each website
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/site1.com.conf

// open the file and edit the contents
sudo nano /etc/apache2/sites-available/site1.com.conf

<VirtualHost *:80>
    ServerAdmin admin@example.com
    ServerName site1.com
    ServerAlias www.site1.com
    DocumentRoot /var/www/site1.com/public_html
    
    <Directory /var/www/site1.com/public_html>
      Options Indexes FollowSymLinks MultiViews
      AllowOverride All
      Order allow,deny
      allow from all
      </Directory>
    
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

// enable the configuration files
sudo a2ensite site1.com.conf

// restart apache
sudo service apache2 restart