Skip to content

Instantly share code, notes, and snippets.

@bendo01
Created November 2, 2011 11:22
Show Gist options
  • Save bendo01/1333412 to your computer and use it in GitHub Desktop.
Save bendo01/1333412 to your computer and use it in GitHub Desktop.
MacPorts install nginx & php
# Download & install marports http://www.macports.org/install.php
$ sudo port selfupdate
$ sudo port install nginx
$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.nginx.plist
$ sudo port install php5 +fastcgi fcgi
$ sudo mkdir /opt/local/etc/LaunchDaemons/org.macports.php-fastcgi
$ cd /opt/local/etc/LaunchDaemons/org.macports.php-fastcgi
$ mate org.macports.php-fastcgi.plist # or vim org.macports.php-fastcgi.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Debug</key>
<false/>
<key>EnvironmentVariables</key>
<dict>
<key>PHP_FCGI_CHILDREN</key>
<string>2</string>
<key>PHP_FCGI_MAX_REQUESTS</key>
<string>1000</string>
</dict>
<key>Label</key>
<string>com.tudorstudio.phpfcgi</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/opt/local/bin/php-cgi</string>
<string>-b 127.0.0.1:9000</string>
<string>-q</string>
</array>
<key>RunAtLoad</key>
<false/>
</dict>
</plist>
$ chown root:admin /opt/local/etc/LaunchDaemons/*
$ sudo ln -s /opt/local/etc/LaunchDaemons/org.macports.php-fastcgi/org.macports.php-fastcgi.plist /Library/LaunchDaemons/org.macports.php-fastcgi.plist
$ sudo launchctl load -w /Library/LaunchDaemons/org.macports.php-fastcgi.plist
$ sudo /opt/local/bin/php-cgi -q -b 127.0.0.1:9000
$ mate /opt/local/etc/nginx/nginx.conf # or vim /opt/local/etc/nginx/nginx.conf
# Nginx Config
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /ChangeToTheWebApps/root;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /ChangeToTheWebApps/root;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /ChangeToTheWebApps/root;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
include /opt/local/etc/nginx/fastcgi.conf;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root share/nginx/html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443;
# server_name localhost;
# ssl on;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_timeout 5m;
# ssl_protocols SSLv2 SSLv3 TLSv1;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root share/nginx/html;
# index index.html index.htm;
# }
#}
}
$ sudo nginx -s reload
@emj365
Copy link

emj365 commented Apr 8, 2013

should no space between "-b" and the host (my system is osx 10.8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment