These last few days I’ve been trying to get XAMPP to work on my MacBook Pro these last couple of days and it has been frustrating! It seemed I kept running into more and more problems. For those who don’t know, XAMPP is tool for developers to run a LAMP stack (Linux, Apache, MySQL, PHP) on your machine locally. I’ve been running it on my Windows machines for years, and I have been running my production servers on Linux.
Installing just XAMPP and getting it to run with the Control Panel was easy. All my headaches started when I tried to get my vhosts installed and working. The problem I ran into getting XAMPP to run on my MacBook Pro were the following:
My first mistake was that I assumed that XAMPP for Mac is the same as XAMPP for Windows. After digging into it, the file structure and config files are pretty different. The php.ini file is different, and all the binary files are in /xampp/xamppfiles/bin/. On windows the binary files are in their own folders. It took me awhile to figure out where everything was at. This led me into my next problem:
When I was trying to debug why stuff wasn’t working, I opened up the terminal and started running commands. There is just one problem, OS X already has a version of Apache installed. So when I cd’d into the bin directory, I would execute this command:
apachectrl -t -D DUMP_VHOSTS
There was just one problem, it was executing the apachectl that was installed by Mac OS X, not the one for XAMPP. So it all my debugging with the config files, etc. wasn’t working. I was going insane. Finally I figured out what was going on and I had to execute this command instead:
./apachectl -t -D DUMP_VHOSTS
It started behaving like I expected! This lead my to my third hang up.
This threw me for a loop to. I don’t understand exactly why this was happening, but I kept gettinga Permission Denied when trying to view the vhost I was trying to setup. The way I used to do it on Windows is I have a partition for all of my development files. I would have a folder at the root of that drive called SVN_Repositories that holds all the SVN Repositories I use for work. So on my MacBook Pro at / I did the same, I had my SVN_Repositories folder. So my vhost would point to a directory like with a name something like this: “/SVN_Repositories/ExampleRepo/trunk/httpdocs/“
So my linux side clicked in and thought “Hrm, it looks like there is something wrong with the permissions. Let me change the folder permissions to 777 just to test.” So I did that and it still didn’t work. This it made me think it still was a vhost configuration issue. So I spent hours testing all sorts of stuff and just getting more frustrating. Then I read somewhere that XAMPP can have problems with OS X’s unique permissions on addition to the FreeBSD stuff it does. It said to host the vhost content in either the Applications folder or Users folder. So I moved my SVN_Repositories folder to my Users folder so it was like this: “/Users/username/SVN_Repositories/ExampleRepo/trunk/httpdocs/“
It finally worked! So the lessons I learned were:
As always, hopefully this helps someone. Feel free to leave any questions or comments.