Skip to content

Instantly share code, notes, and snippets.

@sumardi
Forked from romanr/mpnml
Created November 21, 2012 10:32
Show Gist options
  • Save sumardi/4124180 to your computer and use it in GitHub Desktop.
Save sumardi/4124180 to your computer and use it in GitHub Desktop.
Mysql, Php-fpm, Nginx on OSX Mountain Lion
sudo port -v install mysql5-server
sudo -u _mysql mysql_install_db5
# if above command produce this error: ERROR: 1004 Can't create file '/var/tmp/#sqle967_1_0.frm' (errno: 9)
# do this:
# sudo chown -R mysql:mysql /opt/local/var/db/mysql5
# sudo chmod u+rwx,go= /opt/local/var/db/mysql5
# sudo /opt/local/lib/mysql5/bin/mysql_install_db --user=mysql
sudo port -v install php53-fpm +debug +suhosin
sudo cp /opt/local/etc/php53/php.ini-development /opt/local/etc/php53/php.ini
sudo nano /opt/local/etc/php53/php-fpm.conf
--------------------------------------------
[global]
pid = /var/run/php-fpm.pid
error_log = /var/log/php-fpm.log
[www]
listen = /tmp/php-fpm.sock
#listen = 127.0.0.1:9000
listen.owner = _www
listen.group = _www
user = _www
group = _www
pm = dynamic
pm.max_children = 1
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1
pm.max_requests = 500
slowlog = /var/log/php-fpm.log.slow
sudo port -v install nginx +ssl
sudo cp /opt/local/etc/nginx/mime.types.example /opt/local/etc/nginx/mime.types
sudo cp /opt/local/etc/nginx/fastcgi_params.example /opt/local/etc/nginx/fastcgi_params
sudo nano /opt/local/etc/nginx.conf
worker_processes 1;
error_log /var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
root /Users/holms/Sites/sitenl/web;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
#server_name ~^local\.(?.+?)\.com$;
#root /Users/holms/Sites/$site/web;
server_name local.site.nl;
index index.php index.html;
location = /favicon.ico {
log_not_found off;
}
location ~ \.php$ {
fastcgi_pass unix:/tmp/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
}
mkdir -p ~/Sites/site/web
sudo mkdir -p /var/log/nginx/
cat > ~/Sites/site/web/index.php
<?php phpinfo(); ?>
ctrl+d
# put "127.0.0.1 local.site.nl" to /etc/hosts
cat > ~/.profile
# nginx
alias nginx_start='sudo launchctl load -w /Library/LaunchDaemons/org.macports.nginx.plist'
alias nginx_stop='sudo launchctl unload -w /Library/LaunchDaemons/org.macports.nginx.plist'
alias nginx_restart='nginx_stop; nginx_start;'
# php-fpm
alias fpm_start='sudo launchctl load -w /Library/LaunchDaemons/org.macports.php53-fpm.plist'
alias fpm_stop='sudo launchctl unload -w /Library/LaunchDaemons/org.macports.php53-fpm.plist'
alias fpm_restart='fpm_stop; fpm_start'
# mysql
alias sql_start="sudo /opt/local/share/mysql5/mysql/mysql.server start"
alias sql_stop="sudo /opt/local/share/mysql5/mysql/mysql.server stop"
alias sql_restart="sql_stop; sql_start"
ctrl+d
sudo nano /Library/LaunchDaemons/org.macports.php53-fpm.plist
# replace /opt/local/sbin/php-fpm53 to /opt/local/sbin/php-fpm53.dSYM
# https://trac.macports.org/ticket/35258
sql_start
sudo /opt/local/lib/mysql5/bin/mysql_secure_installation
fpm_start
nginx_start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment