您好,欢迎访问一九零五行业门户网

mac os下配置nginx+php7.1+fastcgi

这篇文章介绍的内容是关于mac os下配置nginx+php7.1+fastcgi,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下
mac os 预装的php 版本 是 5.6.3,使用homebrew将php更新到php7.1 并搭建 nginx。安装 nginx$ brew search nginx $ brew install nginx // 安装之后,常用的配置路径有: // 配置文件路径:/usr/local/etc/nginx/nginx.conf // 服务器默认路径:/usr/local/var/www // 貌似是安装路径:/usr/local/cellar/nginx/1.13.11
此时打开localhost:8080 应该是能看到 :welcome to nginx!
nginx 的基本命令如下:
//测试nginx 站点是否正确 $ sudo nginx -t //重新加载 nginx 服务 $ sudo nginx -s reload // 关闭 nginx 服务 $ sudo nginx -s stop
更新 php7.1$ brew update // 更新安装 php7.1 $ brew install php71 $ echo 'export path="/usr/local/opt/php@7.1/bin:$path"' >> ~/.bash_profile $ echo 'export path="/usr/local/opt/php@7.1/sbin:$path"' >> ~/.bash_profile // 安装模块 $ brew install php71 --with-debug --with-homebrew-curl --with-homebrew-libxslt --with-homebrew-libressl --with-homebrew-libxml2 --with-phpbg --with-webp --with-imap --build-from-source php71-mcrypt php71-igbinary php71-mongodb php71-redis php71-intl php71-xdebug
修改 nginx 配置1、 php7.1安装成功之后,此时直接访问 index.php 可能会有 403 或者 下载 这两种情况。需要修改 nginx.config 文件
打开nginx.config文件
$ vim /usr/local/etc/nginx/nginx.conf
2、 修改用户和用户组(访问出现403可能是 因为用户和用户组)
user fg dev // 在配置文件的第一行。user 后第一个参数是用户名,第二个是用户组。 // 查看用户和用户组 (系统偏好设置-->用户与群组-->选中用户右键-->高级选项)
3、 在server 的 location 配置中添加 index.php
location / { root html; index index.html index.htm index.php; }
4、 将被注释的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; }
5、 修改上一步范围内的 fastcgi_param 参数
fastcgi_param script_filename $document_root$fastcgi_script_name;
以上步骤基本完成配置。等有空把虚拟主机部分再添加上。
相关推荐:
mac上通过docker配置php开发环境
以上就是mac os下配置nginx+php7.1+fastcgi的详细内容。
其它类似信息

推荐信息