Jump to content

[Wiki] Compiling on Linux, complete beginner's guide


disintegore

Recommended Posts

This guide is for Debian-based distributions. It can be used as a reference for other distros but you need to go the extra mile yourself. The only difference should be how you get the required packages.

Intro: This guide is for those who would prefer to use the superior stability and resource management of Linux, or simply cannot use Windows for various reasons. While the current Linux sticky guide is a great source of information, there are a few nuances it fails to mentions and the aim of this thread is to address those. This guide will be largely similar, but will hopefully be more up to date with a few of the changes in the repositories. This guide is written with the complete beginner in mind, and as such might state the obvious on occasion.

1. Fetching the dependencies.

Mangos needs a number of applications to be able to compile and run properly. Getting those is easy with a simple application of the aptitude package manager.

sudo apt-get install build-essential gcc g++ automake git-core autoconf make patch libmysql++-dev mysql-server libtool libssl-dev grep binutils zlibc libc6 libbz2-dev cmake

mysql-server will run a short and simple installation daemon of its own and ask for a root password among other things. Make sure to remember it.

If you are unable to download some of these packages, try sudo apt-get update to bring aptitude's repositories up to date. If it still fails after that, it is possible that one of these packages is missing for a variety of reasons. You can try apt-cache search package (note that apt-cache does not require super user privileges) and look for those packages by name.

2. The mangos user (Optional)

You might want to create a new user with which to run your mangos server. It is not advised to run the server (and a lot of other things) as root.

adduser mangos

And follow the prompts. A quicker, less verbose way to do this is

useradd mangos
passwd mangos

This will create a new user with the name mangos and with owner privileges on /home/mangos by default. This is where I run my server, because the account is not used for anything else. If you would prefer your private server to run in another folder, make sure to give your mangos user owner privileges to that folder.

chown /your/folder/here mangos

And when you're done setting that up, switch to the user

su mangos

3. Getting the Mangos source

There's a lot of mangos versions to choose from. You can find them here: http://getmangos.eu/bb/topic/206/mangos-sourceproject-list/

This guide will use the master mangos project (Cataclysm) and if you're looking to host another xpac, simply change the github links to reflect that.

Make sure you're in the right folder and then fetch the server, database and ScriptDev2 sources. ScriptDev2 needs to be in server/src/bindings

git clone git://github.com/mangos/server.git
git clone git://github.com/mangos/database.git
cd server/src/bindings
git clone git://github.com/mangos/scripts.git

4. Compiling the server source

Patch ScriptDev2 into your server

git apply src/bindings/scripts/patches/MaNGOS-*-ScriptDev2.patch

And if this fails, edit the server/src/bindings/CMakeLists.txt manually and find this line

#add_subdirectory(universal)

Un-comment it, and change "universal" to "scripts" so that it looks like this:

add_subdirectory(scripts)

and save the file. CMake will then know to include ScriptDev2.

Then go back to your server folder, create a new directory in which to build the project, and navigate to that. Note that ~/ is a relative path to the current user's home directory.

cd ~/server
mkdir build
cd build

Build the server, specifying where it will be installed to after compiling. This can take about 5 minutes. Note that ".." is a constant for the parent directory. Doing "cmake .." in /home/mangos/server/build is the same as doing "cmake /home/mangos/server". The -DPREFIX= argument specifies where the server will be installed. Change it accordingly.

cmake .. -DPREFIX=/home/mangos/
make
make install

5. Extracting the game assets

In your server's root directory (in this case, /home/mangos/), create a folder for your data files. It can be named whatever you want, but you'll need to remember that folder name for later. I use "data". Make your logs folder while you're at it too.

mkdir data
mkdir logs

And then extract the data files from Blizzard's mpq archives. Make sure you the client's version matches your server's.

On Linux

(I have not done this process under linux myself. Correct me if I got it wrong.)

If your appropriate WoW client folder is on your Linux system, copy the items in server/contrib/extractor_binary to your WoW client, give permissions for the bash scripts to run and execute them. Once that's done,

