nginx搭建游戏网站

  • nginx搭建游戏网站
1.注释掉之前的默认网站
[root@web01 html]# cd /etc/nginx/conf.d/
[root@web01 conf.d]# gzip default.conf 
2.编写游戏网站Nginx配置文件
[root@web01 conf.d]# cat game.oldxu.com.conf 
server {
	listen 80;			#该网站提供访问的端口
	server_name game.oldxu.com;	#访问该网站的域名
	
	location / {
		root /code;
		index index.html;
	}
}
3.根据Nginx的配置文件,初始化
[root@web01 conf.d]# mkdir /code
4.上传代码(此处代码只要是游戏代码就行,最好为五子棋或者坦克大战!)
[root@web01 conf.d]# cd /code/
[root@web01 code]# rz html5.zip
[root@web01 code]# unzip html5.zip 
5.检测语法
[root@web01 code]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
6.重载服务
[root@web01 code]# systemctl restart nginx
7.配置域名解析
本机host配置(真实云环境进行域名与服务器绑定即可访问)
8.Nginx访问网站的整体流程
http://    game.oldxu.com     /      game/yibihua/index.html
请求的uri:		/game/yibihua/index.html
真实映射位置:   /code/game/yibihua/index.html
posted @   老王教你学Linux  阅读(456)  评论(0编辑  收藏  举报
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 【译】Visual Studio 中新的强大生产力特性
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
点击右上角即可分享
微信分享提示