一:## 新建一个Web站点
[root@centos7-1 ~]# vim /data/usr/local/nginx/conf/nginx.conf
include /data/usr/local/nginx/conf/conf.d/*.conf;##建议把配置写在下面的子文件里面,不要在源文件配置,;是固定结尾符。写在最后一个}前面就行了
}
[root@centos7-1 html]# vim /data/usr/local/nginx/conf/conf.d/web1.conf
server {
listen 80; ##监听80端口
server_name www.jyc.net; ##主机名,其实就是你访问的url
location / {
root /var/www/html; ##这个location对应的根目录,文件路径就是root+location,例如访问www.jyc.net 其实后面省略了/index.html,那么uri就是/index.html 对应的就是这个location
index index.html;
}
location /mobile {
root /var/www/html; ##这里的uri需要些/mobile/了,这里的文件路径就是root+location
index index.html;
}
}
配置测试页面:
[root@centos7-1 mobile]# cat /var/www/html/index.html
web1 page 192.168.48.141
[root@centos7-1 mobile]# cat /var/www/html/mobile/index.html
mobile www.jyc.net 192.168.48.141