Mac

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/how-to-install-mcrypt-for-php-on-mac-osx-lion-10-7-development-server/

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.

Note: If you don’t want to use the built-in PHP or want to use version 5.5, then these are some alternatives:

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

  1. 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.
  2. Open the pref pane and start the MySQL Server.
  3. 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:

  1. Ensure that MySQL is running
  2. sudo mkdir /var/mysql
  3. 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.sock by /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/

PmWiki

pmwiki.org

Blix theme adapted by David Gilbert, powered by PmWiki