macOS 集成环境MAMP 配置nginx虚拟域名

原创
2016/11/16 10:16
阅读数 3.4K

不废话,直接上过程

sudo vim /private/etc/hosts;
#增加要监控的server_name
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
127.0.0.1       sayhei.com    #这一行我加的

然后修改MAMP的nginx配置

vim /Applications/MAMP/conf/nginx/nginx.conf
server {
		listen               80 default_server;

		# MAMP DOCUMENT_ROOT !! Don't remove this line !!
		root                 "/Applications/MAMP/htdocs";

		access_log           /Applications/MAMP/logs/nginx_access.log;
		error_log            /Applications/MAMP/logs/nginx_error.log debug;

		location / {
			index            index.html index.php;
			root             /Applications/MAMP/htdocs;
		}
...
       }

#添加一个server
server {
		listen               80;
		server_name          sayhei.com;
		# MAMP DOCUMENT_ROOT !! Don't remove this line !!
		root                 "/Applications/MAMP/htdocs/project/tp5/public";

		access_log           /Applications/MAMP/logs/nginx_access.log;
		error_log            /Applications/MAMP/logs/nginx_error.log debug;

		location / {
			index            index.html index.php;
		}
...
       }

修改root路径,重启nginx,OK。

展开阅读全文
打赏
0
0 收藏
分享
加载中

引用来自“fanhu”的评论

为什么我添加了一个新的server后直接就起不来了
我也起不来。请问怎么解决的?
2018/04/07 20:00
回复
举报
为什么我添加了一个新的server后直接就起不来了
2017/04/19 16:52
回复
举报
更多评论
打赏
2 评论
0 收藏
0
分享
返回顶部
顶部