Install nginx+php-cgi on Snow Leopard

Source: Internet
Author: User
Tags phpinfo
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.

  • Related Article

    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.