⑤配置第一个网站
匿名 · 更新于 2017/6/30
1、在家目录home下新建 www/myweb 目录
2、进入/application/nginx/conf目录 cd /application/nginx/conf
3、新建extra目录 mkdir extra
4、在extra目录下新建 myweb.conf 配置文件,其中代码配置如下
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /home/www/myweb;
index index.php index.html index.htm;
if (!-e $request_filename) {
rewrite ^(.)$ /index.php?s=$1 last;
break;
}
}
location ~ .php/?. {
root /home/www/myweb;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
#error_page 404 /404.html;
}
5、修改nginx.conf,注释server区块配置,并且在http区块最后引入myweb.conf include extra/myweb.conf;
6、到此为止,第一个网站配置成功,重启nginx就可以访问了(这里是通过IP访问,如果绑定域名,可以将server_name 后边的localhost设置为对应域名)