cp server/contrib/extractor_binary/* /your/wow/client/location/
cd /your/wow/client/location
chmod +x *.sh
./ExtractResources.sh
mv  dbc /home/mangos/data/dbc
mv maps /home/mangos/data/maps
mv vmaps /home/mangos/data/vmaps

On Windows

Move the files in server/contrib/extractor_binary to your WoW client's location on your Windows filesystem.

Click start, type cmd in the search bar and do shift+ctrl+enter to run it as administrator. Navigate to your WoW client's location and do the following.

ad.exe
vmapExtractor.exe
vmap_assembler.exe buildings vmaps

Move the dbc, maps and vmaps folders to your server's data folder on your linux filesystem.

6. SQL batch magic

Mangos uses SQL databases to store just about a million things. It also comes with a number of batch scripts to build the required databases for you. You will be using the "mysql -u root -p" command a lot. This command essentially lets you run mysql queries from the command line. The -u parameter specifies which user to apply the query as (in this case, root), and the -p parameter is necessary if your user has a password. Keep in mind -p by itself works and you don't need to do "mysql -u root -p qwerty123" or whatever your password is!

Note that these .sql files would probably work with a gui mysql application such as phpmyadmin or navicat.

Start with the files in server/sql. This will create the three databases Mangos uses and build the table structures.

cd /home/mangos/server/sql
mysql -u root -p < create_mysql.sql
mysql -u root -p realmd < realmd.sql
mysql -u root -p characters < characters.sql
mysql -u root -p mangos < mangos.sql

ScriptDev2 also needs its own database.

cd /home/mangos/server/src/bindings/scripts/sql
mysql -u root -p < scriptdev2_create_database.sql
mysql -u root -p scriptdev2 < scriptdev2_create_structure_mysql.sql
mysql -u root -p scriptdev2 < scriptdev2_script_full.sql

Now you need to populate the databases. This includes quests, dialog, etc. There is a script that will compile a massive number of sql files into one big sql batch you can apply at once.

cd /home/mangos/database
chmod +x make_full_db.sh
./make_full_db.sh
mysql -u root -p mangos < full_db.sql

Depending on when you are reading this, the server might need a few "updates" applied to it without which the world server will refuse to run. I needed to do this with mangoszero but not mangostwo. Do this step if you get an error at runtime.

cd /home/mangos/server/sql/updates
mysql -u root -p mangos < blahblahblah_mangos_whatever.sql
Repeat for every similar .sql file in the folder. Mangos might not be the appropriate database for this every time.

7. Configuration

To configure your server you will need to edit a few text files, and edit a few entries in your SQL databases. I recommend you use a graphical SQL client such as phpmyadmin if your computer runs apache2, navicat for windows or squirrel sql for linux. First, copy the default configuration files created by your server and edit them as necessary.

cd /home/mangos/etc
cp realmd.conf.dist realmd.conf
cp mangosd.conf.dist mangosd.conf
cp scriptdev2.conf.dist scriptdev2.conf 

The minimal effort required run a function server is to edit the following lines in mangosd.conf

DataDir = "/home/mangos/data"
LogsDir = "/home/mangos/logs"

Of course you should go over all three .conf files and change what you want. Comments can tell you much more than I can.

Now, point your SQL client to your SQL server and select the realmd database. Then select the realmlist table. There should already be an entry there. Edit the name, address and port fields as necessary. The reason why 127.0.0.1 doesn't work is because that address is what the CLIENT will try to connect to, and thus will try to probe itself.

8. Running the server and creating an Admin account

Your binaries will be located in the bin folder of your server's root directory. Those are mangosd realmd.

mangosd is the world server and realmd is the realm server. Typically you only need one instance of realmd running, and one mangosd instance for every realm you want in your realmlist.

If you want to run these servers using screen, use these scripts, courtesy of krampf. Make sure to chmod +x them.

#!/bin/sh
cd /home/mangos/bin
screen -A -m -d -S mangosworld ./mangosd

#!/bin/sh
cd /home/mangos/bin
screen -A -m -d -S mangosrealm ./realmd

Make sure to run ./mangosd normally once, because you'll need to create your account and give it admin privileges. Run these commands in the mangos command shell.

account create "username" "password"
account set gmlevel "username" 3

And here you go! A functional, partially scripted private server for you to mess around with. Have fun.

Link to comment
Share on other sites

nice guide but change this

cd /home/mangos/server/src/bindings/scripts/sql
mysql -u root < scriptdev2_create_database.sql
mysql -u root scriptdev2 < scriptdev2_create_structure_mysql.sql
mysql -u root scriptdev2 < scriptdev2_script_full.sql

to

cd /home/mangos/server/src/bindings/scripts/sql
mysql -u root -p < scriptdev2_create_database.sql
mysql -u root -p scriptdev2 < scriptdev2_create_structure_mysql.sql
mysql -u root -p scriptdev2 < scriptdev2_script_full.sql

its easyer for cp users :P

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

Very good tutorial!

And a German Translation (very brave as I don't speak german !!): https://github.com/mangoswiki/wiki/wiki/Debianinstall%20german

Yes, very brave. It was terrible german :lol: , but should be correct and understandable now.

It seems that a few details (at least I needed them) were missing in this tutorial, @disintegore do you mind if I add them by myself to your text in the wiki (my german translation is still 1:1 your text)?

Link to comment
Share on other sites

Very good tutorial!

Yes, very brave. It was terrible german :lol: , but should be correct and understandable now.

That's what my German Teacher used to say all the time :P

- Thanks for the updates

If you fancy volunteering to be part of the new Wiki team, please let me know and i'll add you to the Wiki Team :D

Link to comment
Share on other sites

That's what my German Teacher used to say all the time

Oh, sorry! I Didn't want to flame you! I thought you were using translation software!

If you fancy volunteering to be part of the new Wiki team, please let me know and i'll add you to the Wiki Team

Yes, that would be cool, even though my english isn't that great...

Link to comment
Share on other sites

That's what my German Teacher used to say all the time

Oh, sorry! I Didn't want to flame you! I thought you were using translation software!

If you fancy volunteering to be part of the new Wiki team, please let me know and i'll add you to the Wiki Team

Yes, that would be cool, even though my english isn't that great...

I did not consider it a flame, my language skills are rubbish.... i'm sure your English is much better than my German !

I will pm you shortly and explain what i'm planning/working on and add you to the team :D

Link to comment
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use