Nginx搭建游戏

本文详细介绍了如何使用Nginx部署《象棋游戏》和《马里奥游戏》,包括上传代码、编辑配置文件、测试配置、重启Nginx、域名解析及测试访问。重点讲解了配置文件的编写和域名的解析步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一:Nginx搭建《小游戏》
1.上传《象棋游戏》代码

image

2.编辑配置文件(尾部必须要加 .conf<文件>)
[root@web01 conf.d]# vim /etc/nginx/conf.d/game.conf

image

server {
    listen 80;
    #server_name localhost;
    server_name www.game.com;

    location / {
        root /opt/jiaoben1765/jiaoben1765;
        index index.html;
    }
}
3、测试配置文件是否正常
[root@web01 conf.d]# nginx -t

image

nginx: the configuration file /etc/nginx/nginx.conf syntax is oknginx: configuration file /etc/nginx/nginx.conf test is successful
4、重启Nginx
[root@web01 conf.d]# systemctl restart nginx
5、域名解析
1.windows目录下域名解析DNS
C:\Windows\System32\drivers\etc\hosts
2.文件内输入 ip地址  域名
172.16.1.7 www.game.com

image

6.测试域名访问

image

二:Nginx多次搭建《马里奥游戏》
1.切换路径到配置路径
cd /etc/nginx/conf.d
2.复制相同配置文件
[root@web01 conf.d]# cp game.confcd game1.confcd

image

3.编辑配置文件(尾部必须要.conf《文件》
[root@web01 conf.d]# vim game1.conf

image

server {
    listen 80;
    server_name www1.game.com;

    location / {
        root /opt/Mario;
        index index.html;
    }
}
3、测试配置文件是否正常
[root@web01 conf.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
4、重启Nginx
[root@web01 conf.d]# systemctl restart nginx
5、域名解析
1.windows目录下域名解析DNS
C:\Windows\System32\drivers\etc\hosts
2.文件内输入 ip地址  域名
172.16.1.7 www.game.com www1.game.com

image

6.测试域名访问

image

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值