Mac 之 Nginx 安装
参考
打开终端, 对 brew 进行更新
brew update
查询 Nginx 是否存在
brew search nginx
查看 Nginx 详情
brew info nginx
正式开始安装
brew install nginx
查看 Nginx 安装目录(是否如 info 所说)
open /usr/local/etc/nginx/ # 配置目录
open /usr/local/Cellar/nginx # 安装目录
启动 Nginx, 终端输入如下命令
nginx
修改 Nginx 配置
vim /usr/local/etc/nginx/nginx.conf
在 http 里面增加
# 开启目录文件列表
autoindex on;
# 显示出文件的确切大小, 单位是bytes
autoindex_exact_size off;
# 显示的文件时间为文件的服务器时间
autoindex_localtime on;
#设置字符集
charset utf-8,gbk;
添加 server 配置
server {
...
location / {
root /Users/zhangsan/projects/;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /Users/zhangsan/projects/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
...
}