I highly advise that you make a backup of any system files before modifying them.
- From Finder, select Go -> Go To Folder -> /etc/apache2/users
- Look for a file named username.conf (where username is your username)
- If such a file does not exist, create it and open it, if it does exist, open it.
- Copy and paste the following into the username.conf file, replace username with your username.
<Directory "/Users/username/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
- Save and close that file. You will be prompted to enter your administrative password because you are modifying a system level file.
- Move up one directory so you are in /etc/apache2/
- Look for and open a file named httpd.conf
- Open a search prompt and enter the query: php
- You should then be looking at a line that reads as follows or similarly (may be slight variations based on the PHP version)
LoadModule php5_module libexec/apache2/libphp5.so
- Remove the # from the beginning of this line
- Save and close the file and provide your administrative credentials.
Open Terminal and enter and run the following command to restart Apache and you are all set.
sudo apachectl restart
- Similarly to above, open the httpd.conf file.
- Open a search and query: DocumentRoot
- You should then see a line that reads as follows
DocumentRoot "/Library/WebServer/Documents"
Modify this line to the directory path you would like to use as your root localhost directory. Be sure to type out the full directory path. For example I created new folders in my root user folder for 'Published Projects' and 'Projects' so I adjusted mine to read like so:
DocumentRoot "/Users/davidcondrey/Projects/
If for example I wanted the 'Target' folder in the 'Sites' folder that sits on my 'Desktop' it would look like this:
DocumentRoot "/Users/davidcondrey/Desktop/Sites/Target/
Restart Apache one more time with the terminal command:
sudo apachectl restart