牛刀小试:Nginx网站配置实操

Nginx网站配置实操

注意:后续章节均以yum官方源安装的nginx主配置文件为例详解。

h5小游戏网站部署


# 在/nginx/conf.d下新增配置文件game.conf
​
cd /etc/nginx/conf.d
ll
vim game.conf
  
server {
    listen 80;
    server_name game.driveryang.com;   # 服务的IP或域名
 
    location / {                # 控制网站访问路径
        root /code/h5_games;    # 这个目录要能找到下面这个index.html才行     
        index index.html;       # 默认网站页面的文件
    }
}
​
# 放置游戏源代码文件至nginx配置文件指定的目录
mkdir /code && cd /code
wget http://test.driverzeng.com/Nginx_Code/h5_games.zip
​
# 解压
unzip h5_games.zip 
​
解压后:
  0 ✓ 10:53:58 root@web01,172.16.1.7:/code # ll
total 18856
drwxr-xr-x 6 root root      108 May  3  2019 h5_games
-rw-r--r-- 1 root root 19304923 May  3  2019 h5_games.zip
drwxrwxr-x 3 root root       40 May  3  2019 __MACOSX
​
# 检查配置语法是否存在错误并重载nginx (记得每次配置完文件都要检查并重载)
nginx -t
systemctl reload nginx  
​
# 设置windows本地DNS解析文件(只要是域名访问,就要在客户端做解析)
win+R输入drivers,在里面找
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值