access apache2 virtualhost code example
Example: apache virtual host
# File: /etc/apache2/sites-available/domain1.com.conf
<VirtualHost *:80>
# Server Name (domain name) and any aliases
ServerName domain1.com
ServerAlias www.domain1.com
#OPTIONAL Admin name
ServerAdmin [email protected]
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot /home/demo/public_html/domain1.com/public
# Custom log file locations
LogLevel warn
ErrorLog /var/log/apache2/error-mydomainname.com.log
CustomLog /var/log/apache2/access-mydomainname.com.log combined
</VirtualHost>
# Enabling:
# sh ~ $
sudo a2ensite domain1.com # Refer to above ServerName!
# The utility may automatically suggest, but run:
sudo /etc/init.d/apache2 reload
# To restart apache!