1. 打开 /Applications/MAMP/conf/nginx/nginx.conf 在server最后面 加上一行
include vhost/nginx.*.conf; 这是加载vhost文件夹里面的所有nginx.(站点).conf 的配置文件
2.在vhost文件 新建文件
如 配置 www.sign.com 那就新建nginx.sign.conf
在文件中添加以下内容
server { listen 80; server_name www.sign.com; # MAMP DOCUMENT_ROOT !! Don't remove this line !! root "/Applications/MAMP/htdocs/sign/public"; access_log /Applications/MAMP/logs/sign_access.log; error_log /Applications/MAMP/logs/sign_error.log debug; location / { index index.html index.php; } #下面这块最好复制nginx.conf文件里面的,如果地址和我的不一样,php代码会解析不了 location ~ .php$ { try_files $uri =404; fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }