Mac Nginx php php-fpm

Source: Internet
Author: User
Tags root access

#the php-fpm config and cammand ...

Cp/private/etc/php-fpm.conf.default/usr/local/etc/php-fpm.conf

PHP-FPM--fpm-config/usr/local/etc/php-fpm.conf--prefix/usr/local/var

PS aux | grep ' PHP-FPM '

Killall-hup PHP-FPM

#the nginx config and cammand ...

Brew Services Restart Nginx

Fastcgi_param Script_filename/scripts$fastcgi_script_name;
=====>
Fastcgi_param script_filename $document _root$fastcgi_script_name;

It can be added to your location PHP to return 404 when the file does not exist, instead of handing it over to PHP-FPM.

Location ~ \.php$
{
...
#文件不存在转404
Try_files$uri = 404;
...
}

Then, in your configuration file, find the following paragraph

Fastcgi_param Script_filename/scripts$fastcgi_script_name;

Replace with below  fastcgi_param  script_filename   $document _root$fastcgi_script_name;   mac Start Php-fpm mac OS X 10.9 has been self-php-fpm, for the person with a clean system obsessive-compulsive disorder, or the original control, with Brewhome re-loaded with a total feel the heart will have a small rabbit, the following the original PHP-FPM configuration up.   Direct operation, there is an error can not find the configuration file. $ php-fpm[11-jan-2014 16:03:03] error:failed to open configuration file '/private/etc/php-fpm.conf ': No such file or dire Ctory (2) [11-jan-2014 16:03:03] error:failed to load configuration file '/private/etc/php-fpm.conf ' [11-jan-2014 16:03:03] ERROR:FPM initialization failed can generate a configuration file in the/private/etc/directory, requires root (sudo), or in a directory where ordinary users have permissions to place the configuration file, Specify the location of the configuration file via the--fpm-config parameter as follows: # cp/private/etc/php-fpm.conf.default/usr/local/etc/php-fpm.conf $ PHP-FPM-- fpm-config/usr/local/etc/php-fpm.conf[11-jan-2014 16:10:49] error:failed to open error_log (/usr/var/log/php-fpm.log ): No such file or directory (2) [11-jan-2014 16:10:49] error:failed to post process the configuration[11-jan-2014 16:10:4 9] ERROR:FPM initialization failed error message: The log file cannot be opened correctly because the default is in the/usr/var directoryUnder Work, you can modify the configuration file to specify the correct log file path  $ vim/usr/local/etc/php-fpm.conf Modify the Error_log entry in the php-fpm.conf file, the default prefix is/usr/var, But not this path error_log =/usr/local/var/log/php-fpm.logpid =/usr/local/var/run/ Php-fpm.pid or do not modify the path of the configuration item in the configuration file, in the PHP-FPM run parameter (-p) specifies the relative path prefix of the drop runtime file  $ php-fpm--fpm-config/usr/local/etc/ Php-fpm.conf  --prefix/usr/local/var to this, PHP-FPM daemon has basically been able to start correctly.   Below we look at the php.ini configuration file and the installation of the extension. First look at the compilation parameters, some values are compiled into the execution of the program, cannot be changed. $ php-i|grep Config Find the configuration file (php.ini), directory location, the value of the following two entries specify '--with-config-file-path=/etc '--with-config-file-scan-dir=/ Library/server/web/config/php ' So we need to create php.ini,mac in the/etc directory in/private/etc,/ Etc are provided in the sample file Php.ini.default, through the inspection, two files are identical, so copy which does not matter, MAC has provided MD5 instead of Linux under the md5sum:$ md5/private/etc/ PHP.INI.DEFAULT/ETC/PHP.INI.DEFAULTMD5 (/private/etc/php.ini.default) = 1C47241665EA5EFDC55FD5809F675449MD5 (/etc/ Php.ini.default) = 1c47241665ea5efdc55fd5809f675449 /etc Directory permission Root:wheel, requires root access or sudo, For instructions on how to set the password required for the sudo command of your Mac, see http://support.apple.com/kb/HT4103?viewlocale=zh_CN&locale=zh_CNhttp://support.apple.com/kb/ph6515?viewlocale=zh_cn # Cp/etc/php.ini.default  /etc/ PHP.ini change own, later change not always switch root, production environment best not change # Chown < your username >/etc/php.ini# chmod u+w/etc/php.ini  install PHP extension/library /server/web/config/php This directory does not exist, or Mac OS X Server version has it, do not know, manually create him, with root permissions # Mkdir-p/library/server/web/config/php   Compile extensions, Brewhome is a one-off, brew-style installation extension needs to rely on PHP, such as Php54-redis will rely on PHP54, as to whether the compiled extensions can be configured to bring their own, no experiment. The following is an example of a php_discuz extension (https://github.com/potterhe/php_discuz download). If the extension source code in the/users/apple/php_discuz directory $./configure$ make extension compiled, the default is stored in the/users/apple/php_discuz/modules/ Discuz.so will expand in config file Open $ echo "extension=/users/apple/php_discuz/modules/discuz.so" >/library/server/web/config/ php/discuz.ini  Test Validation $ php-i|grep discuzdiscuz support = enabled  Run use case test $ php-f/users/apple/php_discuz/ Discuz.php   nginx file not found error handling for accessing PHP files, two cases

This error is common, there are two of the following

1. PHP-FPM could not find PHP files executed in Script_filename

2. PHP-FPM cannot access the PHP that is being executed, that is, the permissions issue

First case

It can be added to your location PHP to return 404 when the file does not exist, instead of handing it over to PHP-FPM.

Location ~ \.php$
{
...
#文件不存在转404
Try_files$uri = 404;
...
}

Then, in your configuration file, find the following paragraph

Fastcgi_param Script_filename/scripts$fastcgi_script_name;

Replace with the following Fastcgi_param script_filename $document _root$fastcgi_script_name;

Then reload the Nginx configuration file

Systemctl Restart Nginx
The second case

Two workarounds:
The first is to set your root folder to be allowed by other users
Second, find your php-fpm configuration file, find the following section, and replace Apache with the user group you want


; Rpm:apache choosed to being able to access some dir as httpd
user = Apache
; Rpm:keep a group allowed to write in log dir.
Group = Apache

Mac Nginx php php-fpm

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.