1. 使用 brew 安装 nginx
brew install nginx
2.打开ngnix
sudo nginx
-- 重启ngnix
ngnix -s reload
3. 关于php ,默认使用 mac 上的php ,先配置 ,再开启 php-fpm
sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf vim /private/etc/php-fpm.conf
sudo php-fpm
4.找到 /usr/local/etc/nginx/nginx.conf , 配置虚拟主机(###|$$$ 根据主机而定)
server {
listen 80;
server_name www.####.com;
root /Users/#####/$$$$$;
index index.html index.htm index.php;
location / {
root html;
index index.html index.htm;
if (!-e $request_filename) {
#rewrite ^/(.*)$ /index.php?$1 last;
rewrite "^/(.*)$" /index.php last; #这一条很重要
}
rewrite ^/$/index.php last;
}
location ~ .*\.php$
{
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
expires off;
}
}