[Last procedure check : 2020-07-13 ]
I re-write the procedure since there are many questions about linux install procedure.
Many of them are no more applicable today and the getmangos.sh script needs rework as I write this article.
I am assuming you are running your server on a Linux Operating system with Ubuntu Server 18.04 flavor.
Your OS should be up to date. If not, log in as root and run :
apt update && apt upgrade
PART 1 : Configuring the environment
This tuto will use the MaNGOS zero repo URL but it is replicable with all of our cores repos. Just change the git repo URL and you will be fine.
> Creating system user
Be sure you have created a Linux user for your server, since it is not a good idea to run it as root for obvious security reasons.
We will then assume you have created a mangos linux user using the command :
To be more handy you can add this user to the sudoers in order to be able to run administrative commands.
usermod -aG sudo mangos
After this point, be sure to be logged-in as mangos Linux user. We do not need root account anymore (or perhaps once or twice.. but..never mind ! do not use root when not needed)
> Installing useful programs
MaNGOS requires some libraries to be built and to run properly.
We also need some programs to run further commands or simply to handle some scripts which are in the repo (e.g : python scripts O_o)
apt install git make cmake libssl-dev libbz2-dev build-essential default-libmysqlclient-dev libace-6.4.5 libace-dev python
> Preparing your system folders
A good practice is to separate locations for the needs :
- sources, db sql files and build folder under the mangos system user : /home/mangos/
- binaries, confs, logs, gamedata in /opt/
Thus you can create the folders when logged-in as mangos system user :
Then the /opt/ folder is only accessible to root so you need to use sudo and impersonate root to make things there.
The aim to to create a fodler using the root account then giving the good rights to be able to use it with the mangos system user.
The opt folder will a have a wow subfolder in which the mangos folder will be. It would let you install other cores if you want to (Trinitycore, Cmangos etc..) all should be installed in /opt.
chown -R mangos:root wow
chmod g+s wow
Now you will have a wow folder in /opt/ that will be writable by the mangos system user.
Create all necessary useful folders to handle future files using mangos system user :
cd /opt mkdir wow/install && mkdir wow/install/mangos && mkdir wow/install/mangos/bin && mkdir wow/install/mangos/bin/logs && mkdir wow/install/mangos/conf cd /opt/wow && mkdir gamedata && mkdir gamedata/1.12 && mkdir gamedata/1.12/mangos
> Getting Game data
Since MaNGOS is an educationnal project we will not redistribute exctracted game data.
In order to be able to run your server, you will need to extract these data from your game folder using the extractor programs that are built when you build the project.
To run the server the best way, you will have to extract :
- vmaps (takes a long time)
- mmaps (takes a long time)
Please remind to put all extracted data on the folders you pre-created on previous steps.
If you work with a VM you can use Linux extractors against a shared game folder betwwen your PC and the Linux VM, or if you have the Game folder on your server, you will have to use extractors in this folder.
More information on this topic :
PART 2 : Getting the sources & Compiling the core
Note that we always use the mangos system user.
Get into your source folder :
Retrieve the sources (WARNING do not forget to get them recusrsively !!) :
git clone https://github.com/mangoszero/server.git . --recursive --depth=1
Well, that good now we are going to build the solution.
/!\ WARNING ABOUT ACE DEPENDENCIES /!\
It is possible that the build fails due to he ACE linked sources in the "dep" folder. It is related to a bug between Linux build and Windows build.
The main "server" repository is set to refer to a speficif commit that allows by default a correct build on Windows. If you are on Linux you will probably have to manuall pull & checkout the "dep" folder (wich is a git submodule) :
git checkout master
Keep in mind that this example show a default build. You can tweak teh buidl option in cmake to build or not some parts of the software.
cmake ../sources/ -DCMAKE_INSTALL_PREFIX=/opt/wow/install/mangos -DCONF_INSTALL_DIR=/opt/wow/install/mangos/conf
When it's finished, depending on the number of your cores you will adapt the following make command :
make -j<NbCores> (e.g : for an intel i7 octocore you can tupe 'make -j8')
The build process should begin, and when it's finished, you will have to install the built binaries :
After that, all binaries and default conf files woudl have been copied to their destination folders which you have set in the previous cmake command.
PART 3 : Installing MySQL
First things first : you have to install MySQL server.
With Ubuntu Server 18.04 the reference MySQL version is 5.7.30 (this statement is valid at the date when this guide is written, it can evolve in the future).
To install mysql-server :
sudo apt install mysql-server
After installation, you may wonder : "Why the program did not ask me for a root password ?".
Well, on new MySQL versions, the default auth protocol is set to "auth_socket" but all our software will use a password to connect to the database.
Don(t worry, we are going to create a user that would be able to authenticate with standard credentials :
Now you are logged-in to mysql command prompt with the root account. you will notice no password was asked to you because roto user uses auth_socket protocol to authenticate.
Now you are going to create the MySQL mangos user :
CREATE USER 'mangos'@'localhost' IDENTIFIED BY 'mangos';
GRANT ALL PRIVILEGES ON *.* TO 'mangos'@'localhost' WITH GRANT OPTION;
The "WITH GRANT OPTION" is not mandatory but can be useful for future use if you want to administer other users with this mangos account.
Then leave MySQL command prompt and root shell :
PART 4 : Database Setup
> Main databases (auth, characters, world)
You first have to clone the database repo in the db folder :
git clone https://github.com/mangoszero/database.git . --recursive --depth=1
You will be prooted a screen with several questions :
You will also be prompted to determine your dabases names.
A good practice is to set the realm db name to : mangos_auth, and also to suffix all others db names with the core versions you are running (e.g characters db for mangos zero : mangos_characters0 , world db : mangos_world0 )
Note : you need only 1 realm database if you run several cores (mangos zero, mangos one etc..) on teh same server, BUt you will need 2 db (characters and world) for each core you run.
> Apply database updates
On a fresh install, World updates should also be applied.
In order to see if it is Ok, check on the World db (the process is the same for other databases) : connect to mysql using mangos user :
mysql -u mangos -pmangos mangos_world0
SELECT * FROM db_version ORDER BY VERSION DESC, structure DESC, content DESC LIMIT 0,1;
If the return show you the same version that the most recent file in the World/Updates/Rel21 folder. You are OK.
The version number alwas increase so it will be easy to determien if your version/structure/content is ok or not.
If not, then go to the World update folder (World/Updates/Rel21) and apply missing updates to the databases.
mysql -u mangos -pmangos mangos_world0 < nameOfUpdateSQlFile.sql
In case you run a non english speaking server, you can apply translation fiels to the world database.
You will find the correct sql files to apply in the Translations folder :
Since I cannot ensure the Linux scripts are working, here is how to do manually : Apply the 3 first .sql files in teh folder :
mysql -u mangos -pmangos mangos_world0 < 1_LocaleTablePrepare.sql mysql -u mangos -pmangos mangos_world0 < 2_Add_NewLocalisationFields.sql mysql -u mangos -pmangos mangos_world0 < 3_InitialSaveEnglish.sql
Of course you will have to replace the db name "mangos_world0" with your db name etc... if you have changed default db names and user and password
You will need to go to the translation folder of the desired language (e.g for French language ) :
The more easy solution would be to compile all files in one and import it
cat *.sql > full.sql
mysql -u mangos -pmangos mangos_world0 < full.sql
There, your translations should be applied.
PART 5 : Configuring *.conf files for executables
Go to the conf folder an create a copy of each .dist file :
cp realmd.conf.dist realmd.conf && cp mangosd.conf.dist mangosd.conf
Change database connection information in each file in order to allow your binaries to connect to the database.
Update your game data path in mangosd.conf too.
Update the logs folder to "logs" value (relative to binary)
A lot of behaviours can be configured in these files. Please consider studying it carefully.
PART 6 : Auto-restarting
When operating a game server it is nice to use an auto-restarter.
Otherwise, you will have to keep up 2 terminals for realmd and mangosd.
That can be really annoying because daemons would be killed after terminal exit.
Read this article to know how to use a restarter on Linux operating systems :
PART 7 : Final comments
> Nice to have
When your system is running, you could perhaps check :
- Do you have a DB backup system ? You can easily put one in place with a CRON job
- Do you have a backup system for your conf files ?
- Do you have a flushing system for the server log files if you keep them timestamped ?
> About errors at core start-up
You can have some DB errors at startup like this one :
It means you have applied DB updates beyond core expectation but since it is only content related, it is not a big issue.
The core would not start id the version or structure is different, but the core can start with a content mismatch.
> How to first connect whith default accounts ?
If you have any questions - please ak on the forum on on Discord when anybody is connected