Table of contents
Preface
The previous article was about [How to use Huawei Cloud Yaoyun Server L instance] . Today we will do a real project deployment. The actual project can best train a person's learning ability. In this article, we will deploy a small game around cats so that we will not be too boring during the learning process. I also hope that you will gain something after following my article.
Game address: Waimaomao mini-game online address
Game display:
1. Reasons for choosing Huawei Cloud Yaoyun Server L instance
I have also learned about other cloud servers before, but finally chose Yunyao Cloud Server L instance because its usage threshold is low, and I am still in the learning stage for servers. If there are too many server configurations, it will only make me overwhelmed. retreat. However, Yunyao Cloud Server L instance is a new generation of out-of-the-box lightweight application cloud server built for small and medium-sized enterprises and developers. Yunyao Cloud Server L instance provides a rich and carefully selected application image, enabling one-click deployment of applications, helping customers to build e-commerce websites, web applications, applets, learning environments, various development tests, etc. in the cloud conveniently and efficiently.
2. Advantages of Huawei Cloud Yaoyun Server
Compared with traditional cloud servers, Huawei Cloud Yao Cloud Server L instances are simpler to purchase and use. The Huawei Cloud User Experience Team addresses the pain points of small and medium-sized enterprises and developers in cloud server selection, deployment, use, operation and maintenance, and proposes "user scenario-centered purchasing " and " global availability from the whole to parts." The solution ideas of "video management " and " one-stop configuration guidance " have been implemented, and multiple experience optimization solutions have been implemented, which greatly improved the user experience.
3. Quickly deploy a small game
There are two methods provided here, one is terminal deployment and the other is pagoda visualization panel deployment. Both of them can be deployed quickly. You can choose the method you are most familiar with for practical operation. In addition, this server is Ubuntu
.
(1) Terminal deployment
1. Use Termius
tools to connect to the terminal
Enter the server name, IP address, username, and password, and enter the terminal after logging in.
After logging in, the following interface is displayed
2. Install Nginx
sudo: A tool that allows system administrators to let ordinary users execute some or all root commands.
- Install
sudo apt update
sudo apt install nginx -y
- start up
sudo systemctl start nginx
sudo systemctl enable nginx
- check status
sudo systemctl status nginx
sudo systemctl is-active nginx
- The configuration file for configuring
Nginx is located at/etc/nginx/nginx.conf
cd /etc/nginx
vi nginx.conf
http {
server
{
# 监听的端口号
listen 8088;
# 定义了虚拟主机的域名或IP地址
server_name 123.249.122.178;
# 将此路径替换为您的Vue.js应用程序的dist文件夹所在的实际路径
root /www/wwwroot/catchcat/dist;
# 定义了默认的索引文件,如果用户请求的是一个目录而不是特定文件时,Nginx会尝试查找这些文件作为默认文件
index index.html index.htm;
# 定义特定URL路径的配置
location / {
# 定义了Nginx的行为。它告诉Nginx首先尝试查找与请求URI匹配的文件($uri),如果找不到,则尝试查找一个目录($uri/),最后如果还找不到,将请求重定向到/index.html
try_files $uri $uri/ /index.html;
}
}
}
3. Upload the package file
Upload the packaged file to /www/wwwroot/catchcat/dist
and you can access it!
Access address: http://123.249.122.178:8088
(2) Pagoda visualization panel deployment
Pagoda Linux Panel is a free, open source web control panel for managing Linux servers. It provides a series of functions and tools to make server management simpler and more efficient.
1. Enter the pagoda
After we purchased Linux 可视化宝塔面板8.0
the server, there was a Pagoda management address. The previous article has already introduced how to obtain the account password of the pagoda, so I won’t explain it here.
Then we log in with our account and password and enter the pagoda interface.
2. Pagoda menu
The left menu of the Pagoda Linux panel provides a series of main functions and modules for managing and configuring your Linux server. The following are the main functions of the menu on the left side of the Pagoda panel:
-
Website: In this module, you can create, manage and configure a website, including virtual host, domain name, FTP account and SSL certificate settings.
-
FTP: FTP server management module, you can set up FTP accounts for file upload and download.
-
Database: Used to manage database systems, supporting MySQL, MariaDB, MongoDB, etc. Here you can create, import, backup and restore databases.
-
Monitor: Used to monitor server performance and resource usage, including CPU, memory, disk, etc.
-
Security: Provides some security-related settings, such as firewall, DDoS protection, SSH key management, etc.
-
File: Provides a Web file manager that can be used to browse, upload, download, edit and delete files on the server.
-
Log: Here you can view various log files of the server for troubleshooting and performance analysis.
-
Terminal: The server address where you can connect.
-
Scheduled tasks (Cron): You can create and manage scheduled tasks to automatically execute specific tasks or scripts on a regular basis.
-
Software store: You can download various applications, such as: Nginx, Apache, Pm2, etc.
3. Upload the code
Open 文件
the menu, there will be www
a root directory starting with, then /www/wwwroot
create a new catchcat
file in the directory and upload the packaged dist file of the game.
4. Download the Nginx application
软件商城
Search in , Nginx
then download and install. Note that the download may take a long time (it took me more than 20 minutes to download)
5. Configure Nginx
There are two ways to configure Nginx.
(1) Visualization panel configuration
Click 设置
the button in the picture above, and then a pop-up box will appear, and then modify the configuration in the configuration modification option.
Here is the main server
content being modified. After modification, click Save.
server
{
# 监听的端口号
listen 8088;
# 定义了虚拟主机的域名或IP地址
server_name 123.249.122.178;
# 将此路径替换为您的Vue.js应用程序的dist文件夹所在的实际路径
root /www/wwwroot/catchcat/dist;
# 定义了默认的索引文件,如果用户请求的是一个目录而不是特定文件时,Nginx会尝试查找这些文件作为默认文件
index index.html index.htm;
# 定义特定URL路径的配置
location / {
# 定义了Nginx的行为。它告诉Nginx首先尝试查找与请求URI匹配的文件($uri),如果找不到,则尝试查找一个目录($uri/),最后如果还找不到,将请求重定向到/index.html
try_files $uri $uri/ /index.html;
}
}
Finally, restart Nginx and click the button 服务
in the menu 重启
. If there is no problem with the above configuration, it will be displayed nginx服务已启动
.
(2) Modify nginx.conf
files directly
Click the left menu 文件
and then /www/server/nginx/conf
search for nginx.conf
files based on the directory
Double-click nginx.conf
the file to make changes.
Note that nginx needs to be restarted after saving the file here. You can restart it through the method (1), or of course through the command line:
//判断nginx配置是否正确
nginx -t
//停止nginx
nginx -s stop
//重启nginx
nginx -s reload
If you don’t have permission, add it in front ofsudo
Summarize
This project uses Huawei Cloud Yaoyun Server L instance. It starts with the basic use of Pagoda and explains how to deploy a Maomao Mao mini-game. From the code upload to Nginx configuration, direct operation through the visual panel, you can get started quickly. You can deploy one in 10 minutes. project, this is also an important reason why I chose Huawei Cloud Yaoyun Server L instance.