Welcome!

Join our community of MMORPG enthusiasts and private server developers! By registering, you'll gain access to in-depth discussions on source codes, binaries, and the latest developments in MMORPG server files. Collaborate with like-minded individuals, explore tutorials, and share insights on building and optimizing private servers. Join us today and unlock the full potential of MMORPG server development!

Join Today!

How to create server on Linux

Joined
Sep 18, 2011
Messages
1,104
Reaction score
258
This guide uses Arch Linux, the Terminal, pacman, yaourt almost all the way. This is not for everyone, you need some understanding of your Linux!

There are 2 versions of SQL available on Linux: 2017 (evaluation - but it's for 64 bit apps only) and 2000. This guide will follow the installation of 2000 - the game can only be run 32 bits...

Installing SQL 2000 under wine:
Note for 64 bits systems: for any wine/winetricks related instruction to SQL server and your top server, you have to add this:
Code:
env WINEARCH=win32 WINEPREFIX=~/.wine32

This is because Winetricks prevents dotnet20sp2 from installing into a 64 bits prefix - it is 32 bits only! Examples:

Code:
env WINEARCH=win32 WINEPREFIX=~/.wine32 winetricks winxp
env WINEARCH=win32 WINEPREFIX=~/.wine32 winetricks dotnet20sp2
...
env WINEARCH=win32 WINEPREFIX=~/.wine32 wine MSDE2000A
...

First, to configure Wine to support SQL 2000, set it to win xp mode and install Net Framework 2.0 SP 2 and MDAC 2.8 (SP 2 is not needed but it is recommended):

Code:
winetricks winxp
winetricks dotnet20sp2
winetricks mdac28

Then, cd to folder where MSDE2000A.exe is and install it - Remember to use .wine32 folder instead of .wine to use the 32 bits prefix on a 64 bit system:

Code:
wine MSDE2000A.exe
wine ~/.wine/drive_c/MSDERelA/setup.exe DISABLEROLLBACK=1 BLANKSAPWD=1 DISABLENETWORKPROTOCOLS=0 SECURITYMODE=SQL
The installer will fail! When time out failures start appearing, do a ctrl+c to abort, then copy the remaining files over - - Remember to use .wine32 folder instead of .wine (on both parameters) to use the 32 bits prefix on a 64 bit system, and to use your user name instead of "myusername":
Code:
cp ~/.wine/drive_c/users/myusername/Temp/SqlSetup/Temp/*.* ~/.wine/drive_c/windows/system32/

Now installation is finished. Restart wine or computer (otherwise SQL service might not run). Then MSSQLSERVER service will start automatically when first running a program on wine on 32 bits prefix. You can also do the following to start it manually directly:

Code:
wine net start MSSQLSERVER

To start the program that controls the service, you can do the following:

Code:
wine "C:/Program Files/Microsoft SQL Server/80/Tools/Binn/sqlmangr.exe"
Sources:



Before we continue, the dbs have to be in the same environment of the installed SQL server. That means, you are using the ~/.wine32/drive_c folder on 64 bits and ~/.wine/drive_c on 32 bits.


These folders are usually hidden, so you might need to unhide them first (you need to configure that in your system). Then unpack the db files to a folder inside that drive_c folder.

---

This guide will show how to setup SQuirreL SQL client. SQuirrel SQL and similar gui clients should be used for fully setup gui Linux environments and ease of use. This guide will assume you already installed the SQL server.


Setting up SQuirreL SQL client and connecting to server:
Installing:

Download it using yaourt:
Code:
yaourt -S squirrel-sql

After installing it, download MSSQL JDBC driver depending on the SQL version installed:
SQL 2017: version 6+: . Extract sqljdbc41.jar (enu/jre7 folder) if SQL client uses Java 7, or sqljdbc42.jar (enu/jre8 folder) if using Java 8.
SQL 2000: version 3.0: Extract sqljdbc4.jar.


Setting up the SQL client:

Start the client, click the drivers tab on the left side of the window, then right click "Microsoft MSSQL Server JDBC Driver", then click modify.
Click "Extra Class Path" tab, then click "Add" button.

Now search for that file you just extracted. Then click "OK". On the bottom of window, you'll see "Driver class com.microsoft.sqlserver.jdbc.SQLServerDriver successfully registered for driver definition: Microsoft MSSQL Server JDBC Driver", that means it worked.
Now click the "Aliases" tab on left side of window. Then click the "+" sign button (create new alias).
Put any name, select "Microsoft MSSQL Server JDBC Driver". Now for the url, it's going to be like this:
Code:
jdbc:sqlserver://localhost:1433

localhost can be the ip of your SQL server, if not local, and the 1433 can be changed to another if you have another SQL 2000 instance running or are using another port for the SQL server.
The user name is sa, and:
SQL 2017: put the sa password given at installation.
SQL 2000: leave the pass blank.
Then click OK.

Connecting to SQL server:

Now start SQL server if not started yet:
SQL 2017: it already starts on system start.
SQL 2000: starts only if you manually run a wine command or run the SQL manager.
Then click "Aliases" tab again, select the connection you created, and click the Connect button.

To run SQL commands, there's a set of tabs: Objects, SQL, Hibernate, Monitor. Click the SQL tab. Now the torture will start. Type the commands in the SQL commands section and then click the first line, and click the "running guy" button. If you did any mistakes, red text is going to appear on the bottom.

SQL Commands:

Now continuing, this is the tricky part for those who don't know the SQL language (like me) - you gotta attach using the SQL language (specifically, TSQL for SQL 2000)! The scripts that follow will be the same in all and any SQL clients.

Attaching the databases (using SQL 2000 language):
Code:
EXEC sp_attach_db @dbname = 'dbname',
    @filename1 = 'dbpathfile.mdf',
    @filename2 = 'dbpathfile.ldf';

Where dbname is the name of db (either 'accountserver' or 'gamedb'), the dbpathfile.mdf is the path to the db .mdf file in wine, like 'C:\folder\db.mdf' and dbpathfile.ldf is the path to the db .ldf in wine too. So for example:

Code:
EXEC sp_attach_db @dbname = 'accountserver',
    @filename1 = 'C:\games\top-server-db\accountserver_data.mdf',
    @filename2 = 'C:\games\top-server-db\accountserver_log.ldf';
EXEC sp_attach_db @dbname = N'gamedb',
    @filename1 = N'C:\games\top-server-db\gamedb_data.mdf',
    @filename2 = N'C:\games\top-server-db\gamedb_log.ldf';

Creating SQL logins (using SQL 2000 language):

Now you have to create the logins needed by the server. Type in:
Code:
EXEC sp_addlogin 'account', 'pass', 'db';

For example:
Code:
EXEC sp_addlogin 'pko_account', 'Y87dc#$98', 'AccountServer';
EXEC sp_addlogin 'pko_game', 'Y87dc#$98', 'GameDB';
Assigning ownership of databases to a SQL login (using SQL 2000 language):

Of course, changing the account names/passwords depending on server file cfgs. Then add the users to the dbs as owners, by typing in:
Code:
USE db;
EXEC sp_adduser 'account', 'account', 'db_owner';

For example:
Code:
USE AccountServer;
EXEC sp_adduser 'pko_account', 'pko_account', 'db_owner';
USE GameDB;
EXEC sp_adduser 'pko_game', 'pko_game', 'db_owner
';

Creating in-game accounts:

Using one of the sql clients above, use the guide below:
Code:
USE AccountServer; INSERT INTO account_login (name, password) VALUES ('<Login>', '<PasswordMD5>') USE GameDB; INSERT INTO account (act_id, act_name, gm) VALUES ((SELECT MAX(act_id) + 1 FROM account), '<Login>', <GM-level>);
But just in case the forums get deleted for some reason, it's a good idea to keep a summary of it here - first part to create account, second part to make it gm or not:
USE AccountServer;
INSERT INTO account_login (name, password) VALUES ('<Login>', '<PasswordMD5>')

USE GameDB;
INSERT INTO account (act_id, act_name, gm) VALUES ((SELECT MAX(act_id) + 1 FROM account), '<Login>', <GM-level>);

Getting the server up and running:

Now you also need to unpack the server files to a folder in the:
SQL 2000: wine environment used by SQL server.
SQL 2017: anywhere as long as you own the folder. It doesn't matter which wine prefix you use either. Databases need to be in the certain folder specified in SQL 2017 guide part.

When you do, run them. Now, if you run gameserver, you might run into some errors that usually won't happen in Windows:

"Bad allocation" error: Your server is using too much memory. 32 bit programs can use at most 4 GB of memory, but on Linux, for some reason, it can't use that much. Maybe even 2 GB is too much. I'm still not sure how to fix this, but the workaround is to load less things into 1 game server. Running linux with just barebones installed might help (which you would usually do on a dedicated server).
"Access Violation" error on GateServer: Regular IP's put at IP key on [ToClient] will make this error to appear. You have to put a long and invalid string on that field. 1231234h25giftuihfi223 is good, hdf8duity357hruasdklhfj is good too. Anything is good, as long as it's not an IP and is long (maybe over 16 bytes long).

(EXTRA) Running client on Linux notes:

The client can run on a 64 bits prefix wine as well, and performance is like on Windows for me. There are some things to take note that are as follows:
It's best to install wine-staging-nine - it has patches that improve dx 9 games. I didn't test the client with it yet, but it should work. Configure it at winecfg at Staging tab.

Some private server launchers will require wine-mono to be installed. Net Framework 4.0 might work too (look here: ). When installing SQL 2000, mono gets uninstalled from that prefix. You might want to create another prefix just for that.

The flash bug on the server selection screen has the workaround which is on wine online database. But there's another workaround found by me which only applies to a Linux with borderless and titlebar-less window management - just move the window to the top-left corner until it snaps there. Now Flash will draw normally like on Windows.

Removed sections:


Ignore this - this will stay here if Microsoft ever releases a 32 bit version of this or the game is made 64 bits... (or buy the bridge)
Installing SQL 2017:

More info on this new Microsoft development:
Yaourt or another AUR client is required to install it. These instructions use sudo or su for root priviledges, and follow yaourt usage:

yaourt -S mssql-server
sudo /opt/mssql/bin/mssql-conf setup
Then answer the following prompts:
Do you accept licence terms? "Yes"
Enter the SQL Server system administrator password: Type the password you would like the system admin to use. 8 chars long at least, with 3 of the 4 of the following: upper case letters, lower case letters, numbers, and symbols.
Confirm the SQL Server system administrator password: Same as above.
That's all - very simple!

Until you get to handle permissions on your db... then you'll get into the common Linux headache:

Permissions:
FIrst, you need to add yourself to mssql group:

sudo usermod -aG mssql myusername
Where username is the name of your user. This won't be enough to make SQL access the databases. To do that the files need to be owned by user mssql and group mssql, and also have make follow rights set for other dbs. The only way to do that is by moving all databases to /var/opt/mssql/data folder, and making sure the permissions as above are set. Here's the Terminal way to do it:


su #all following commands need root rights
Repeat the following for each database you have - remember upper/lower case matter on Linux:

#Copy database to mssql database folder
cp mydatabase.mdf /var/opt/mssql/data/mydatabase.mdf
cp mydatabase.ldf /var/opt/mssql/data/mydatabase.ldf

cd /var/opt/mssql/data

#Change user ownership to mssql
chown mssql mydatabase.mdf
chown mssql mydatabase.ldf

#Change group ownership to mssql
chgrp mssql mydatabase.mdf
chgrp mssql mydatabase.ldf

#Set the same rights as the other files in folder (in octal)
chmod 640 mydatabase.mdf
chmod 640 mydatabase.ldf
Then exit su block:

exit #Leaves su block
This process should allow all the dbs to be attached without any problems. Just remember the path to the files per database:

/var/opt/mssql/data/mydatabase.mdf
/var/opt/mssql/data/mydatabase.ldf

Ignore this - mstools doesn't work on SQL 2000 servers or below.
Setting up mstools and connecting to server:
Run the follows:


yaourt -S mssql-tools
This will install sqlcmd and bcp. Then we need to connect to server:

sqlcmd -S localhost,1433 -U username -P sapassword
localhost can be the ip of your SQL server, if not local, and the 1433 can be changed to another if you have another SQL 2000 instance running or are using another port for the SQL server.
The user name is sa, and:
SQL 2017: put the sa password given at installation.
SQL 2000: leave the pass blank.
Then click OK.

Then an interactive prompt will show up. Type the sql commands as they are in the next section.
 
Back