Nginx搭建游戏

一: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

posted @ 2021-12-31 22:38  AlexEvans  阅读(125)  评论(0编辑  收藏  举报