Not touch PHP for a long time, slightly unfamiliar! But migrating the Web front-end to PHP is imperative!
Here is introduced in snow Leopard build nginx+php-cgi development environment!
With the MacPorts, everything is a lot easier!
Installing Nginx
sudo port install Nginx
If you and I just want to do the development environment, do not want to automatically start the Nginx every time the boot, execute the following command:
sudo launchctl unload-w/library/launchdaemons/org.macports.nginx.plist
Initialize Configuration Nginx
cd/opt/local/etc/nginx/
CP Fastcgi.conf.example fastcgi.conf
CP Fastcgi_params.example Fastcgi_params
CP Nginx.conf.example nginx.conf
Start
Sudo/opt/local/sbin/nginx
Shut down
Sudo/opt/local/sbin/nginx-s quit
Restart
Sudo/opt/local/sbin/nginx-s Reload
Installing php-cgi
sudo port install php5 +fastcgi fcgi
Initializing the configuration of PHP
Cd/opt/local/etc/php5
CP php.ini-development PHP.ini
Start php-cgi
Php-cgi-b 127.0.0.1:8888
debugging, starting a process is enough, if you want to close, ctrl-c can.
Adjust Nginx configuration
Location ~ \.php$ { root share/nginx/html; Fastcgi_pass 127.0.0.1:8888; Fastcgi_index index.php; Fastcgi_param script_filename /opt/local/share/nginx/html$fastcgi_script_name; Include fastcgi_params; }
Attention:
Address, port in Fastcgi_pass to be consistent with php-cgi
Fastcgi_param in the/opt/local/share/nginx/html, this path must be correct, otherwise will be reported 404 error, prompted "No input file specified."
Write a test file/opt/local/share/nginx/html/test.php
Restart php-cgi, Nginx, and then access http://localhost/test.php
If you can see the Phpinfo table, the simplest configuration of the nginx+php-cgi development environment is complete.