I just installed a fresh installation of Sierra on my Hackintosh and couldn’t for the life of me get XAMPP to run properly! I got “Access Forbidden” on my localhost and vhosts.I figured I’d write a few notes for people that run into this issue running XAMPP on your Mac. Please comment below if you don’t agree with or see a flaw in my notes and I can test and update your feedback. This guide assumes you already know basics behind XAMPP/WAMP stacks and are stuck getting it running on OSX.
Are they rebranding OSX to macOS? I digress…
Setting Up httpd.conf & httpd-vhosts.conf
1.) Open up XAMPP and click the tab Manage Servers. Highlight Apache and click Configure. Click Open Conf File. This will open your httpd.conf file.
2.) In httpd.conf find the follow line of code and change it daemon to your OS X username.
3.) In httpd.conf find the following line and uncomment it (by removing the #)
Save the file, don’t close TextEditor
4.) In TextEditor, goto File -> Open. You should start out in xamppfiles/etc. Click into the extra directory and then open httpd-vhosts.conf
5.) Remove the example code -or- comment all of it out.
6.) Use the following code to base your vhosts on, keep in mind I kept the default localhost example just to access the default htdocs location. https://gist.github.com/wykydtronik/8c9e3b701ac138b19a7d012a34d34c6c
7.) Restart Apache services in XAMPP’s Manage Servers tab.
Solving Access Forbidden in XAMPP
This part is the one thing many would disagree with and I’m not 100% a way around this in macOS Sierra. Previously I’ve simply chmod 644 -R my working folders but I couldn’t for the life of me get around the forbidden error. If you know a better way around this please comment below.
1.) Open Terminal (Applications/Utilities/Terminal)
2.) cd to your directory and give execute read write permissions, example below
$ sudo chmod -R +xrw wordpress/
If you’re new to this, the $ is just signifying the command line beginning and we’re not su. This should set execute/read/write permissions reclusively to all files and folders within our working directory. I haven’t tried it but you can also try chown but these directories are already owned by my user…
Setting Up Hosts File in OSX Sierra
If you’re not familiar with vhosts on a local XAMPP stack, the hosts file allows you to overwrite local DNS routing on your machine. In our scenario, we will one for our local wordpress environment.
1.) In terminal, simply use this command to open up the hosts file:
$ sudo nano /private/etc/hosts
2.) At the bottom of the file add this to your hosts file:
This will now route traffic from http://wordpress.dev to your localhost. If your httpd.conf and httpd-vhosts.conf files are setup correctly, you can now access your local WordPress developer environment. Try to refresh http://localhost -or- for example http://wordpress.dev
Are you having troubles with this article? Please feel free to leave a comment below or Tweet me at @eddihughes – I can go through the article and update any steps that may have changed.