1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
5/5, 1 rating

Preparing a fresh Ubuntu 16.04 for ServUO using mono and unixODBC

Summary of the tutorial

This tutorial aims to simplify preparation of a fresh Ubuntu 16.04 server for use with ServUO and unixODBC.

How to prepare a fresh Ubuntu 16.04 installation for ServUO
A few programs I recommend installing on your computer (not server) are puTTY, WinSCP, and Notepad++

Install Ubuntu 16.04 on the server of your choice or you can use a free EC2 server from Amazon AWS https://aws.amazon.com/

You can download Ubuntu Server 16.04 here:

https://www.ubuntu.com/download/server/thank-you?country=US&version=16.10&architecture=amd64

If you are only going to be using your server for ServUO, the best way to improve performance is to only install what is needed for ServUO, and nothing more. You don't need a LAMP installation or other processes taking up valuable RAM and CPU.

So, when installing, choose only SSH Server. Don't install LAMP, DNS, or any of the other options. If you need a web and database server, install them on another server.

During the installation, you will need to setup your first user. If the server is only going to be running ServUO, then make the login name "servuo" or "ubuntu" (something generic. This can help later when migrating or collaborating)
Once you have the server installed, you are ready to prepare it for ServUO. Use puTTY to connect to your server and login as the default user: ubuntu

