Credits to Psykko for this awesome guide (tumbs up)



WELCOME TO THIS TUTORIAL
brought to you by Psykko

______________________________________________
Quote Originally Posted by Psykko
Greetings, i decided to publish this small tutorial for all the people without alot Linux knowledge. This Tutorial contains reading and dragons, but it also includes anything you need for a save and successful start on your Linux System. People with Knowledge can surely skip a few steps, this is written for total beginners. Following i list a register of things within this Tutorial. Should we start?

Tutorial overview:
1. Getting a Linux Machine with a free month (optional)
1.1 Gathering Software for Linux Communication
1.2 Setup Sessions
___
2. Linux System Setup
2.1 Installation of needed Packages
2.2 SSH Port
2.3 MySQL Port
2.4 Setup Git
2.5 Setup User
___
3. Setup TrinityCore
3.1 Clone the newest TrinityCore
3.2 Merge with ElunaLuaEngine (optional)
3.3 Cmake
3.4 Compiling and Installing
3.5 Configuration
3.6 Setup of iptables
___
4. Database Setup
4.1 User and Database Setup
4.2 Base Database Installation
4.3 WorldDb and Updates
4.4 Realmlist
___
5. Server Startup Prepare
5.1 Adding an Restarter
5.2 Starting Auth and World with Screen
___
6. End

______________________________________________

1. Getting a Linux Machine with a free month (optional)

Im showing you here how you can get a neat vps for small money inculsive a free month of payment.
This VPS is a great choise for starting a Server.



Click at the Image above to spectate the VPS.
______________________________________________

1.1 Gathering Software for Linux Communication

Its up to you what kind of Program you are going to use to communicate with your VPS/Dedicated Server. In this Tutorial I will be using PuTTy and WinSCP, but i will list some other Programs too.

We are in need of an Program which allows us to open an SSH tunnel between your Computer and your VPS, therefore im using PuTTy.

And we will also need an File Transfer Protocol Program for Filetransfer between your Computer and your VPS, therefore im using WinSCP since it has many functions and a nice interface.

PuTTy - Click to Download the Installer
WinSCP - Click to Download the Installer

FileZilla - Click to Download the Installer
CyberDuck - Click to Download the Installer
BitKinex - Click to Download the Installer

I would really suggest you to use PuTTy and WinSCP since they have a good integration with each other.

So we going to install PuTTy by starting the downloaded Installer and following the Steps.



Now we are going to install WinSCP by starting the Installer and follow the Steps.





Congratulation, you have successfully installed everything you need to work with your VPS!

______________________________________________

1.2 Setup Sessions

First of all, we are going to open PuTTy, you should find something like this


Fill the Informations like in the Layout above.
(following is an example of mine)



So far PuTTy is finished.

Lets open up WinSCP and you should find something like this.

Fill the Informations like in the Layout above.
(following is an example of mine)


Choose again a Name for the Session, i entered My VPS instead of [email protected] and mark the Save Password Button. Ok
(above is an example of mine)

You are now able to access PuTTy and WinSCP by doubleclicking the Session Name.

______________________________________________

2. Linux System Setup

We are now going to open our PuTTy Session.
(note: any first connection to a VPS causes an PuTTy Security Alert, dont get in panic, hit the Yes Button.)
After that, login with the root user to your Linux System. Take the Password from the Email/Userpanel of your Provider.
(note: the passwords never getting shown in PuTTy. You can paste into PuTTy per rightclick into the black field)

We are now logged into our Linux System. Im using Debian 7 minimal 64bit for this Tutorial. Since im running 64bit, i will need to download 32bit Libaries too, so im in need of adding the 32bit architecture to the System for better integration. So we are going to enter dpkg --add-architecture i386 into PuTTy and run it.
After that happened, we are going to run apt-get update && apt-get upgrade into PuTTy and run it, to catch the updates for the previous set architecture

Now simply run apt-get install ia32-libs

Ubuntu Users need this:




______________________________________________

2.1 Installation of needed Packages

So far our Linux System does not contain any Software exept you are using LAMP (recommented if you are going to host a website too). We are going to install all needed Packages we need to generate, compile and install our TrinityCore containing MySQL (not git, git is getting installed seperate sooner.)
(note: skip this if you have them installed already.)
Here is a list of the needed Packages:


So we are going to run apt-get install -y sudo screen libtool gcc g++ mysql-server mysql-client libmysqlclient-dev libmysql++-dev make cmake p7zip-full libncurses5-dev zlib1g-dev libbz2-dev gdb nano openssl libssl-dev libreadline6-dev libboost-dev libboost-thread-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-iostreams-dev build-essential autoconf into PuTTy and run it.

