Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save geekykant/0d5bd1c3d80f1c93ce405037b4ec3659 to your computer and use it in GitHub Desktop.
Save geekykant/0d5bd1c3d80f1c93ce405037b4ec3659 to your computer and use it in GitHub Desktop.
Sample virtual host .conf file for Apache2 on Ubuntu
# This to be used when you need to implement SSL
# Make sure that apache mod_ssl is on
# You can generate self signed certificates for development
# http://www.selfsignedcertificate.com/
<VirtualHost *:443>
ServerName yourapp.test
#ServerAlias www.yourapp.test
ServerAdmin webmaster@localhost
DocumentRoot /home/user_name/projects/project-folder
<Directory "/home/user_name/projects/project-folder">
Order allow,deny
AllowOverride All
Allow from all
Require all granted
</Directory>
#ErrorLog ${APACHE_LOG_DIR}/error.log
#CustomLog ${APACHE_LOG_DIR}/access.log combined
# Enable SSL
SSLEngine on
SSLCertificateFile /path/to/www_yoursite_com.crt
SSLCertificateKeyFile /path/to/www_yoursite_com.key
</VirtualHost>
# This is the minimal configuration file to create a virtual host
# Path /etc/apache2/sites-available/
# Ubuntu 14.04/16.04/18.04, apache 2.4
# Commands to remember-
# sudo a2ensite example-virtual-host.test.conf
# sudo service apache2 restart
<VirtualHost *:80>
ServerName yourapp.test
#ServerAlias www.yourapp.test
ServerAdmin webmaster@localhost
DocumentRoot /home/user_name/projects/project-folder
<Directory "/home/user_name/projects/project-folder">
Order allow,deny
AllowOverride All
Allow from all
Require all granted
</Directory>
#ErrorLog ${APACHE_LOG_DIR}/error.log
#CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
# Dont forget to make an entry in /etc/hosts
# 127.0.0.1 yourapp.test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment