The introduction
Want to experience the joy of legendary games? Want to experience the nobility of full VIP? Do you want to feel 99,999? All kinds of wonderful equipment, wings, pets, all for you, right in the archangel sword!
This article explains the archangel sword H5 game set up tutorial, want to study how to achieve H5 game, experience the game in seconds day seconds to seconds of air must not miss.
I built the archangel sword game link: http://39.105.134.68:81, computer and mobile phone can be perfect operation, come to experience it.
Game screenshots:
The erection
1. Set up conditions
Erection of archangel sword requires:
- For Linux servers, centos7/8 is recommended. Aliyun and Tencent cloud are recommended.
- Game source code, pay attention to my public number Echeverra, send “archangel sword” to obtain.
I have removed the ads from the game source code, fixed the GM, closed the game, etc.
2. Install a pagoda
Yum install wget - y && wget - O the sh http://download.bt.cn/install/install_6.0.sh && sh the shCopy the code
Pagoda is a server operation and maintenance management software, I from the beginning of LAMP to PHPstudy and then pagoda, found the pagoda really fragrant! Graphical interfaces are really easy to use. After the installation is complete, the url, user name and password will be given for access. Remember to save it and access the pagoda interface. If the access fails, port 8888 May not be opened on the server.
3. Environment installation
After the pagoda is installed, we need to install the running environment of the game:
- Web server: Nginx 1.20
- Database: mysql 5.6
- Programming languages: PHP 5.6, PHP 7.4
- Database management tool: phpMyAdmin 4.9
The game was built using PHP 5.6, and PHP 7.4 is a prerequisite for installing phpMyAdmin.
Install via pagoda App Store:
In addition to the environment installed through the pagoda, there are also environments that need to be installed by command.
Install libnsl and BC to support floating point operations:
yum install bc
yum install libnsl
Copy the code
The commands in the following steps are executed from the terminal menu and are not displayed in screenshots.
4. Upload the source code and decompress it
After getting the source code of the game, unzip the compressed file Archangel Sword, you will get angel and SQL two compressed files, upload the Angel compressed file to the server root directory.
After uploading, select the compressed angel file and unzip it to the root directory.
5. File permissions
After the decompression is complete, grant full 777 permissions to the decompressed directories /data and/WWW /wwwroot/angel.
Or authorize by command:
chmod -R 777 /data
chmod -R 777 /www/wwwroot/angel
Copy the code
Ini file permission cannot be changed. Skip this operation, which does not affect the installation.
6. Import the database
Change the password of database root on the pagoda to 0987abc123
Create two databases, H5 and Actor. H5 stores user-related data and Actor stores game-related data.
The password does not need to be changed because the source code uses the root administrator account.
Decompress the compressed file SQL in the source file of the game, get two SQL files, upload and import the corresponding database.
After the import, the root user can connect to the mysql server from any host and run the following command:
GRANT ALL PRIVILEGES ON *.* TO 'root'@'127.0.0.1' IDENTIFIED BY '0987abc123' WITH GRANT OPTION; GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' IDENTIFIED BY '0987abc123' WITH GRANT OPTION; flush privileges; exitCopy the code
7. Open ports
Ports to be opened:
- Pagoda: 8888
- Phpmyadmin: 888
- Mysql: 3306
- Game related ports: 81, 5007, 6007, 7007, 9007
Server open port, take Ali Cloud open port 81 as an example, other ports are added in the same way, other servers are also set in security.
Pagoda open port, also take port 81 as an example:
If you do not open the port, the service will not be accessible. If you have no security requirements, you can directly open the port from 1 to 65535.
8. Modify IP
Source IP is my own VIRTUAL machine IP, need to replace with your own server IP.
Files whose IP addresses need to be changed:
/www/wwwroot/angel/app1.php
/www/wwwroot/angel/login.php
/www/wwwroot/angel/config.php
/www/wwwroot/angel/game.php
/www/wwwroot/angel/login/cqlb/server.php
/www/wwwroot/angel/resource/main.min.js
/www/wwwroot/angel/login_bt.json
Copy the code
For example, modify the angel/app1. PHP file. You can modify other files in the same way.
Double-click app1.php to open edit mode, press Ctrl+F to search for 39.105.134.68, replace it with your server IP and save.
In addition to changing the IP address of the file, you also need to change the IP field of the server table in database H5.
Open the phpMyAdmin admin tool:
Double-click the field to change the IP address and press Enter to save:
9. Create a game website
To access H5 games, add the site from the menu of the website, write your domain name :81, root directory: / WWW /wwwroot/angel/, and select version 5.6 for PHP.
10. Start the game
With that done, it’s time to start the exciting game. Start the command:
cd /data/
sh start_server.sh
Copy the code
After normal startup, success will be prompted, check the listening port, you can see 5007, 6007, 7007, 9007 are listening, then congratulations you can start the game.
netstat -lntp
Copy the code
11. Start the game
Visit the game link: http://IP:81, using your server’s IP.
Can open the game login interface, congratulations you have passed the first step, and then registered an account login the game, click start the game, at this time will stay in an interface for 2-3 minutes, as the chart, this is because the files have been loaded a 10 MB +, patience to wait for, the second game will read the browser cache data, without waiting for.
Fill in the name of the game and select a class. There are currently three classes, swordsman, magician and archer. At the end of the game, you will have three classes, so choose any one.
Finally, enter the game interface, congratulations you have successfully completed the game set up!
12. The GM tool
The Game has a GM tool, also known as the Game Master, which can recharge the Game, send equipment, experience materials and other functions. The in-game recharge has been shielded from the payment configuration. Click the GM suspension button on the left to open the GM interface. Account Fill in the login account, not the game character name, Yuan Bao 280 represents the recharge monthly card, VIP10 full level need to recharge 200,000 yuan.
Receive emails from GM
Direct full VIP, that is, 20,000 RMB recharge!
You can also open the GM interface separately for operation, link:http://IP:81/gm.
Ah! How lonely invincible is…
13. Turn off the game
Close game execution command:
cd /data/
sh stop_server.sh
Copy the code
If no message is displayed after the command is executed, the shutdown is successful. Why no hint? Because no result is the best result.
subsequent
1. Security
The database used in the establishment is root account, password 0987abc123, which is equivalent to the database exposure, know the IP can directly log in the operation of the database, so there is a big security problem.
The first solution I came up with was to change the password of the root account and replace all 0987abc123 in the source code with my own password. However, the game did not run successfully. After studying the source code, it was found that the core file gameworld_24_5 in the background was encrypted and the configuration in gameWorld.txt would be read:
SQL = {Host = "127.0.0.1", Port = 3306, DBName = "actor", DBUser = "root", DBPass = "jdusVRPm8XI+vYJb5gNZiw==" }, --0987abc123Copy the code
The database password DBPass used in the background is 0987abc123 obtained using an encryption algorithm. You cannot set a new password if you do not know the encryption mode and key. Therefore, changing the password does not work.
Therefore, only the user name can be changed, corresponding to the three databases h5, actor, log (background will create their own log database) to create the corresponding account, password set to 0987abc123, as long as the account name is not leaked, the database is still secure, and will not affect other databases under root.
To modify the database configuration in the source code, change the root user name to the corresponding account name based on the database in use. If the gameworld.txt file above is used to modify the actor database, then change root to the actor database account. Webstorm or vscode IDE is recommended for global search and replacement.
You also need to execute the commands in the setup article 6 import database so that the three accounts can connect to the mysql server from any host.
Re-import the file and run the game successfully, thus solving the database security problem.
2. Change the zone name
You need to change the area name in two ways.
Modify/data/gameworld gameworld. TXT file
Example Modify the name field of the server table in database H5
Shut down the game and restart it, or you may get a “this server does not exist” error.
3. About the source code
Archangel Sword H5 game uses Ajax and Websocket communication to transmit data in the game, mainly using shell commands, PHP, Lua, JavaScript and other programming languages. Unfortunately, the background core files DBserver_24_5, gameworld_24_5, gateway_QIJI_24_5 and LoggerServer_24_5 are all encrypted and cannot be further studied, but other functions, Especially the foreground of the game interface rendering implementation or very valuable research.
Above is all the archangel Sword graphic construction tutorial, I hope to help you, if you have any questions, please contact me through my blog echeverra.cn and wechat official account echeverra.
Did you learn to “waste”?
This article was first published on my blog echeverra.cn.
Welcome to follow my wechat official account Echeverra to learn and make progress together! Uncertain when there are resources and welfare oh!