Before you install the wrong version of mono which will install by default, you need to get the lastest
Code (C#):
  1.  
  2. sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
  3. echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
  4.  
Now you are ready to install everything you need to run ServUO
Code (C#):
  1.  
  2. sudo apt-get update
  3. sudo apt-get install -y git autoconf libtool automake build-essential mono-devel gettext cmake xclip unzip mono-complete unixodbc screen htop libpng-dev zlib1g-dev
  4.  
Now you need to setup ODBC so your MyRunUO can update the databse
Code (C#):
  1.  
  2. wget http://dev.mysql.com/get/Downloads/Connector-ODBC/5.3/mysql-connector-odbc-5.3.7-linux-ubuntu16.04-x86-64bit.tar.gz
  3.  
Extract
Code (C#):
  1.  
  2. tar xvzf mysql-connector-odbc-5.3.7-linux-ubuntu16.04-x86-64bit.tar.gz
  3.  
Copy drivers to /usr/lib/x86_64-linux-gnu/odbc/
Code (C#):
  1.  
  2. sudo cp mysql-connector-odbc-5.3.7-linux-ubuntu16.04-x86-64bit/lib/* /usr/lib/x86_64-linux-gnu/odbc/
  3.  
Create a Driver (MySQL ODBC 5.3 Unicode Driver)
Code (C#):
  1.  
  2. sudo ./mysql-connector-odbc-5.3.7-linux-ubuntu16.04-x86-64bit/bin/myodbc-installer -d -a -n "MySQL ODBC 5.3 Unicode Driver" -t "DRIVER=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5w.so;SETUP=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5S.so"
  3.  
cleanup
Code (C#):
  1.  
  2. rm -rf mysql-connector-odbc-5.3.7-linux-ubuntu16.04-x86-64bit
  3. rm mysql-connector-odbc-5.3.7-linux-ubuntu16.04-x86-64bit.tar.gz
  4.  
Create your a System Data Source:
Code (C#):
  1.  
  2. sudo nano /etc/odbc.ini
  3.  
Enter your MyRunUO server details
Code (C#):
  1.  
  2. [myrunuo]
  3. DRIVER=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5w.so
  4. SETUP=/usr/lib/x86_64-linux-gnu/odbc/libmyodbc5S.so
  5. SERVER = mysqlserver
  6. PORT = 3306
  7. DATABASE = myrunuo
  8. OPTION = 3
  9. USER = myrunuo
  10. PASSWORD = myPassword
  11.  
Now create the DSN
Code (C#):
  1.  
  2. sudo odbcinst -i -s -l -f /etc/odbc.ini
  3.  
verify that the DSN is ready (should return [myrunuo])
Code (C#):
  1.  
  2. odbcinst -s -q
  3.  
connect to your MyRunUO database with isql
Code (C#):
  1.  
  2. isql -v myrunuo myrunuo myPassword
  3.  
  4. quit
  5.  
Create a link to the driver so mono can see it
Code (C#):
  1.  
  2. sudo ln -s /usr/lib/x86_64-linux-gnu/libodbc.so.1 /usr/lib/libodbc.so
  3.  
Generate your key to use with GitLab
Code (C#):
  1.  
  2. ssh-keygen -t rsa -C "GitLab" -b 4096
  3.  
Show your server's public key
Code (C#):
  1.  
  2. cat ~/.ssh/id_rsa.pub
  3.  
Copy your public key and paste it in GitLab (Click configure icon in upper right, and select "Deploy Keys")
Follow directions to get a copy of ServUO into your private repository on GitLab
There is a guide here:
https://www.servuo.com/tutorials/managing-a-shards-code-with-git.18/?page=1section_46

Once you have the ServUO source on your server, edit of the files in the Config directory to your liking
and create a directory for your uofiles (path is set in the Config/DataPath.cs file)
Code (C#):
  1.  
  2. make
  3.  
Press ctrl+c to stop your server after you have setup your owner login and allowed it time to save.

Now you need to chown your ServUO directory for example:
Code (C#):
  1.  
  2. sudo chown -R ubuntu:ubuntu ServUO
  3.  
  4. In order for your server to keep running after you logout, you need to launch you server in a "screen"
  5. screen
  6.  
  7. now enter the directory where your server is and run the startup script
  8. ./ServUO.sh
  9.  
  10. now you can disconnect from your screen and connect to it any time later by pressing CTRL+A, then D
  11.  
  12. to reconnect to your screen later, type:
  13. [CODE]
  14. screen -r
  15.  
The server will launch after it compiles and will launch and ask you to enter your owners login and password.
Done!

Optional installing .NET MySQL Connector
create a working directory (i.e. mysql)
Code (C#):
  1.  
  2. mkdir mysql
  3. cd mysql
  4.  
Download the connector
Code (C#):
  1.  
  2. wget https://dev.mysql.com/get/Downloads/Connector-Net/mysql-connector-net-6.9.9-noinstall.zip
  3. unzip mysql-connector-net-6.9.9-noinstall.zip
  4.  
Now add the 4.0 libs
Code (C#):
  1.  
  2. cd v4.0
  3. sudo gacutil /i /package 4.0 MySql.Data.dll
  4.  
You should see:
Package exported to: /opt/local/lib/mono/4.0/MySql.Data.dll -> ../gac/MySql.Data/6.8.3.0__c5687fc88969c44d/MySql.Data.dll
Installed MySql.Data.dll into the gac (/opt/local/lib/mono/gac)

Now the 4.5 libs
Code (C#):
  1.  
  2. cd ../v4.5
  3. sudo gacutil /i /package 4.5 MySql.Data.dll
  4.  
Package exported to: /opt/local/lib/mono/4.5/MySql.Data.dll -> ../gac/MySql.Data/6.8.3.0__c5687fc88969c44d/MySql.Data.dll
Installed MySql.Data.dll into the gac (/opt/local/lib/mono/gac)

verify
Code (C#):
  1.  
  2. gacutil -l|grep MySql
  3.  
MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d


To use these in any of your ServUO scripts, you need to update the Makefile
Code (C#):
  1.  
  2. nano Makefile
  3.  
Change this:
REFS=System.Drawing.dll

To this:
REFS=System.Drawing.dll,System.Data.dll,/usr/local/lib/mono/4.0/MySql.Data.dll

This save
Add this to your scripts to use:
Code (C#):
  1.  
  2. using MySql.Data;
  3. using MySql.Data.MySqlClient;
  4.  
If you are getting errors about MySql assembly reference, you may need to update your machine.config files
Code (C#):
  1.  
  2. /etc/mono/4.0/machine.config
  3. /etc/mono/4.5/machine.config
  4. /usr/local/etc/mono/4.0/machine.config
  5. /usr/local/etc/mono/4.5/machine.config
  6.  
Edit these files, search for <system.data> and add this inside <DbProviderFactories>
Code (C#):
  1.  
  2.             <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient"
  3.                  description=".Net Framework Data Provider for MySQL"
  4.                  type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
  5.  
  6.  
If you want to setup your ServUO to run as a service and automatically restart, check out my other tutorial here:
https://www.servuo.com/tutorials/running-servuo-as-a-service-on-ubuntu-16-04-with-auto-restarts.28/


If you want to see what processes are running try htop.
Code (C#):
  1.  
  2. htop
  3.