Nginx--Web核心配置示例之一

一:## 新建一个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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值