Skip to content

Instantly share code, notes, and snippets.

@ankurk91
Last active March 13, 2024 03:53
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 10 You must be signed in to fork a gist
  • Save ankurk91/afee4bcd575261c5c549 to your computer and use it in GitHub Desktop.
Save ankurk91/afee4bcd575261c5c549 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 at path
# /etc/apache2/sites-available/
# 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