MacOS 自带 PHP 执行 php-fpm 的问题及解决
2020-01-21 本文已影响0人
Peter杰
MacOS下执行php-fpm会报错
ERROR: failed to open configuration file '/private/etc/php-fpm.conf': No such file or directory (2)
ERROR: failed to load configuration file '/private/etc/php-fpm.conf'
ERROR: FPM initialization failed
不能打开配置文件,因为没有 php-fpm.conf 文件,复制 php-fpm.conf.default 文件,改名为 php-fpm.conf,然后再根据需要改动配置。
cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf
再次执行php-fpm
WARNING: Nothing matches the include pattern '/private/etc/php-fpm.d/*.conf' from /private/etc/php-fpm.conf at line 125.
ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
ERROR: failed to post process the configuration
ERROR: FPM initialization failed
WARNING 找不到配置文件夹
cd /private/etc/php-fpm.d
sudo cp www.conf.default www.conf
ERROR 不能打开错误日志文件。因为没有这个目录,配置到 /usr/local/var/log 目录。
vim /private/etc/php-fpm.conf,将 error_log 配置为 /usr/local/var/log/php-fpm.log
再次执行 php-fpm 依然报错
NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
sudo php-fpm,再次报错:
因为9000端口被占用,编辑 www.conf,修改 listen 为 127.0.0.1:9999。
sudo vim /private/etc/php-fpm.d/www.conf
最后再次开启
开启php-fpm: sudo php-fpm -D
nginx 使用 php-fpm
nginx 配置文件
vim /usr/local/etc/nginx/nginx.conf
server {
listen 8080;
server_name localhost;
location / {
root /Users/guofeng/wwwroot/thinkphp/public;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /Users/guofeng/wwwroot/thinkphp/public;
fastcgi_pass 127.0.0.1:9999;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}