It will start reading and downloading the packages and installing them... So far you dont have an mysql-server installed,you are going to get in contact with this screen.

simply enter an password for the user "root" for MySQL
you need to re-enter it.

______________________________________________

2.2 SSH Port

Before it comes to Compiling and all that stuff, we need to do some changes for your own security. We are going to change the SSH port which is currently 22 which is default for Linux.

We are going to enter nano /etc/ssh/sshd_config into PuTTy
(note: you can only move per cross-buttons on your keyboard in PuTTy. To enter Numbers, dont use the Numblock.)
Something like this should appear, we are going to change the part
Port 22 to something else, you can use any number within this range 49152-65535.
I am used to 53155.

Press CTRL+X to exit nano. Now you are getting asked to save changes.


Enter Y to continue and again press <Enter> after that.


______________________________________________

2.3 MySQL Port

[COLOR="#B22222"]After we have changed the SSH Port, we are now going to change the MySQL Port too. Default: 3306
We are going to enter nano /etc/mysql/my.cnf into PuTTy. You should find something like this:



Change the Port from 3306 at both locations to any number within this range 49152-65535 and put a single # infront of bind-address = 127.0.01 like in the Layout above.

I am used to 53165. Press CTRL+X to exit nano. Now you are getting asked to save changes.
Enter Y to continue and again press <Enter> after that.
Now we need to change the SSH Port in PuTTy and WinSCP from 22 to our new Port.



2.4 Setup Git

After we have changed the SSH and MySQL Port, we can Setup Git and also the last step before we are going to add the User for Compiling and Running the Server.

So we enter apt-get install -y git into PuTTy



After that, we need to do some Git Configuration. We add an Username and Email for this Git per entering the following into PuTTy

Replace the lightblue stuff with your infos (does not require an github user)

git config --global user.name "Enter Username"
git config --global user.email "Enter EMail Address"

______________________________________________

2.5 Setup User

The last Step before the generating and compiling begins is adding a new user for all of this. We have neither an existing one, netiher an folder where to actually start working. So we make use of the command useradd and add a few parameters.

-m to create the homedirectory
-s bash
(note: to find out what to enter here, you need to enter which bash into PuTTy and copy the path)
-d to set homedirectory on login

REPLACE THE LIGHTBLUE STUFF WITH YOUR INFO

useradd -m -s /bin/bash -d /username/ username

After that, we setting a password for the User we just created, in my case it was acweb. We run passwd username


______________________________________________

3 Setup TrinityCore

So we are now going to reboot our system once since we have done alot of installations and changes of ports. So we run reboot into PuTTy and close it, waiting till the VPS comes back up.


Once the VPS is back available, open PuTTy and login with the new created user.


______________________________________________

3.1 Clone the newest TrinityCore

So we are now logged in with our server-user. Let us begin with downloading the newest 3.3.5a TrinityCore. We Execute git clone -b3.3.5 git://github.com/TrinityCore/TrinityCore.git src into PuTTy.


______________________________________________


3.2 Merge with ElunaLuaEngine (optional)

We do now own the Newest TrinityCore 3.3.5a Sourcecode. If you want to use Lua within your TrinityCore, we need to execute cd src into PuTTy to enter the src folder where all the trinitycore files are placed and then we need to run
git pull --recurse-submodules git://github.com/ElunaLuaEngine/ElunaTrinityWotlk.git

Something like this should come up

Go all the way down with your arrow down button and enter an message, im used to acwebtutorial


Press CTRL+X to exit. Now you are getting asked to save changes.
Enter Y to continue and again press <Enter> after that.

Something like that should you see now after its finished


Now we only run git submodule init && git submodule update into PuTTy and we are finished with merging.


______________________________________________

3.3 Cmake

Now we can run cmake to run the generation of the compileable files.
We are visiting back our homedirectory per running cd per PuTTy
Now we are going to create a new directory for our cmake step. We are going to run mkdir cmake in PuTTy.
To Check if the Directory was created, run ls and seek out for it.
Now we are going to enter the cmake folder by entering cd cmake into PuTTy.

To run cmake, simply enter cmake into PuTTy to run it, but we need to add a few additional parameters.
I am going to use the followings:
source/path
-DCMAKE_INSTALL_PREFIX
-DTOOLS
-DUSE_COREPCH
-DUSE_SCRIPTPCH

For those who need Warnings and Debug also need those:
-DWITH_WARNINGS
-DWITH_COREDEBUG


REPLACE THE LIGHTBLUE STUFF WITH YOUR INFO

For example (normal)

cmake ../src -DCMAKE_INSTALL_PREFIX=/username/run -DTOOLS=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1

For example (debug)

