Jump to content

[Tuto] MTA Server on CentOS 7 with NGINX

Recommended Posts


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


100/100 Uplink

Centos 7.3.1611 x64


Root permissions.

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



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

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: 



Start your NGINX server.

$ service nginx start

Test NGINX config.

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


To test compression, navigate to:

And use this URL:


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:


5 - Starting MTA Server.

Resume screen.

$ screen -r server-screen

Start MTA Server.


Minimize screen.


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

Useful links:




Edited by JoaoZanetti
  • Like 4
Link to post
  • 1 year later...
17 hours ago, Psychotic_OZ said:

Correct me if i'm wrong but isn't it bad practice to start a gaming server as root? I've always started a game server as a user because if there is an exploit or something they not only can destroy your game server but your entire server itself.

To install some packages and edit firewall you need to have root permissions. But yeah, you can run your server without root privileges, its better if you keep minimum needed permissions.

Link to post
  • 1 year later...
  • 2 months later...
  • 4 weeks later...
On 22/02/2020 at 06:46, KINGKHAN said:

What about opening ports problem in ogp panel ,Linux vps centos?

I don't think OGP has a built-in feature to open ports. I never used OGP but i think you just need to open ports using native CentOS firewall.

Nginx port to download files
firewall-cmd --zone=public --add-port=20080/tcp --permanent

Download files
firewall-cmd --zone=public --add-port=22005/tcp --permanent

Join port
firewall-cmd --zone=public --add-port=22003/udp --permanent

Browse port
firewall-cmd --zone=public --add-port=22126/udp --permanent

Save configs
firewall-cmd --reload

Edited by JoaoZanetti
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.

  • Create New...