首先进入nginx的servers
$ cd /usr/local/etc/nginx/servers
然后查看一下自己的.conf文件,可以自己新建一个,配置~
$ touch learnphp.conf
$sudo vim learnphp.conf
1 server{
2 listen 80;
3 server_name learn.php.com; //自己需要的域名
4 root /Users/yzi/PhpstormProjects/learnphp; //项目的路径
5 index index.php index.html;
6 location / {
7 try_files $uri $uri/ /index.php?_url=$uri&$args;
8 }
9 location ~ \.php {
10 fastcgi_pass 127.0.0.1:9000;
11 fastcgi_index index.php;
12 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
13 include fastcgi_params;
14 }
15 }
再去添加一下域名
$ sudo vim /etc/hosts
2 # Host Database
3 #
4 # localhost is used to configure the loopback interface
5 # when the system is booting. Do not change this entry.
6 ##
7 127.0.0.1 localhost local.api.ebao.com
8 127.0.0.1 learn.php.com
9 255.255.255.255 broadcasthost
10 ::1 localhost
最后重启nginx
$ sudo nginx -s reload
搞定!
learnphp.png