cmake ../src -DCMAKE_INSTALL_PREFIX=/username/run -DTOOLS=0 -DUSE_COREPCH=1 -DUSE_SCRIPTPCH=1 -DWITH_WARNINGS=1 -DWITH_COREDEBUG=1
You should see something like this now


______________________________________________

3.4 Compiling and Installing

Our TrinityCore is now ready to be compiled. We can do that per using the command make and the install command

Depending on how much CPU Cores you have, you can add -j X to the make command as parameter.
For Example in my case:

make -j 6 && make install
It should start compiling. Now you wait till it reached 100% and till it has installed the server binaries to the install_prefix we set before in cmake.


Depending on your Hosting Specs, it can take a while since the Precompiled Headers are included, any further on re-compile for example when adding a Script will be alot faster.

______________________________________________

3.5 Configuration

Our TrinityCore is now Compiled and Installed, we can now move to the configs folder and remove the .dist per again visit the homedirectory per cd and then execute cd /run/etc in PuTTy.


After that we are going to run the following 2 commands:
cp authserver.conf.dist authserver.conf && cp worldserver.conf.dist worldserver.conf
rm authserver.conf.dist && rm worldserver.conf.dist


to copy the existing files without the .dist and delete the files with .dist after that.
as soon as we only have authserver.conf and worldserver.conf in our folder (check it per using ls) we need to give those files some permissions per running chmod 777 authserver.conf && chmod 777 worldserver.conf in PuTTy


Now we are going to Open WinSCP and Connect with the root user to the Linux System. Follow the path -> ../username/run/etc where the configs are placed.


Open them by Selecting both with your mouse and hit <Enter>

First thing we are going to change is the ListenPort and the PID File.
Choose any Port from 1-65500


The next thing is changing the MySQL Port from 3306 to our new Port.


Now we are going to open the worldserver.conf and also edit a few things first.
We are adding an external folder for dbc,maps,vmaps,mmaps for better overview of things.
We set binary folder to logfolder and change the MySQL and Worldserver Port (Choose any Port from 1-65500)
We also enable mmaps and pid for the worldserver, and disable updates





After that, go into your binary folder with cd ../bin and create a new folder called data per mkdir data in PuTTy.

Now we are going to enter the data folder with cd data and download the dbcs,maps,vmaps and mmaps with the following command

wget http://euve104411.serverprofi24.de/ac-tut/resources.zip (1000MB+)

Let it finish load. and after that extract the files with unzip resources.zip or unzip e resources.zip use (A)LWAYS on getting a request

The Stuff is Extracted from my Client and Compressed and Uploaded to the Tutorial VPS to be HTTP Downloaded by you.

After you extracted the stuff, we are going to remove the zip file again.

rm resources.zip

To see everything is alright, run ls into putty and look out that it looks like this:
( THERE ARE NOW A FEW MORE FOLDERS FROM UPDATE BUT OUTDATED IMAGE! )



______________________________________________

3.6 Setup of iptables

[COLOR="#B22222"]TrinityCore is now Configured and all ports are set. lets setup iptables and allow the ports we need.
We open another PuTTy Session and login with the root user and run apt-get install iptables, after that we forward all ports with this command.

iptables -A INPUT -i eth0 -p tcp -m tcp --dport PORTNUMBER -j ACCEPT

Run it multible times with your SSH, MySQL, AuthserverListen, WorldServer Port.

In my case

______________________________________________

4. Database Setup

So far we have anything done for a successfull serverstart, we only need to install the Database for that.

______________________________________________

4.1 User and Database Setup


