Apache MySQL PHP
El Capitan (10.11) and others:
https://mallinson.ca/osx-web-development/
http://ericlbarnes.com/2015/08/04/set-mac-local-php-development/
Yosemite (10.10)
http://coolestguidesontheplanet.com/get-apache-mysql-php-phpmyadmin-working-osx-10-10-yosemite/
http://coolestguidesontheplanet.com/install-mcrypt-php-mac-osx-10-10-yosemite-development-server/
Mavericks (10.9)
http://akrabat.com/computing/setting-up-php-mysql-on-os-x-mavericks/
With OS X 10.9 Mavericks, Apple chose to ship PHP 5.4.17. This is how to set it up from a clean install of Mavericks.
- PHP 5.3/5.4/5.5 for OS X 10.6/10.7/10.8/10.9 as binary package by Liip
- Zend Server (Free Edition)
- Homebrew has PHP.
Let’s go!
/usr/local
Ensure that the following directories exist and have the right permissions:
sudo mkdir /usr/local/include
sudo mkdir /usr/local/bin
sudo mkdir /usr/local/lib
sudo mkdir -p /usr/local/man/man1
sudo chgrp -R staff /usr/local
cd /usr/local
find . -type d -exec chmod g+rws {} \;
MySQL
- Download the “x86, 64bit” DMG version of MySQL 5.6.x for OS X 10.7 from mysql.com and install the pkg, the startup item and the pref pane.
- Open the pref pane and start the MySQL Server.
- Update the path by editing ~/.bash_profile and add:
export PATH=~/bin:/usr/local/bin:/usr/local/mysql/bin:$PATH
at top of file.
Set up MySQL root password:
mysqladmin -u root password {new-password}
mysqladmin -u root -p{new-password} -h localhost password {new-password}
mysqladmin -u root -p{new-password} reload
Clear the history file by typing history -c so that {new-password} isn’t in plain text on the disk.
Now ensure that the mysql.sock file can be found by PHP:
- Ensure that MySQL is running
- sudo mkdir /var/mysql
- sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
Snow Leopard
http://maestric.com/doc/mac/apache_php_mysql_snow_leopard
Apache
Start Apache
sudo apachectl start
Check it's working: http://localhost/
PHP
In /etc/apache2/httpd.conf, uncomment this line:
LoadModule php5_module libexec/apache2/libphp5.so
Restart Apache
sudo apachectl restart
Fix a warning appearing in phpinfo()
Create /etc/php.ini and make it writable
cd /etc sudo cp php.ini.default php.ini sudo chmod 666 php.ini
In php.ini, find this line:
;date.timezone =
Uncomment it and insert your time zone (http://php.net/manual/en/timezones.php)
date.timezone = America/Indiana/Indianapolis
Restart Apache
sudo apachectl restart
MySQL
- Download the MySQL package for Mac OS X.5 (32 or 64 bits depending on your machine)
- Install everything in the package in this order: mysql, the startup item, the preference pane.
- Start MySQL in the preference pane.
- Test it's working:
/usr/local/mysql/bin/mysql
Fix mysql.sock location in php.ini
- In
/etc/php.ini, replace the three occurences of/var/mysql/mysql.sockby/tmp/mysql.sock
pdo_mysql.default_socket=/tmp/mysql.sock mysql.default_socket = /tmp/mysql.sock mysqli.default_socket = /tmp/mysql.sock
Restart Apache
sudo apachectl restart
Extra
Activate PHP short tags
In /etc/php.ini, under Language Options, change
short_open_tag = Off
to
short_open_tag = On
Restart Apache
sudo apachectl restart
Reference
http://wordpress.org/support/topic/306878
http://stackoverflow.com/questions/1293484/easiest-way-to-activate-php-and-mysql-on-mac-os-10-6-snow-leopard
http://superfancy.net/php-mysql-apache-in-mac-osx-leopard/