Preamble
I try to keep this guide as up-to-date as possible although over time, some details may become outdated. If you find something has changed, please notify me and I will fix it as soon as possible. Please note this guide DOES NOT contain information for dealing with mmaps. I have not tried mmaps yet and they take hours (Can be even a day on slow computers) to extract.
A lot of guides I've read contain a whole lot of useless or overly technical information. This is not needed in any way shape or form. So here is a better guide. How to properly and easily download, compile and setup a MaNGOS server of any version using YTDB.
Why compile your own server? This way you know it is absolutely up-to-date, contains no malicious crap from little kiddies screwing around and will actually work.
Needed Tools
GIT Client
Visual Studio C++ Express 2010
MYSQL Community Server (I'll explain the installation later)
An SQL DB editor (I'll be using Navicat for MYSQL).
Downloading MaNGOS
Once you've installed all the programs mentioned in the above section, needed tools. Go ahead and open up GIT Bash (Not GIT GUI). First we need to change the directory. Type cd /c to change it's working directory to the root of your C: drive, otherwise it will download it all the way in your root user folder. Now we can download the latest MaNGOS. Type git clone git://github.com/mangostwo/server.git mangos. Let it finish and close GIT Bash. Your server should now be located in C:\mangos.
Downloading Scripts Library
NOTE: Some versions of the MaNGOS core have the scripts library already built in. If you do not have a C:\mangos\src\bindings folder, skip this step.
Do the same as you did for downloading MaNGOS but type git://github.com/mangostwo/scripts.git ScriptDev2
Compiling MaNGOS
Open C:\mangos\win\. Open mangosdVC100.sln in Visual Studio Express C++ 2010. Once it loads, go to Build>Configuration Manager now change the Active solution configuration to Release and the Active solution platform to Win32 and click Close. Now go to Build>Rebuild Solution. It will seem like it's doing nothing if you do not have the Output window enabled (Ctrl+Alt+O). It will take a while to compile.
Compiling ScriptDev2
STOP. Do not do continue until MaNGOS has finished compiling. If you continue on, your server will not work.
NOTE: Some versions of the MaNGOS core have the scripts library already built in. If you do not have a C:\mangos\src\bindings folder, skip this step.
Once MaNGOS has finished compiling, copy the your ScriptDev2 folder you downloaded to C:\mangos\src\bindings. This step is pretty much the same at compiling the core. Open scriptVC100.sln in the ScriptDev2 folder. Go to Build>Configuration Manager now change the Active solution configuration to Release and the Active solution platform to Win32 and click Close. Now go to Build>Rebuild Solution. This will also take a little while.
Setting Up MYSQL
This part is relatively easy. Install MYSQL, when it asks you about setting up an instance. Go to Standard Configuration then click Next. Make sure Include Bin Directory in Windows PATH is unchecked. Click Next. Set up your password. It doesn't matter what it is. Most people use root as their password and click Next and let it set itself up.
Setting up the Database
Open Navicat. Go to Connection>MYSQL. Type anything for Connection Name. Type localhost for Host Name/IP Address and 3306 for Port. Type root for User Name (MYSQL uses root for the root user) and whatever your password is. Click OK and connect to the SQL server over in the sidebar by double clicking the connection. Click on User and go to New User. For User Name type mangos, localhost for Host and mangos for the Password and click Save. Now your MaNGOS server can, by default settings, properly connect to the SQL server.
Creating Databases
Now right click on your SQL connection in the sidebar and click Execute SQL file and browse to C:\mangos\sql\. Open mangos.sql and click Start. Let it finish and click Close. Repeat that step with characters.sql and realmd.sql. Now we need to set up ScriptDev2's database. Do the same as before but browse to C:\mangos\src\bindings\scriptdev2\sql\ and open scriptdev2_create_database.sql, execute it and then run scriptdev2_create_structure.sql.
Populating Databases
Now that we have our databases set up. We need to populate them. There are different ways we can do this but for this we'll use the default YTDB database. Open up GIT Bash and do as before but type git clone git://github.com/mangostwo/database.git database. Now run install_Windows.bat and press Enter 3 times until it prompts you for your password. Type mangos and press Enter twice more and then type y and wait for it to finish. Now we need to add ScriptDev2's database. Open up Navicat and right click your mangos database (Not the connection) and click Execute SQL File. Browse to:
1a. If scripts are not built in: C:\mangos\src\bindings\scriptdev2\sql\ and execute mangos_scriptname_full.sql.
1b. If scripts are built in C:\mangos\sql\scripts_sql\ and execute mangos_scriptname_full.sql.
Now in the ScriptDev2 database, execute scriptdev2_script_full.sql. Now comes the most annoying part it my opinion. We need to update the databases. In Navicat, open up the mangos database and go to Tables and open the db_version table. The last field should say something like required_blahblah. Remember what it says. Now right click the database and click Execute SQL File and browse to C:\mangos\sql\updates\ find that file name that we needed to remember (Make sure names are assorted ascending), execute the next file. Make sure the next file says mangos and not realmd or character. Then execute the next file and so on and so forth until you are at the latest file. Look for the same table in both realmd and characters and do the same. Usually you wont need to update characters or realmd. Note if you do not do these steps, the server will not work.
Extracting DBC, Maps & VMaps
First browse to C:\mangos\contrib\extractor_binary\, if there are no executables in this folder, you will need to get the individual files from the other folder, as described below.
Browse to C:\mangos\contrib\extractor\release\ and copy ad.exe to your root World of Warcraft installation folder. Then go to c:\mangos\contrib\vmap_assembler\ and copy the files to your root World of Warcraft installation folder and do the same with c:\mangos\contrib\vmap_extractor\. Run ad.exe and makevmaps_SIMPLE.bat. Let them finish, it will take a while. Once done, go to C:\mangos\bin\Win32_release\ and make a new folder called Data. Copy the folders dbc, maps and vmaps from your World of Warcraft folder into there.
If ad.exe or the 3 files in \contrib\vmap_extract_assembler_bin\ are not there, scroll down to the Compiling Tools section to learn how to compile them.
Compiling MMaps
MMaps are not required but they make pathing a hell of a lot better but they do take a very long time to extract so if you have a slow computer, be prepared for extraction to take place overnight. I also wrote this based off of SkyFire's mmaps guide rather than MaNGOS but I am assuming it is exactly the same procedure so bear with me if I turn out to be wrong and as always, feel free to correct me if you know something is incorrect.
Browse to C:\mangos\server\contrib\mmap\win and into the folder that corresponds with your version of Visual Studio and run the project file and build it like you would anything else. MMap building requires you to first extract and compile your VMaps, so if you haven't done that yet, do it. After building the VMaps, you should have a folder called "buildings" in your root World of Warcraft folder. Take all the files from that folder (Not the folder itself, just the files in it) and move them into your VMaps folder and create a new folder inside the VMaps folder called mmaps. Move the compile mmap generator into the VMaps folder as well and run the MMap generator. This process will take a long time.
Configuring Your Server
Browse to \mangos\src\bindings\scriptdev2\ (Or \mangos\src\scripts\) and move scriptdev2.conf.dist.in to \mangos\bin\Win32_Release\. Now remove the .dist.in from mangosd.conf.dist.in and realmd.conf.dist.in and scriptdev2.conf.dist.in. Now open mangosd.conf, scroll down to DataDir = and type "./Data". Scroll down to BindIP = and type "127.0.0.1". LoginDatabaseInfo, WorldDatabaseInfo and CharacterDatabaseInfo should be correct by default if you followed this guide correctly.
You can also customize your server by editing values in mangosd.conf. Every value is explained within the configuration file. Most tutorials explain changes you need to make in the file, fortunately for you, if you followed this guide, you don't need to change anything as we set up the server so, by default settings, we would need to change very little.
Setting Up Your Client
Make sure first you have the proper version of World of Warcraft installed. Now go to \World of Warcraft\Data\enUS\ and open realmlist.wtf in Notepad and change set realmlist and set patchlist to 127.0.0.1.
If you need to update your copy of World of Warcraft, I suggest looking for the patches you need at WoWWiki - Patch Mirrors.
Starting Your Server
Go to \bin\Win32_Release\ and start realmd.exe and mangosd.exe. If it automatically closes, look for a file in that folder named Server.log (If mangosd.exe closed) or Realmd.log (If realmd.exe closed), read what happened. If you cannot figure out the problem, PM me and I will tell you what to do. If they did not close, wait till you hear mangosd.exe make a beep sound. This means it has finished starting.
You can now start World of Warcraft and log in with the username and password administrator Note, never start World of Warcraft through Launcher.exe or it will attempt to update the client.
Compiling Tools
This section is only if ad.exe and 3 files in \contrib\vmap_extract_assembler_bin\ were not there. Go to \contrib\extractor\ and open VC100_AD.sln and go to Build>Rebuild Solution. Once it's finished, ad.exe should be in \extractor\release\. Now go to \contrib\vmap_assembler\ and open vmap_assemblerVC100.sln, rebuild it and do the same with vmapExtractor3_VC100.sln in \contrib\vmap_extractor_v3\win\. Copy the files we just compiled to your World of Warcraft folder and also copy over makevmaps_SIMPLE.bat from \contrib\vmap_extract_assembler_bin\. Now if makevmaps_SIMPLE.bat is not there, create a notepad document, open it and copy the following:
vmapExtractor3.exe
md vmaps
vmap_assembler.exe buildings vmaps
pause
Save and close it. Change the extension from .txt to .bat and move it to your World of Warcraft folder. Now you can extract the vmaps, dbc and maps.Additional Shit
If I left out anything, please feel free to tell me. If you need help, PM me, I will do my best to help you but for the love of God, please use proper grammar. I hate deciphering what people say when they use broken English or teen texting lingo.
This guide can easily be also used for compiling and setting up non-MaNGOS servers, since setting up most servers is relatively the same.
If you require compiling a 64-bit server, follow the guide but when you compile ScriptDev2 and the MaNGOS core just change the Active solution platform to x64. This will also change the directory of your compiled binaries. They would be in \mangos\bin\x64_Release\. Although please note, as of the latest update to this guide, 64-bit compiles seem to suffer from the god-awful realmlist loop issue and none of the usual suspects cause it.
If you are importing a very large database using Navicat, you may run into a problem where the execution gets stuck at like 70 commands, that's cause Navicat sucks at executing large queries. Here's a simple workaround:
Make a copy of the SQL file you need to execute and put it in C:\Program Files\MySQL\MySQL Server X.X\bin\ (Replace X.X with whatever version folder is in there). Press Win+R to open the Command Prompt and type CD C:\Program Files\MySQL\MySQL Server X.X\bin\ (Replace X.X with whatever version folder is in there) then type mysql -u root -p database_name < FileToExecute.sql, it'll prompt you to enter your MySQL server password (By default it's "root"). It'll only take a couple of seconds this way.
Warning as of 1/2015: I reverted this guide to using MaNGOS instead of CMaNGOS (Originally it was pre-split MaNGOS, then MaNGOS, then CMaNGOS and now MaNGOS again). If you do use CMaNGOS, as far as the script library which I refer to as "ScriptDev2" in this guide, you will need to instead download the real ScriptDev2 from https://github.com/scriptdev2/ and for the database, you'll need use UDB from https://github.com/unified-db/Database, but you can choose to use YTDB as it is compatible.. Everything else is exactly as described in the guide, sans populating the mangos database, which instead I suggest following the tip directly above this paragraph to execute the very large SQL file located in unified-db/Database/Current_Release/Full_DB/, then follow the updating section as described.
Tip for advanced users: If you desire to compile a TrinityCore or SkyFire server, you will need to install Microsoft Visual Studio 2013 Express (Unfortunately downloading just the MSVC++ 2013 runtime libraries isn't good enough), CMake and OpenSSL (Not Light). You will need to generate the solution files with CMake before compiling.
Darkicon
Ragezone