Setup PHP environment in Mavericks using XAMPP
To setup a PHP environment in Mac OS X 10.9:
You can download the latest version here. Then install it.
Bare in mind that by default, MySQL root user has no password, but will set it later
Once completed, launch it
- Select Manage Servers tab
- Select MySQL Database
- Start it
Then close it.
⌘ + Space key, type in
terminal then hit Enter key.
Create a directory to keep all projects _(e.g. public_html)_
$ mkdir ~/public_html
Create a project to that directory
$ mkdir ~/public_html/project_a
Create a home page for it
$ touch ~/public_html/project_a/index.php
then add the following content
For testing purpose, just duplicate the project A
$ cp -r ~/public_html/project_a ~/public_html/project_b
Edit the file ~/public_html/project_b/index.php
Now we have 2 projects, so we use virtual host (setup different domains) to differentiate them
Navigate to XAMPP directory
$ cd /Applications/XAMPP/etc/
Edit the file named httpd.conf, search for
httpd-vhosts, you will see the line
uncomment the line, i.e.
Now will look like
Navigate to deeper directory
Then edit the file named httpd-vhosts.conf, and it already come with this content
Remove it and change to
Restart apache server
$ sudo /Applications/XAMPP/xamppfiles/xampp restart
Edit the /etc/hosts file
$ sudo vi /etc/hosts
Add the following content to bottom
# Virtual hosts
Open your browser (e.g. Safari), type in the URL local.foosite.com, then you will see
and then change the URL to local.barsite.com, then you will see
In your browser, type in the URL localhost/phpmyadmin, select a user
- Select Users tab
- Click on the link
Scroll to Change password section
Then type in the password you want (e.g. password).
Once completed, when you simply click on any link above, error appear.
To solve this, just have to edit the file located in /Applications/XAMPP/xamppfiles/phpmyadmin/config.inc.php
$ sudo vi /Applications/XAMPP/xamppfiles/phpmyadmin/config.inc.php
Add in the password you just set
Save it and exit.
In your browser, refresh the phpmyadmin page. It should work now.
Add the content to the files
$ sudo vi xampp
(By default, XAMPP will install in the path above, if yours is different, just modify it.)
$ sudo vi StartupParameters.plist
Change the ownership
$ cd .. # go back 1 level up (directory)