Using Nginx and PHP connection problems under Mac OS X

Source: Internet
Author: User
Installing Nginx

Use the Brew Package management tool to install Nginx

http://brew.sh/

Official online at a glance, the use is very simple.

After successful installation, execute the brew install Nginx directly in the terminal.

After installation, under/usr/local/cellar/can see the installation of Nginx package, Cellar directory is dedicated to put the brew installed package, all the relevant configuration files under/usr/local/etc/nginx/.

Configure Nginx

The initial nginx listen is the 8080 port, according to the Convention changed to 80 port, pay attention to bring your own Apache off.

At this time to execute the nginx command, the browser localhost can see the welcome, but still cannot execute PHP files, because there is no configuration with PHP connection, here will use PHP-FPM, First to add fastcgi configuration in Nginx configuration file:

Location ~ \.php$ {            fastcgi_pass   127.0.0.1:9000;            Fastcgi_index  index.php;            Fastcgi_param  script_filename  /usr/local/cellar/nginx/1.8.0/html$fastcgi_script_name;            Include        fastcgi_params;        }
The corresponding modifications can be made by reference to the above configuration.

Configure PHP-FPM

Then modify the configuration of the Error_log and PID in the PHP-FPM configuration file:

Go to config file, sudo vim/private/etc/php-fpm.conf

Error_log =/usr/local/var/log/php-fpm.logpid =/usr/local/var/run/php-fpm.pid
Refer to the corresponding modifications.

Open PHP-FPM:

sudo/usr/sbin/php-fpm

Re-start Nginx

Nginx-s Reload

Test the PHP file in the server root directory.


Nginx and Apache The most intuitive difference is that Apache can be PHP as a sub-module, thus directly parsing PHP, and nginx can not do, only through the fastcgi mode with PHP connection, of course, Apache can also use fastcgi mode. The PHP-FPM (Process Manager) is the tool that manages fastcgi, and after the PHP5.3 version, PHP comes with it.

FastCGI and PHP-FPM related knowledge Reference:

What is fastcgi and php-fpm in PHP?

The above describes the Mac OS X using Nginx and PHP connection issues, including the aspects of the content, I hope that the PHP tutorial interested in a friend helpful.

  • Large-Scale Price Reduction
    • 59% Max. and 23% Avg.
    • Price Reduction for Core Products
    • Price Reduction in Multiple Regions
    undefined. /
    Connect with us on Discord
    • Secure, anonymous group chat without disturbance
    • Stay updated on campaigns, new products, and more
    • Support for all your questions
    undefined. /
    Free Tier
    • Start free from ECS to Big Data
    • Get Started in 3 Simple Steps
    • Try ECS t5 1C1G
    undefined. /

    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.