👈 back home

Install Apache, MySQL, PHP, phpMyAdmin on OSX 10.10 Yosemite

Written by andy onJanuary 21, 2015

1. Check installed apache on your mac

sudo apachectl start

then go to browser and open http://localhost/
It, should be showing “It works!” text.
Try to stop, restart, and check version using this command:

sudo apachectl stop


sudo apachectl restart

Check version

httpd -v

2. Document Root

It is easier to use the user level one as you don’t have to keep on authenticating as an admin user.

The other web root directory which is missing by default is the ~/Sites folder in the User account.

Create a Folder Sites

Create “username.conf” file

change username with your account shortname. If you don’t know your shortname, type whoami and terminal.

$ cd /etc/apache2/users
$ sudo nano username.conf

and on that file paste this content.

AllowOverride All
Options Indexes MultiViews FollowSymLinks
Require all granted

check permission and should be:

-rw-r--r--   1 root  wheel  298 Jun 28 16:47 username.conf

if not, you need to change to 644

$ sudo chmod 644 username.con

Open file httpd.conf and allow some modules

$ sudo nano /etc/apache2/httpd.conf

and make sure this line is uncommented

LoadModule authz_core_module libexec/apache2/mod_authz_core.so
LoadModule authz_host_module libexec/apache2/mod_authz_host.so
LoadModule userdir_module libexec/apache2/mod_userdir.so
Include /private/etc/apache2/extra/httpd-userdir.conf

*Open another Apache config and uncomment User * *

$ sudo nano /etc/apache2/extra/httpd-userdir.conf


Include /private/etc/apache2/users/*.conf

Restart Apache

$ sudo apachectl restart

User-level document root will be vieable at:

3. Override .httaccess and Allow Rewrites

sudo nano /etc/apache2/httpd.conf

Change AllowOverride None to AllowOverride All

Allow Rewrites

Go back to file httpd.conf

$ sudo nano /etc/apache2/httpd.conf

and uncomment:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

4. PHP

$ sudo nano /etc/apache2/httpd.conf

use control+w and type libphp uncomment this line by remove # prefix

LoadModule php5_module libexec/apache2/libphp5.so

Restart Apache

$ sudo apachectl restart

To test PHP, create a file name it info.php, and save to your user-level document root ~/Sites/info.php

<?php phpinfo(); ?>

5. MySQL

Download MySQL from their official website at: MySQL Community Server

Download Mac OS X 10.9 (x86, 64-bit), DMG Archive

You don’t need to Sign Up or Login yet. find link No thanks, just take me to the downloads and the software will start downloaded

Once downloaded, open the .dmg file and run the installer.

Starting MySQL from System Preferences

Starting MySQL from Terminal

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

Set the MySQL root password

$ /usr/local/mysql/bin/mysqladmin -u root password 'yourpassword'

change yourpassword to be your password.

AutoStarting MySQL on Reboot

$ sudo nano /Library/LaunchDaemons/com.mysql.mysql.plist

and paste:
<!--?xml version="1.0" encoding="UTF-8"?-->
<plist version="1.0">
<true />

save and then:

$ sudo chown root:wheel /Library/LaunchDaemons/com.mysql.mysql.plist

$ sudo chmod 644 /Library/LaunchDaemons/com.mysql.mysql.plist

$ sudo launchctl load -w /Library/LaunchDaemons/com.mysql.mysql.plist

it will load on restart

6. phpMyAdmin

Download phpMyAdmin on its official website here

Extract .zip file and rename the folder to phpmyadmin

Make a config folder

$ mkdir ~/Sites/phpmyadmin/config

and change permission :

chmod o+w ~/Sites/phpmyadmin/config


$ sudo chmod -R a+w ~/Sites/folder_name
$ sudo chown -R _www ~/Sites/folder_name

Thanks to: coolestguideontheplanet.com