Skip to content

Instantly share code, notes, and snippets.

@me-shaon
Last active October 30, 2016 10:02
Show Gist options
  • Save me-shaon/1e7f3b5d42dee7e3675f1a0ad83cc1a5 to your computer and use it in GitHub Desktop.
Save me-shaon/1e7f3b5d42dee7e3675f1a0ad83cc1a5 to your computer and use it in GitHub Desktop.
Create Virtual Host in Apache Server (Ubuntu)
# Go to /etc/apache2/sites-available/
# Create a file with the name of the virtual host consisting the '.conf' extension. Like myproject.com.conf
# Put the following code on that file
<VirtualHost *:80>
ServerName myproject.com
ServerAlias www.myproject.com
DocumentRoot /var/www/html/file_path_of_the_project
<Directory /var/www/html/file_path_of_the_project>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/myproject-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/myproject-access.log combined
</VirtualHost>
#Run the following command to enable the virtual host
sudo a2ensite myproject.com.conf
sudo service apache2 reload
# Update the /etc/hosts file with something similar to following
127.0.1.5 myproject.com
# So that the request to the myproject.com can be resolved by the host file to our own local server
# And that's it.
@me-shaon
Copy link
Author

A details article about it can be found here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment