Install Nginx + PHP-CGI on SnowLeopard

Source: Internet
Author: User
Install Nginx + PHP-CGI on SnowLeopard for a long time don't touch PHP, a little unfamiliar! However, it is imperative to migrate the WEB front-end to PHP!

Here we introduce how to build Nginx + PHP-CGI development environment on Snow Leopard!

With MacPorts, everything is much simpler!

Install Nginx

Sudo port install nginx

If you just want to create a development environment and do not want to start Nginx automatically at startup, run the following command:

Sudo launchctl unload-w/Library/LaunchDaemons/org. macports. nginx. plist

Initialize Nginx configuration

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

Close

Sudo/opt/local/sbin/nginx-s quit

Restart

Sudo/opt/local/sbin/nginx-s reload

Install PHP-CGI

Sudo port install php5 + fastcgi fcgi

Initialize php configuration

Cd/opt/local/etc/php5

Cp php. ini-development php. ini

Start php-cgi

Php-cgi-B 127.0.0.1: 8888

For debugging, it is enough to start a process. to disable it, press ctrl-c.

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;        }

Note:

The address and port in fastcgi_pass must be consistent with that in php-cgi.

/Opt/local/share/nginx/html in fastcgi_param. this path must be correct. Otherwise, a 404 error will be reported, prompting "No input file specified .".

Compile a test file/opt/local/share/nginx/html/test. php

 

Restart php-cgi and nginx, and then access http: // localhost/test. php

If you can see the phpinfo table, the nginx + php-cgi development environment with the simplest configuration is complete.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.