Step 1: Install and configure Apache.
Make sure you specify what port you want to listen on, for me I specified 8080
. This will be the case for this series of instructions.
Listen 8080
- Default is 80
Step 2: Edit your /etc/hosts
file to spoof your loopback address, 127.0.0.1
127.0.0.1 localhost
127.0.0.1 some.example # domain-name.domain-TLD
127.0.0.1 www.some.example # The same as the above line, but with www. prefixed
You should really add a handle for subdomains on your web server, Apache or Nginx (or whatever else you use. Something that routes www to non-www.
Step 3: Enable the Virtual Hosts import on Apache.
- Open your
httpd.conf
file located within Apache2's subdirectories. Usually within /conf
- Uncomment the line that resembles this:
Include conf/extra/httpd-vhosts.conf
- Also uncomment this module import:
LoadModule log_config_module modules/mod_log_config.so
Step 4: Configure your Virtual Hosts file
- Find your Virtual Hosts config,
httpd-vhosts.conf
, you can comment out the two example Virtual Hosts in the file. Usually within /conf/extra
- Copy your own Virtual Host into the file from this template:
<VirtualHost *:80> # Change the 80 to the number Apache2 "Listen"s on. In my case, 8080
ServerName SERVER-ADDRESS # E.g. mywebsite.local
ServerAlias WWW.SERVER-ADDRESS # E.g. www.mywebsite.local
DocumentRoot " SERVER-FILE-ROOT " # E.g. "Users/user-name/Sites"
<Directory /> # This should be a full path, though
Require all granted # Required for permission errors
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride none
</Directory>
</VirtualHost>
You're Done!
Once your Virtual Host has been edited to your liking you are done, just restart Apache and enjoy.
This guide already includes the fixes implemented, but in-case you still get permission errors:
- You MUST make sure that your
DocumentRoot
is not inside any documents your user explicitly owns. If it needs to be, give "Read Only"
access to "Everyone" on Mac for that particular folder, E.g. "Documents" or "Movies" etc....