brew非root用户下使用php72和nginx

来源:互联网 发布:中国软件发展趋势 编辑:程序博客网 时间:2024/06/01 15:42
用brew分别安装php72和nginx
安装时不用考虑插件问题可后续安装 --with-fpm 在options中默认为withot状态 不用关默认会安装的
添加环境变量
echo 'export PATH="$(brew --prefix homebrew/php/php72)/bin:$PATH"' >> ~/.bash_profile
执行source ~/.bash_profile
修改php-fpm的配置
新建日志文件
touch /usr/local/var/log/php-fpm72.log
不然会抱报错
[24-Sep-2017 09:45:52] ERROR: failed to open error_log (/usr/local/var/log/php-fpm.log): Permission denied (13)
因为我们是用非root账户不能是用root账户创建的文件或者文件夹 记住这一点
并且修改php-fpm.conf配置文件
error_log = log/php-fpm72.log
执行php-fpm
[24-Sep-2017 09:46:27] NOTICE: [pool www] 'user' directive is ignored when FPM is not running as root
[24-Sep-2017 09:46:27] NOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
自动忽略执行
lsof -Pni4 | grep LISTEN | grep php
php-fpm   3440   cz    7u  IPv4 0x959c0067c3d07c69      0t0  TCP 127.0.0.1:9000 (LISTEN)
php-fpm   3441   cz    0u  IPv4 0x959c0067c3d07c69      0t0  TCP 127.0.0.1:9000 (LISTEN)
php-fpm   3442   cz    0u  IPv4 0x959c0067c3d07c69      0t0  TCP 127.0.0.1:9000 (LISTEN)
成功
*加入到开机启动(如果使用lanchrocket的建议跳过这步)
To launch php-fpm on startup:
    mkdir -p ~/Library/LaunchAgents
    cp /usr/local/opt/php56/homebrew.mxcl.php72.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php72.plist

修改nginx服务器配置
参考http://www.cnblogs.com/huijian222/p/6163692.html
1.打开 nginx.config 文件
?
1
/usr/local/etc/nginx/nginx.conf
2.找到 server 的 location 配置,给 index 加一个 index.php
?
1
2
3
4
location / {
  root  配置成自定义的文件夾;
  index index.html index.htm index.php;
}
3.并打开 server 下被注释的 location ~.php$(即删除代码前面的 ‘#'),如下:
?
1
2
3
4
5
6
7
location ~ \.php$ {
  root      配置成自定义的文件夾;
  fastcgi_pass  127.0.0.1:9000;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
  include    fastcgi_params;
}
4.并修改 fastcgi_param 参数
?
1
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
改为
?
1
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
5.执行nginx -c /usr/local/etc/nginx/nginx.conf
使配置生效
6.执行nginx -s reload
如果出错
nginx: [error] open() "/usr/local/var/run/nginx.pid" failed (2: No such file or directory)
执行上面的第5步使配置生效的命令
7.重新启动nginx服务器

错误
403 php-fpm和nginx是否都是同一个用户下的,nginx的root参数是否是该用户下的
File no found nginx下的配置 所有的root参数是否都修改为自定义的路径
原创粉丝点击