修改 php-fpm 文件

1.执行命令:

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

2.找到目录下的 php-fpm 文件

/private/etc/php-fpm.conf

3.找到32行的 error_log ,改为(正行替换,注意 ‘;’ 和空格):

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

否则 php-fpm 时会报错:

ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)

四、修改 Nginx 配置

打开 nginx.config 文件

/usr/local/etc/nginx/nginx.conf

2.找到 server 的 location 配置,给 index 加一个 index.php

location / {

root  html;

index  index.html index.htm index.php;

}

3.并打开 server 下被注释的 location ~.php$(即删除代码前面的 ‘#’),如下:

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.并修改 fastcgi_param 参数

fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

改为

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

五、创建 index.php

在 /usr/local/var/www 目录下,删除 index.html,创建 index.php,输入

六、启动相关服务

sudo nginx

sudo php-fpm

然后访问localhost:8080,看到 php 配置信息,就说明 ok 了

七、其他命令

修改 nginx.conf 后,重载配置文件

sudo nginx -s reload

停止 nginx 服务器

sudo nginx -s stop

停止 php-fpm可以直接在 Activity Monitor 中停止。也可以使用脚本来停。

八、可能出现的问题

1.访问 index.php 报 403 Forbidden.查看(四.2)步骤中,是否在 index 后添加 index.php。

2.访问 index.php 报 File not found.查看(四.4)中,fastcgi_param 参数是否修改。

WARNING: Nothing matches the include pattern '/private/etc/php-fpm.d/*.conf'

localhost:www qiaoting$ sudo php-fpm

[17-Nov-2018 19:14:03] WARNING: Nothing matches the include pattern '/private/etc/php-fpm.d/*.conf' from /private/etc/php-fpm.conf at line 126.

[17-Nov-2018 19:14:03] ERROR: No pool defined. at least one pool section must be specified in config file

[17-Nov-2018 19:14:03] ERROR: failed to post process the configuration

[17-Nov-2018 19:14:03] ERROR: FPM initialization failed

解决:
cd /private/etc/php-fpm.d
sudo cp www.conf.default www.conf
 

mac下配置nginx php的更多相关文章

  1. 【高可用HA】Nginx (1) —— Mac下配置Nginx Http负载均衡(Load Balancer)之101实例

    [高可用HA]Nginx (1) -- Mac下配置Nginx Http负载均衡(Load Balancer)之101实例 nginx版本: nginx-1.9.8 参考来源: nginx.org [ ...

  2. Mac下配置Nginx负载均衡

    1.首先在Mac下安装Nginx(可参考我的另一篇随笔http://www.cnblogs.com/malcolmfeng/p/6896703.html). 2.安装Tomcat,下载后,解压,bin ...

  3. mac下配置nginx

    nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器,下面我们来了解下nginx的用法. 安装nginx 使用brew安装nginx brew install ...

  4. Mac 下配置Nginx安装环境配置详细说明

    环境信息: Mac OS X 10.11.1 Homebrew  0.9.5 正文 一.安装 Nginx 1.终端执行: ? 1 2 brew search nginx brew install ng ...

  5. CAS (3) —— Mac下配置CAS客户端经代理访问Tomcat CAS

    CAS (3) -- Mac下配置CAS客户端经代理访问Tomcat CAS tomcat版本: tomcat-8.0.29 jdk版本: jdk1.8.0_65 nginx版本: nginx-1.9 ...

  6. CAS (7) —— Mac下配置CAS 4.x的JPATicketRegistry(服务端)

    CAS (7) -- Mac下配置CAS 4.x集群及JPATicketRegistry(服务端) tomcat版本: tomcat-8.0.29 jdk版本: jdk1.8.0_65 cas版本: ...

  7. 在Mac下配置php开发环境:Apache+php+MySql

    /private/etc/apache2/httpd.conf 一.启动Apache sudo apachectl start sudo apachectl -v   可以查看到Apache的版本信息 ...

  8. iOS开发MAC下配置svn

    版本控制对于团队合作显得尤为重要,那么如何在iOS开发中进行版本控制呢?在今天的博客中将会介绍如何在MAC下配置SVN服务器,如何导入我们的工程,如何在Xcode中进行工程的checkOut和Comm ...

  9. windows 下配置 Nginx 常见问题(转)

    windows 下配置 Nginx 常见问题 因为最近的项目需要用到负载均衡,不用考虑,当然用大名鼎鼎的Nginx啦.至于Nginx的介绍,这里就不多说了,直接进入主题如何在Windows下配置. 我 ...

随机推荐

  1. HDU 5695 Gym Class

    拓扑排序. #include<cstdio> #include <iostream> #include<cstring> #include<cmath> ...

  2. lombok注解简化实体类getting 和 setting 方法

    实体类注解,将以往的get/set方法简化为标签注解,让代码看着更简洁. Maven依赖: <dependency> <groupId>org.projectlombok< ...

  3. 转: 使用valgrind检查内存问题

    作者:gfree.wind@gmail.com 博客:blog.focus-linux.net   linuxfocus.blog.chinaunix.net    本文的copyleft归gfree ...

  4. curl的使用(from 阮一峰)

    1.   http://www.ruanyifeng.com/blog/2011/09/curl.html 2.   https://curl.haxx.se/docs/httpscripting.h ...

  5. 2&gt;MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _calloc 已经在 LIBCMTD.lib(dbgcalloc.obj) 中定义

    使用VS2010,在FireBreath里面调用ortp库和Speex库.编译的时候出现错误: 2>MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _ca ...

  6. android事件分发(二)

    非常早之前写过一篇android事件分发的博客,主要写的是它是怎样分发的,具体非常多原理的东西都没有涉及到.今天就从源代码看android怎样控制它的分发机制. 鉴于手机屏幕的限制,所以android ...

  7. git clone新项目后如何拉取其他分支代码到本地

    1.git clone git@git.n.xxx.com:xxx/xxx.git 2.git fetch origin dev 命令来把远程dev分支拉到本地 - - 解读:git fetch命令用 ...

  8. inter 也支持linux开发了

    http://www.intel.cn/content/www/cn/zh/intelligent-systems/bay-trail/atom-processor-e3800-family-over ...

  9. 【CTF】后续深入学习内容

    1.i春秋 https://www.ichunqiu.com/course/451 搜索black hat,可以看到黑帽大会的内容.免费. 2.wireshark 基础篇 1)由于Wireshark是 ...

  10. jquery源码学习笔记三:jQuery工厂剖析

    jquery源码学习笔记二:jQuery工厂 jquery源码学习笔记一:总体结构 上两篇说过,query的核心是一个jQuery工厂.其代码如下 function( window, noGlobal ...