Skip to content

Instantly share code, notes, and snippets.

@japodhidev
Created April 5, 2018 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save japodhidev/a5803a88d5f820aafb099e9987c5f168 to your computer and use it in GitHub Desktop.
Save japodhidev/a5803a88d5f820aafb099e9987c5f168 to your computer and use it in GitHub Desktop.
Apache24 sample VirtualHost configuration
# Assumptions made include
# 1. Incase you are doing this in a Windows OS development environment, directory
# names should be in quotes because spaces will cause lots of errors.
# 2. You have your Apache server set to execute PHP source files.
# 3. The document root has a file named index.php.
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
# Should point to the projects public directory
DocumentRoot "var/www/project_dir/public"
<Directory "var/www/project-dir/public">
Require all granted
DirectoryIndex index.php
# This is optional in case you don't like using .htaccess files
<IfModule mod_rewrite.c>
Options -Multiviews
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>
</Directory>
ErrorLog var/www/project_dir/logs/project_errors.log
CustomLog var/www/project_dir/logs/project_access.log
# Optional (I just like reading debug and/or error messages)
LogLevel warn
</VirtualHost>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment