Need to get working your own local web server in your Mac? If you have Maverics or Yosemite, you can follow this guide!

There are a lot of ways to have a web server working on your Mac, for example:

Create your own Virtual Machine (installing VirtualBox or VMWare) Using Vagrant + Puppet Installing MAMP Using PuPHPet And finally, using the built in Apache and PHP in OSX (you can follow this guide :))


  1. Open terminal app on your Mac. Just go in Application/Others and open the Terminal

  2. Running Apache To run the web server just type in terminal this command:

sudo apachectl start`

And here is how you can stop and restart it:

sudo apachectl stop
sudo apachectl restart
  1. Check Apache is running Open your favorite browser and go to http://localhost. You should see a blank page with just one text: “It works!”

Now, the default Document Root is this path : /Library/WebServer/Documents/.

You can change it editing httpd.conf at this path : /etc/apache2/httpd.conf or just adding a new Virtual Host configuration.

To add a new VH, you must edit this file: /etc/apache2/extra/httpd-vhosts.conf

You can add something like this:

<VirtualHost *:80>
    DocumentRoot "/Users/YourUser/Code/"
    ErrorLog "/Users/YourUser/Code/"
    CustomLog "/Users/YourUser/Code/" common
    <Directory "/Users/YourUser/Code/">
		AllowOverride All

You have added to Apache configurations. Normally, if you go to in your browser, you would be redirected to the real website, but if you modify your /etc/hosts file, by adding this line: your browsers will search for website, at this IP: that is the equivalent to localhost.

Now restart your Apache, as shown above, and go to, you should see the content within this path /Users/YourUser/Code/


As Apache, PHP is already installed in your OSX. The version, for Yosemite, should be 5.5.14.

How can we activate it?

Just modify /etc/apache2/httpd.conf, find this line LoadModule php5_module libexec/apache2/ and remove the “#”.

Save the file and restart Apache.

Now your web server should support php files!

But let’s test it: create a test.php file in /Users/YourUser/Code/ and inside write this lines:

<?php phpinfo() ?>

Go to, you should see PHP configurations.


MySQL is the one not included in the operative system, so download it here.

The version should be this Mac OS X 10.9 (x86, 64-bit), DMG Archive (don’t worry for the 10.9, it’s compatible with Yosemite too).

Once installed, you can start the MySQL server in two ways:

System preferences Command Line (terminal) If you want to start the database server from terminal, just open it and type:

sudo /usr/local/mysql/support-files/mysql.server start

The last step is to set the root password for MySQL Server.

Open terminal and type (replace yourpwd for the password you have choosen):

/usr/local/mysql/bin/mysqladmin -u root password 'yourpwd'

That’s all! Now you should have an AMP, that means Apache MySQL PHP, environment working correctly!

Hope this guide is useful :)