JoaoZanetti

[Tuto] MTA Server on CentOS 7 with NGINX

Recommended Posts

Spoiler

This tutorial works with CentOS 6, but you will need to install another version of EPEL and change ports using iptables.

This tutorial will guide you to install MTA-Server 64 bits and NGINX as external web server. What is NGINX? Is a high performance web server, it can be used to make players download your server at full available link speed with a high compression rate.

Droplet used:

512MB Ram

1vCore

100/100 Uplink

Centos 7.3.1611 x64

Requirements: 

Root permissions.

Here is the resources used in IDLE (6 hours graph). 

Spoiler

rHVWPj0.png

1 - Lets prepare our system!

Change to root user.

$ sudo su

We need to update our distro, we want the latest packages.

$ yum -y update

Now we will install some packages that we will use along this tutorial (screen to manage screens, unzip to .zip and EPEL for extra RHEL packages).

$ yum -y install screen

$ yum -y install unzip

$ wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

$ rpm --install --nosignature epel-release-latest-7.noarch.rpm

Start your firewall (You can check firewall status with service firewalld status).

$ service firewalld start

Lets open just ports that we use on MTA and NGINX. 22126 for MTA Query list, 22003 for MTA Server, 22005 for HTTP files and 20080 for NGINX server.

$ firewall-cmd --permanent --zone=public --add-port=22126/udp
$ firewall-cmd --permanent --zone=public --add-port=22003/udp
$ firewall-cmd --permanent --zone=public --add-port=22005/tcp
$ firewall-cmd --permanent --zone=public --add-port=20080/tcp

You should see "success" at the end of each command from firewall

Now we will reload firewall to make active our new rules.

firewall-cmd --reload

2 - Setting up MTA Server.

Now we will download all necessaries files to start our MTA Server.

Navigate to /home and create a directory called MTA.

$ cd /home
$ mkdir MTA
$ cd MTA

Download all files (Server, base config and resources).

Extract everything.

$ tar -xvf multitheftauto_linux_x64.tar.gz
$ tar -xvf baseconfig.tar.gz
$ unzip mtasa-resources-latest.zip

Rename multitheftauto_linux_x64 to server.

$ mv multitheftauto_linux_x64 server

Now we will move our baseconfig files to server folder and remove old files.

$ cd baseconfig
$ mv * ../server/mods/deathmatch
$ cd ..
$ rm baseconfig -f -r
$ rm baseconfig.tar.gz -f

Now we will do the same thing as we did above, but with our resources files, just create folder, and move everything.

$ mkdir server/mods/deathmatch/resources
$ mv -t server/mods/deathmatch/resources [admin] [editor] [gameplay] [gamemodes] [managers] [web]

Ok, now that we finished with server files, we will move our server folder to / and remove MTA folder (MTA folder is inside /home directory).

$ mv server /
$ cd ..
$ rm * -f -r

We need to set 777 permission to mta-server64 bin file.

$ cd /server
$ chmod -R 777 mta-server64

Now we will create a screen called "server-screen" and start our server (Just for test).

screen -S server-screen

$ ./mta-server64

We expect to see a message like this: Server started and is ready to accept connections!

Now that everything is working we will stop MTA server and minimize our screen.

CTRL + c
$ clear
CTRL a + CTRL d

3 - The fun part.

Lets install NGINX and create a server file. (NGINX uses modular server files).

$ yum -y install nginx
$ service nginx stop
$ cd /etc/nginx/conf.d
$ vi mta-server.conf

Lets insert some lines of code inside our .conf file. Don't break the indentation of the file. (Use INSERT in your keyboard to insert files and not replace)

server {
  listen 20080;
  root /server/mods/deathmatch/resource-cache/http-client-files;
  server_name localhost;
  access_log off;
}

Save and exit.

Press ESC
Press :
Type wq and hit enter

Now we will change our global NGINX server configs.

$ vi /etc/nginx/nginx.conf

On the top of the file put this:

worker_rlimit_nofile 5000;

Increase worker_connections 1024 to 5000

worker_connections 5000; 

Below access_log /var/log/nginx/access.log main; insert this lines:

gzip on;
gzip_types *;
We don't want to use NGINX as public web server, so lets change the default port.
Change: listen 80 default_server; and listen [::]:80 default_server; to
listen 8081 default_server;
listen [::]:8081 default_server;

The top of your config file need to look like this: 

Spoiler

FslvLZq.png

Start your NGINX server.

$ service nginx start

Test NGINX config.

If you open this address and download a file, MTA Server block is ok.

http://YOUR_SERVER_IP:20080/admin/client/admin_ACL.lua

To test compression, navigate to:

And use this URL:

http://YOUR_SERVER_IP:20080/admin/client/admin_ACL.lua

4 - Change MTA config file.

Now we will point our download URL to NGINX URL.

$ cd /

$ vi /server/mods/deathmatch/mtaserver.conf

Change <httpdownloadurl></httpdownloadurl> to:

<httpdownloadurl>http://YOUR_SERVER_IP:20080</httpdownloadurl>

5 - Starting MTA Server.

Resume screen.

$ screen -r server-screen

Start MTA Server.

./mta-server64

Minimize screen.

CTRL a + CTRL d

Its done, now your server is ready to accept connections and download all mods with fast speed.

Useful links:

 

 

 

Edited by JoaoZanetti
  • Like 4

Share this post


Link to post
vi /etc/nginx/nginx.conf

i think it too difficult for newbie.

 

i suggest install and use nano.

Edited by Disinterpreter

Share this post


Link to post
5 hours ago, Disinterpreter said:

vi /etc/nginx/nginx.conf

i think it too difficult for newbie.

 

i suggest install and use nano.

It's a good alternative. Another option: connect to SFTP and edit with File Zilla.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.