Mac 下配置Nginx安装环境配置详细说明
环境信息:
Mac OS X 10.11.1
Homebrew 0.9.5
正文
一、安装 Nginx
1.终端执行:
1
2
|
brew search nginx brew install nginx |
当前版本 1.6.2
安装完以后,可以在终端输出的信息里看到一些配置路径:
/usr/local/etc/nginx/nginx.conf (配置文件路径)
/usr/local/var/www (服务器默认路径)
/usr/local/Cellar/nginx/1.6.2 (貌似是安装路径)
二、访问localhost:8080
Nginx 默认8080端口,这时已经可以访问了:
localhost:8080
会有一个默认欢迎界面。
三、修改 php-fpm 文件
1.执行命令:
1
|
sudo cp /private/etc/php-fpm .conf.default /private/etc/php-fpm .conf |
2.找到目录下的 php-fpm 文件
1
|
/private/etc/php-fpm .conf |
3.找到32行的 error_log ,改为(正行替换,注意 ‘;' 和空格):
1
|
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 配置
1.打开 nginx.config 文件
1
|
/usr/local/etc/nginx/nginx .conf |
2.找到 server 的 location 配置,给 index 加一个 index.php
1
2
3
4
|
location / { root html; index index.html index.htm index.php; } |
3.并打开 server 下被注释的 location ~.php$(即删除代码前面的 ‘#'),如下:
1
2
3
4
5
6
7
|
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 参数
1
|
fastcgi_param SCRIPT_FILENAME /scripts $fastcgi_script_name; |
改为
1
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; |
五、创建 index.php
在 /usr/local/var/www 目录下,删除 index.html,创建 index.php,输入
1
|
<?php phpinfo(); ?> |
六、启动相关服务
1
2
|
sudo nginx sudo php-fpm |
然后访问localhost:8080,看到 php 配置信息,就说明 ok 了
七、其他命令
修改 nginx.conf 后,重载配置文件
1
|
sudo nginx -s reload |
停止 nginx 服务器
1
|
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 参数是否修改。
转载于脚本之家(http://www.jb51.net/article/105492.htm)
Mac 下配置Nginx安装环境配置详细说明的更多相关文章
- Mac下安装nginx并配置SSL实现Https的访问
一.nginx安装 ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/insta ...
- Linux下的Nginx的配置+Tomcat启动
Linux下的Nginx的配置 首次如果你只仅主机模式,那么请你切换到桥接模式或者net模式. 1.安装编译工具及库文件 yum -y install make zlib zlib-devel gcc ...
- Mac下Maven安装与配置
Mac下Maven安装与配置 下载maven http://maven.apache.org/download.cgi main->download菜单下的Files 下载后解压在Documen ...
- CentOS 下 安装 nginx 执行配置命令 ./configure 报错
CentOS 下 安装 nginx 执行配置命令 ./configure --prefix=/opt/nginx --sbin-path=/usr/bin/nginx 时提示以下错误: checkin ...
- Mac 下 安装 Nginx
---恢复内容开始--- Mac 下 安装nginx 首先确定自己有安装homebrew 安装 nginx brew install nginx 启动nginx 1.15版本下 安装是 直接在ngin ...
- mac下安装nginx及相关配置
1. 安装 Homebrew 首先 homebrew是什么?它是Mac中的一款软件包管理工具,通过brew可以很方便的在Mac中安装软件或者是卸载软件.不了解的同学看以看官网(https://br ...
- Linux下安装Nginx并配置一个图片服务器
首先安装nginx安装环境 nginx是C语言开发,建议在linux上运行,本教程使用Centos6.5作为安装环境. gcc 安装nginx需要先将官网下载的源码进行编译,编译依赖gcc环境,如果没 ...
- 【工匠大道】Mac下Java开发环境配置简述
本文地址 原文地址 分享提纲: 1. 下载JDK1.7 2. 配置java_home 3 .安装tomcat 4 .安装eclipse或者myeclipse 5. mysql安装 破解版下载请参考M ...
- Mac下golang开发环境配置
go语言在开发效率和运行效率中的优势让很多人青睐,所以有倾向打算转向go语言的开发. 下面介绍在Mac OS X中golang的开发环境配置. 1.安装brew brew是一个mac下的由ruby开发 ...
随机推荐
- 安装三代组装canu、smartdenovo、wtdbg及矫正软件Racon、Nanopolish的安装
1)三代组装软件 ------------------------------------------------------------------canu--------------------- ...
- Error:No toolchains found in the NDK toolchains folder for ABI with prefix: mips64el-linux-android
https://www.jianshu.com/p/fd3d49c7f1f8 通过Android Studio 的Sdk Manager安装NDK,安装完之后编译失败,报错信息如下: Error:No ...
- maven <scope>provided</scope>
今天开发web的时候,需要用到servlet-api,于是在pom.xml中添加依赖 <dependency> <groupId>javax.servlet</group ...
- 使用JavaMail发送邮件-no object DCH for MIME type multipart/mixed报错解决
最近需要实现一个使用Spring schedule按一定时间间隔自动触发条件发送邮件的功能,在开发的过程中,是按照先测试能发出text/html文本邮件,然后测试添加附件发送邮件,我碰到的问题是,文本 ...
- mysql 多行合并一行
SELECT `w`.`id` AS `id`, `w`.`phone` AS `phone`, `w`.`belong_id` AS `belong_id`, `w`.`name` AS `name ...
- metadata信息的采集
exiftool可以查看图片的信息.可以获得照片的相关信息,甚至是GPS定位信息.
- 最完整Android Studio插件整理 (转)
转自:http://blog.csdn.net/alpha58/article/details/62881144 现在Android的开发者基本上都使用android Studio进行开发(如果你还在 ...
- centos7 脚本搭建SVN
#!/usr/bin/env bash #安装软件 HTTP 和 SVN软件 yum install -y httpd subversion mod_dav_svn #创建库文件夹并更改文件夹权限 m ...
- 154. Find Minimum in Rotated Sorted Array II (Array; Divide-and-Conquer)
Suppose an array sorted in ascending order is rotated at some pivot unknown to you beforehand. (i.e. ...
- 102. Binary Tree Level Order Traversal (Tree, Queue; BFS)
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, ...