brew install mysql
mysql_secure_installation
brew services start mysql
brew tap homebrew/dupes
brew tap homebrew/php
brew install --without-apache --with-fpm --with-mysql php70
add this to shell profile (for zsh)
echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.zshrc && . ~/.zshrc
start php70 services
brew services start php70
check php version. it should be using php7.0 and using local php
which php
/usr/local/bin/php
php -v
PHP 7.0
check if php-fpm is already running
lsof -Pni4 | grep LISTEN | grep php
php-fpm 1908 wahyudibo 6u IPv4 0x23a0912e4e76185f 0t0 TCP 127.0.0.1:9000 (LISTEN)
php-fpm 1938 wahyudibo 0u IPv4 0x23a0912e4e76185f 0t0 TCP 127.0.0.1:9000 (LISTEN)
php-fpm 1939 wahyudibo 0u IPv4 0x23a0912e4e76185f 0t0 TCP 127.0.0.1:9000 (LISTEN)
brew install nginx
brew services start nginx
change nginx.conf to the one attached in here. We will use port 80 and setup multiple servers. Then
sudo nginx
setup servers file just like the default.conf that attached in here. it will work for php-fpm. Then, except for
localhost, you must register your servername to hosts file located in /private/etc/hosts
127.0.0.1 server.name
copy index.html from nginx default dir to your dir. then change file ownership
sudo cp /usr/local/var/www/index.html your-custom-folder
cd your-custom-folder
sudo chown wahyudibo:staff index.html
to reload or quit nginx
sudo nginx -s reload (do this after change conf file)
sudo nginx -s quit (to stop nginx)
to start nginx automatically (do this if brew services is not start nginx automatically)
sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
- to know about nginx configuration, use
nginx -V
- if in error log nginx show 403 forbidden, set user in nginx.conf to match user in root folder. in this case : wahyudibo staff
- test with php file contains
<?php phpinfo(); ?> and load file via browser
Shouldn't you exchange the order of
mysql_secure_installation
andbrew services start mysql
?Maybe it's only my case, but mysql_secure_installation didn't work before mysql was started