用port安装nginx
到http://www.macports.org/install.php下载macports
安装nginx:运行sudo port install nginx spawn-fcgi
安装php:运行sudo port install php53 fcgi php53-cgi php53-mysql php53-curl php53-iconv php53-mcrypt
安装imagick: 运行sudo port install php53-imagick
nginx配置
进入/opt/local/etc/nginx
创建sites-avalaible和sites-enabled文件夹
参考附件的配置文件,编辑nginx.conf, fastcgi.conf, mime.types
参考附件的配置文件在sites-available中创建www, game, bbs三个配置文件分别指向3个git代码库的根目录或webroot目录
php 配置
error_reporting = E_ALL & ~E_NOTICE
display_errors = On
date.timezone = Asia/Shanghai
short_open_tag = On
开启自启动配置
- 将以下代码保存至/Library/LaunchDaemons/org.macports.nginx.plist
<?xml version='1.0' encoding='UTF-8'?> <!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd" > <plist version='1.0'> <dict> <key>Label</key><string>org.macports.nginx</string> <key>ProgramArguments</key> <array> <string>/opt/local/bin/daemondo</string> <string>--label=nginx</string> <string>--start-cmd</string> <string>/opt/local/sbin/nginx</string> <string>;</string> <string>--pid=fileauto</string> <string>--pidfile</string> <string>/opt/local/var/run/nginx/nginx.pid</string> </array> <key>Debug</key><false/> <key>Disabled</key><true/> <key>KeepAlive</key><true/> </dict> </plist>
- 将以下代码保存至/Library/LaunchDaemons/org.macports.phpfcgi.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>Label</key><string>org.macports.phpfcgi</string> <key>Debug</key><false /> <key>OnDemand</key><false /> <key>RunAtLoad</key><false /> <key>EnvironmentVariables</key> <dict> <key>PHP_FCGI_CHILDREN</key><string>2</string> <key>PHP_FCGI_MAX_REQUESTS</key><string>5000</string> </dict> <key>LaunchOnlyOnce</key><true /> <key>ProgramArguments</key> <array> <string>/opt/local/bin/spawn-fcgi</string> <string>-C 2</string> <string>-p 9000</string> <string>-f /opt/local/bin/php-cgi53</string> </array> </dict> </plist>
- 运行sudo launchctl load -w /Library/LaunchDaemons/org.macports.nginx.plist
- 运行sudo launchctl load -w /Library/LaunchDaemons/org.macports.phpfcgi.plist
- 运行sudo lsof -i:80和sudo lsof -i:9000检查nginx和fastcgi是否分别正常监听80和9000端口