So we are going to open PuTTy with the root user and run mysql -uroot -p after that we are going to enter the following to add an user to connect from our computer to the vps mysql service, simply replace the lightblue stuff with your infos. (copy the row's one by one, else it will create a user called enter a name)

create user 'enter a name'@'%' identified by 'enter a password';
grant all privileges on *.* to 'the username you choosed before'@'%' WITH GRANT OPTION;


For Example:



Press CTRL+C to exit MySQL.

then enter the following folder cd ../username/src/sql/create to setup the user for the configs and also create the databases auth, characters and world


now we run mysql -uroot -p < create_mysql.sql



______________________________________________

4.2 Base Database Installation

After that we are going to leave the create directory and move to the base directory per running cd ../base in PuTTy

Now we execute authdatabase to the db "auth" and characterdatabase to db "characters"

mysql -uroot -p auth < auth_database.sql
mysql -uroot -p characters < characters_database.sql

______________________________________________

4.3 WorldDb and Updates

Now we only need to download and install the newest TDB and apply the Updates and the setup is nearly finished!

run cd to visit your homedirectory as user root and move into the opt folder per cd ../opt
Now we download the TDB per wget https://github.com/TrinityCore/Trini..._2016_10_17.7z

Now we extract the file per 7z e TDB_full_335.62_2016_10_17.7z and execute the full-db sql file into our world db


mysql -uroot -p world < TDB_full_world_335.62_2016_10_17.sql
(note: dont panic, its not frozen or stuck, it just takes its time to finish batching in the whole database.)


When the database is finished with loading, you need to run cd ../username/src/contrib to reach the file merge_updates_unix.sh to save some time on the updates.

Now we give the file access to run per chmod 777 merge_updates_unix.sh

We need to add the new Path, since TC forgot to change it.. We going to type nano merge_updates_unix.sh and add "3.3.5" to the path.


after that we execute it with ./merge_updates_unix.sh, a new file should appear called "world_update.sql" which we are going to execute into the database with mysql -uroot -p world < world_update.sql


______________________________________________

4.4 Realmlist

Now we only need to edit the realmlist. For that we run as root user the following commands mysql -uroot -p after that we execute a query doing the job for us.. Simple Replace the Lightblue stuff with your infos and enter it into PuTTy
Code:
USE auth;
UPDATE realmlist SET name = "Ac-Web Tutorial", address = '85.25.46.60', port = '63125';

Press CTRL+C to exit MySQL.

______________________________________________

5. Server Startup Prepare

Now we only need to start the authserver and worldserver once to check everything is alright.
So we login with our user and run cd run/bin after the login
now we try to run the authserver per ./authserver

It was successfully! Press CTRL+C to exit the Authserver for now.

Now we try to run the worldserver per ./worldserver

It was successfully! Now we are going to create our admin account.

Type the following into PuTTy
account create name password
account set addon name 2


Press now CTRL+C to exit the Worldserver for now.

Openup PuTTy again and login with the root user and run the following command mysql -uroot -p
Once your logged into mysql, run the following query:
Code:
USE auth;
INSERT INTO rbac_account_permissions (accountId, permissionId, granted) VALUES ('1','192','1');

Now our Account has Administrator Access..

______________________________________________

5.1 Adding an Restarter

We switch back to our PuTTy Session with our sperate user or login with it and run cd /run/bin to get into the server-binary folder

Now we are going to add a small restarter script per nano restarter.sh and paste the following into it:
Code:
#!/bin/bash

while :; do
./worldserver
sleep 0
done
Press CTRL+X to exit nano. Now you are getting asked to save changes.
Enter Y to continue and again press <Enter> after that.

Now we grant the restarter permissions to be executed per chmod 7777 restarter.sh


______________________________________________

5.2 Starting Auth and World with Screen

Make sure you are in /username/run/bin.
Now to start the auth and restarter without having PuTTy open, we going to use screen

Run the following commands:
screen -AmdS auth ./authserver
screen -AmdS world ./restarter.sh


You can access any of those screens per
screen -r auth
screen -r world



to check if the binaries are actually started, run ps -fx and seek out for ./authserver and ./worldserver


Now we only need to set our Realmlist.

Code:
set realmlist your.ip.address.here:RealmPort

my case:

set realmlist euve104411.serverprofi24.de:1337


______________________________________________

Few parts (suggestions) by MyLilSuccy


Quote Originally Posted by MyLilSuccy
Section 5
Instead of forcing GM permissions onto the account via MySQL, just add the following to the Trinity account setup
Code:
account set gmlevel acweb 3 -1

The proper way to shutdown the server is to issue the command
Code:
server shutdown 0
The 0 here is a delay, in seconds, before the shutdown happens.

An exit code and a message can be given with this command as well (usefull for shutting down the server for maintenance). For example, to shutdown after 15 minutes with exit code 255, you can do
Code:
server shutdown 900 255 For routine maintenance
Players will see the message [SERVER] Shutdown in 15 Minute(s) - For routine maintenance
They will receive reminders every 15 seconds as well.

Section 5.1
The exit code from the shutdown command can be checked for in the restart script so as not to auto-restart for normal shutdowns. Here's my suggested changes for the worldserver restart script

Code:
#!/bin/bash

# Restart the worldserver on exit unless exit code 255 is returned
# Clean server shutdown can be done with
#       server shutdown <delay> 255 [message]
#           where <delay> is a time delay in seconds before server goes down.
#                 [message] is an option message sent to all players

RESTART=1
while [$RESTART -eq 1]; do
    ./worldserver
    if [$? -eq 255] then
        RESTART=0
    fi
    sleep 0
done

Section 5.2
Instead of screen, try using tmux. It is much more flexible. Check it out (https://tmux.github.io/)

End


› See More: Linux Tutorial for beginners - Setup your Linux and TrinityCore from scratch