Mac under Nginx environment configuration

Source: Internet
Author: User
Tags fpm nginx server

Environmental information:

Mac OS X 10.11.1

Homebrew 0.9.5

Body

First, install Nginx
    1. Terminal execution:
Brew Search Nginxbrew Install Nginx

Current version 1.6.2

After installation, you can see some configuration paths in the terminal output information:

/usr/local/etc/nginx/nginx.conf (Profile path)/usr/local/var/www (server default path)/usr/local/cellar/nginx/1.6.2  (seemingly an installation path)
Ii. Visit localhost:8080

Nginx default port 8080, you can already access:

localhost:8080

There will be a default welcome interface.

Third, modify the php-fpm file

1. Execute the command:

sudo cp/private/etc/php-fpm.conf.default/private/etc/php-fpm.conf

2. Locate the php-fpm file in the directory

/private/etc/php-fpm.conf

3. Find 32 lines of error_log, instead (positive line substitution, note '; ' and spaces):

Error_log =/usr/local/var/log/php-fpm.log

Otherwise PHP-FPM will be error:

error:failed to open Error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
Iv. Modification of Nginx configuration
    1. Open Nginx.config File
/usr/local/etc/nginx/nginx.conf

2. Locate the server location configuration and add a index.php to index

Location/{    root   html;    Index  index.html index.htm index.php;}

3. And open the annotated location ~.php$ under Server (that is, ' # ' in front of the delete code), as follows:

Location ~ \.php$ {    root           html;    Fastcgi_pass   127.0.0.1:9000;    Fastcgi_index  index.php;    Fastcgi_param  script_filename  /scripts$fastcgi_script_name;    Include        Fastcgi_params;}

4. And modify the Fastcgi_param parameters

Fastcgi_param  script_filename  /scripts$fastcgi_script_name; instead Fastcgi_param  script_filename  $document _root$fastcgi_script_name;
V. Creation of index.php

In the/usr/local/var/www directory, delete index.html, create index.php, enter

<?php phpinfo ();?>
Vi. launch of related services
sudo nginxsudo php-fpm

Then access the localhost:8080, see the PHP configuration information, the explanation is OK

Vii. Other Orders

After modifying nginx.conf, reload the configuration file

sudo nginx-s reload

Stop Nginx Server

sudo nginx-s stop

Stop PHP-FPM can be stopped directly in Activity Monitor. You can also use scripts to stop.

Viii. problems that may arise

1. Visit index.php 403 Forbidden. View (four. 2) in the step, whether to add index.php after index.

2. Visit index.php File not found. See (four. 4), Fastcgi_param parameter is modified.

Mac under Nginx environment configuration

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.