You should have some tools installed like Homebrew, a text editor such as Sublime Text and it's subl command line app inside a bin
folder and some basic terminal knowledge.
This gist is a more detailed version of niepi's gist with things that worked for me. It may help someone :)
$ brew install php --with-apache --with-mysql --with-pgsql --with-intl
$ sudo cp /private/etc/php.ini.default /private/etc/php.ini
$ subl /private/etc/php.ini
Add date.timezone = America/Montreal
See supported PHP time zones for your own timezone
$ subl /private/etc/apache2/httpd.conf
Add LoadModule php7_module libexec/apache2/libphp7.so
in your httpd.conf
file
$ chmod -R ug+w /usr/local/Cellar/php/7.2.10/lib/php
$ pear config-set php_ini /private/etc/php.ini
$ sudo apachectl start
or
$ sudo apachectl restart
Now visit localhost and see if it works. You may need to specify your documentroot directory and other parameters to make it work properly. See Apache documentation
$ brew install mysql
$ brew services start mysql
$ unset TMPDIR
$ mysql_install_db --verbose --user=`whoami` --basedir="$(brew --prefix mysql)" --datadir=/usr/local/var/mysql --tmpdir=/tmp
Note the datadir /usr/local/var/mysql
, you'll need to make sure it's correctly set in your my.cnf
file.
Edit my.cnf with sublime (if it doesn't exist, just create it)
$sudo subl /private/etc/my.cnf
my.cnf
[mysqld]
datadir=/usr/local/var/mysql
socket=/var/lib/mysql/mysql.sock
[mysql.server]
user=mysql
basedir=/usr/local/Cellar/mysql/5.6.10
[client]
socket=/var/lib/mysql/mysql.sock
$ mkdir -p ~/Library/LaunchAgents
$ sudo cp /usr/local/Cellar/mysql/5.6.10/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
ln
won't work if you try to launchctl load
on a symbolic link. You may use hardlink for osx instead of copying the mysql.plist file.
$ sudo hardlink /usr/local/Cellar/mysql/5.6.10/homebrew.mxcl.mysql.plist ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Note: At this point, mysql should already be started by launchctl after launchctl load
.
You can also verify other launchtl loaded agents by going into ~/Library/LaunchAgents
and/or /Library/LaunchAgents
folder and by listing files
$ cd ~/Library/LaunchAgents
$ ls -la
$ mysql.server start
Make sure you don't start mysql deamon before running mysql_install_db
1st time
$ mysqladmin -u root password newpassword
If a password already exists
$ mysqladmin -u root -p'oldpassword' password newpassword
Test if your password works
$ mysql -u root -p'yourpassword' -e 'show databases;'
Edit php.ini file and locate
pdo_mysql.default_socket=/var/mysql/mysql.sock
mysqli.default_socket=/var/mysql/mysql.sock
mysql.default_socket=/var/mysql/mysql.sock
and replace their path with the socket directory we used /var/lib/mysql/mysql.sock
.
Note: You can find the mysql.sock
file used by your server by looking at the mysql configuration variables (see bellow) or you can define your own in the my.cnf
file.
Usefull if you want to know your datadir
or pid file location
, etc.
$ mysql -u root -p
SHOW VARIABLES;
If you don't have autoconf (Xcode 4.3) install autoconf
$ brew install autoconf
Install xdebug & apc
$ pecl install xdebug apc
Open php.ini
file and set this
[xdebug]
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
xdebug.remote_enable = On
xdebug.remote_autostart = 1
You should now see xDebug enabled using phpinfo(), make sure you use zend_extension
and not extension
or you will get a “XDEBUG NOT LOADED AS ZEND EXTENSION” warning and it will not work as expected with breakpoints. ;)
$ brew install postgresql
$ initdb /usr/local/var/postgres
$ cp /usr/local/Cellar/postgresql/9.2.4/org.postgresql.postgres.plist ~/Library/LaunchAgents
or
$ sudo hardlink /usr/local/Cellar/postgresql/9.2.4/homebrew.mxcl.postgresql.plist ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
then
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
$ pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
$ pear config-set auto_discover 1
$ pear install pear.phpqatools.org/phpqatools pear.netpirates.net/phpDox
This will install:
- PHP_Depend
- PHP_CodeSniffer
- File_Iterator Text_Template
- PHP_Timer
- YAML
- Console_CommandLine
- Log
- PHP_TokenStream
- Base
- PHP_PMD
- PHP_CodeBrowser
- PHP_CodeCoverage
- PHPUnit_MockObject
- ConsoleTools
- PHPUnit
- phpcpd
- phploc
- phpqatools
$ pear channel-discover pear.phing.info
$ pear config-set preferred_state beta
$ pear install phing/phing
$ pear config-set preferred_state stable