Advanced EqEmu Linux Setup
This guide has for goal to show how to install a working eqemu server on a Linux box. It's written for Linux but will prolly also work with FreeBSD and Linux clones. It requires a basic Linux knowledge, I certainly won't go deeper enough to teach you how to install Linux, or login on your system. This is widely covered on the web, Google is your best friend.
I won't also cover all the details of the server configuration (ini files), since they are exactly the same with Linux or Windows.
Please refer to the following guides if you need to :
HOWTO: Host a 6.0-DR2 Server! + Minilogin! (WIN32) :
http://www.eqemulator.net/forums/viewtopic.php?t=18935
HOWTO: Host a 6.0 Server on Windows (Perl Quests enabled!!) :
http://www.eqemulator.net/forums/viewtopic.php?t=17531
Please keep in mind that you can setup a Linux box as Eqemu server only if you're on your own LAN (private network). Usually, LAN addresses are taken into the 192.168.*.* range, but if you are on an company network (don't let your boss know that you play EQ at work !), it can be something else.
Prerequisites
- A working Linux box, with a working LAN connexion
- Around 1.5 Gbytes of freespace.
- An EqEmu source package, get it from Sourceforge (links on
http://eqemulator.net), or from anywhere else, it doesn't matter much.
- Eqemu maps, needed for pathing and line of sight code, get them from sourceforge, or
http://www.rogean.com/maps/maps.zip
- A ton of patience and concentration.
- Minilogin.exe (also from Sourceforge) if you want to run a private server.
- Perl 5.8.0+ (this is installed on most recent Linux distribs)
Optional
- A working install of Samba (Windows server emulator, I won't also cover it here since there's several billions tutorial about Samba on the web).
- Knowing how to use a linux text editor, vi for example.
- A 6.0+ database. PEQ lastest release for example, and all the database updates from
http://www.eqemulator.net/databases_v6.php.
Part 0 : What are we going to install ?
We're about to install, starting from nothing, an EqEmu server, on a Linux box. This means that, once done, you'll have your own EqEmu server. If you only want to play to Everquest on an EqEmu server, you don't need to do all this, just go back to the Tutorial forum and open an "How to play" topic. This is only for people who want to run their own server, private or public.
For that guide, we will decide that we want to create a PEQ Minilogin server. Mysql is running on the linux box (it could be ran on another box, Linux or Windows, doesn't matter much). We will connect to it with an account named eqemu and eqpassword as password and the EQ database's name will be eqemu . The server's IP address is 192.168.0.100
Part 1 : Preparing the battlefield
Before unpacking your source or doing any compilation, you must think about what you're going to do.
We will install a software that is frequently updated and requires lot's of tweaking. This parameters must be kept in mind when installing. You will have to change your server's version at least 1 or 2 times per month if you wanna stay uptodate, perhaps even more if your goal is to have a public server.
Which version of Linux ? Well, it's not important as long as it's 'modern' enough. A 2.4.18 or more recent is ok. Memory usage will depend of what you'll do of your server. For private use, 256 Mb and 512 Mb of swap are enough, for a public server, the more the better.
Hard disk space : EqEmu requires now lots of disk space for the map files. The software by itself occupies only a few Mb. I suggest you to choose a partition which has at least 3 or 4 free Gb, even if you don't need them all, there's nothing more boring than full partitions. Avoid the partition(s) that contain /, /tmp and /var. One of the best choices would be to have a dedicated partition for eqemu. For that guide, we will consider that we have mounted a 5+ Gb partition on /eqemu.
Directory structure : Login as root and create the following directories :
/eqemu/source : This is where you'll unpack your packages and compile them.
/eqemu/server : This is where you'll set your server.
Code:
mkdir /eqemu
mkdir /eqemu/source
mkdir /eqemu/server
chown -R root:root /eqemu
chmod -R 775 /eqemu
Part 2 : Compilation
Note concerning non-Intel or old CPUs: If the CPU or your Linux Box isn’t a Pentium 2 or higher and you encounter an error message of the kind
Code:
[1]+ Illegal instruction ./world
when running the binaries, you will have to edit the makefile and makefile.perl files to change the value of the
–march option. If you have a Pentium 1, set it to i586. Other CPUs also have their own settings, but if you have one, you yet certainly know what to use ?
Compiling is the hardest part of the process and where you may encounter most of the problems.
Unpack the source archive into /eqemu/source. You will then obtain a new directory named Source. Rename that directory with the date of the day :
Doing this, you'll keep your different source codes and will be able to go back to an old, and working, setup if something goes wrong with a new one in the future.
Mysql include files
Run the following command :
Code:
mysql_config --cflags
It will return you something that looks like :
Code:
-I'/usr/local/include'
This is where mysql_config thinks your mysql include files are. If you re-installed mysql and made some links to replace the old mysql binaries, it's perhaps not working and will lead you to a compile error.
List the files from the directory returned by mysql_config : ls /usr/local/include/mysql*h
If you obtain a list of files that contains mysql.h, mysql_com.h and some other mysql* files, you're good to go.
If not, you have 2 options :
- Pretty one : Edit the makefile (the file where compilation options are) of what you gonna compile, it means 3 makefile edition per EqEmu compilation.
- Uggly one : Copy or link the needed mysql include files into /usr/local/include (or any directory returned by mysql_config !)
- Advanced one : Edit your mysql_config script and fix the error.
For once, we gonna be uggly because it will be easier.
Find your mysql include files : locate mysql_com.h
This will return prolly several rows. Determinate the one that points where mysql have been installed. If you did it yourself, you certainly yet know where it was, if you didn't, its perhaps something like /usr/include/mysql/mysql_com.h
Now, run this :
Code:
ln -s /usr/include/mysql/mysql*.h /usr/local/include/
This will create symbolic links of mysql include files into the directory mysql_config thinks they should be.
Compilation : libEMuShareMem.so
Go to /eqemu/source/12152004/EMuShareMem, and run make
Code:
cd /eqemu/source/12152004/EMuShareMem
make clean ; make
If you respected the step with mysql include files, compilation will be easy.
Compilation : world
Go to /eqemu/source/12152004/world, and run make
Code:
cd /eqemu/source/12152004/world
make clean ; make
Compilation : zone
Code:
cd /eqemu/source/12152004/zone
make clean
make -f makefile.perl
If you don’t have mysql_config on your Linux box
Create it somewhere in your PATH, for example in /usr/bin :
Code:
vi /usr/bin/mysql_config
Code:
#!/bin/sh
cflags="-I/usr/local/share/mysql/include/mysql"
include="-I/usr/local/share/mysql/include/mysql"
libs="-L/usr/local/share/mysql/lib/mysql -lmysqlclient -lz -lcrypt -lnsl -lm"
libs_r="-L/usr/local/share/mysql/lib/mysql -lmysqlclient_r -lpthread -lz -lcrypt -lnsl -lm -lpthread"
socket="/tmp/mysql.sock"
port="3306"
version="4.0.18"
embedded_libs="-L/usr/local/share/mysql/lib/mysql -lmysqld -lpthread -lz -lcrypt -lnsl -lm -lpthread -lrt"
usage () {
cat <<EOF
Usage: $0 [OPTIONS]
Options:
--cflags [$cflags]
--include [$include]
--libs [$libs]
--libs_r [$libs_r]
--socket [$socket]
--port [$port]
--version [$version]
--libmysqld-libs [$embedded_libs]
EOF
exit 1
}
if test $# -le 0; then usage; fi
while test $# -gt 0; do
case $1 in
--cflags) echo "$cflags" ;;
--include) echo "$include" ;;
--libs) echo "$libs" ;;
--libs_r) echo "$libs_r" ;;
--socket) echo "$socket" ;;
--port) echo "$port" ;;
--version) echo "$version" ;;
--embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;;
*) usage ;;
esac
shift
done
exit 0
Edit the values of cflags, include and libs… with the right directories.
Code:
chmod +x /usr/bin/mysql_config
Part 3 : The database
Step 1 : creating a mysql account for eqemu
If your mysql server is on another box, please be smart enough to work on that box
Under Linux, you will access to your mysql server from your mysql client with the following command :
Connect to mysql using mysql -p, if you didn't installed mysql yourself, there's probably no password specified as root password, just press enter when mysql will ask you for a password. Once connected, you ll obtain a mysql prompt that looks like 'mysql>'. Follow the next steps :
We will work on the database named mysql (the one that contains mysql accounts, privileges and such...)
Now we list the existing mysql accounts
Code:
mysql> select Host,User from user;
You mustn't use the root user for security reasons, instead, create or use another account. Create a new account if needed :
If your mysql server is on your Linux box :
Code:
mysql> insert into user set Host='localhost', User='eqemu', Password=password('eqpassword');
If your mysql server is on another box :
Code:
mysql> insert into user set Host='192.168.0.100', User='eqemu', Password=password('eqpassword');
Now create your eqemu database :
Code:
mysql> create database eqemu;
Give rights to access the eqemu database to the eqemu account :
Code:
mysql> grant all privileges on eqemu.* to 'eqemu'@'localhost';
or if mysql is on another box :
Code:
mysql> grant all privileges on eqemu.* to 'eqemu'@'192.168.0.100';
We refresh the global privileges so mysql knows that we added a new account :
Code:
mysql> flush privileges;
And we can quit mysql:
Note : If you’re using mysql 4.1 or higher and experiment some errors #1251 or #2006 when trying to connect to mysql with your eqemu account run the following query :
Code:
mysql> use mysql;
mysql> update user set Password=old_password('eqpassword') where Host='localhost and User='eqemu';
mysql> flush privileges;
Step 2 : connect to mysql using the eqemu account
Note : you could do that step using the root account, but if you do it with the eqemu account (and from the eqemu server box if mysql server is on another box), you ll be sure that your mysql config is operationnal !
Create a directory name database into your eqemu tree : mkdir /eqemu/database
(Do this even if your mysql box isnt your eqemu box)
Copy and unpack your db files into that directory. There should be the PEQ file, and several smaller update files. You will also need to find every recent update made to the database, in the forum and by reading the HISTORY file contained in the eqemu packages.
Now connect to mysql, mysql server is your eqemu box :
Code:
mysql -p -u eqemu eqemu
mysql is on another box (let's say it is 192.168.0.120)
Code:
mysql -p -u eqemu -h 192.168.0.120 eqemu
If you can connect to mysql and obtain the mysql prompt, bravo, your mysql setup is ok, if not, go back to step 1 and try find where things started to mess up. Eventually, ask for help on Eqemu forums.
Source all the database files using the 'source' command :
Code:
mysql> source PEQ_Kunark_RC1.sql;
mysql> source aa_levels.sql;
etc ...
Database structure is the same for Linux and Windows.
Tips : I suggest you to add -s as option when connecting to mysql. Doing so, mysql client won't show you what he sources into the database, and it ll be 15 or 20 time faster
:
Code:
mysql -p -u eqemu -s eqemu
Step 3 : For minilogin users
Log into mysql, like explained at step 2 and run the following queries :
Code:
mysql> INSERT INTO variables (varname, value, information) VALUES ('LoginType', 'Minilogin', 'Set this to Minilogin to login using a minilogin server :)');
mysql> alter table account add minilogin_ip varchar(32) not null;
mysql> insert into account (name,status, minilogin_ip) values('Muuss',250,'192.168.0.30');
Please refer to
http://www.eqemulator.net/forums/viewtopic.php?t=17843 for this third step, let's not re-invent the wheel, Edgar wrote a tutorial, use it !
Part 4 : Perl (Quests)
Create a quests directory into /eqemu/server : mkdir /eqemu/server/quests
Download :
http://search.cpan.org/CPAN/authors/...y-2.109.tar.gz
and copy it somewhere onto your Linux box, then run the following commands :
Code:
tar zxvf IO-stringy-2.109.tar.gz
cd IO-stringy-2.109
perl Makefile.PL
make
make test (should tell you that everything is ok !)
make install
This is easier than the online install via CPAN.
Part 5 : Installing the server
Everything will now take place into /eqemu/server
Step 1 : the server binaries
We will now use the binaries generated during the Part 2. You can either copy them here, or link them. Choose to link them if you're working on a private server and think you ll play with eqemu source code, so, after each compile, your server will be operationnal. Copy them if you're running a public server and can't shut it down too often.
Links :
Code:
ln -s /eqemu/source/12152004/EMuShareMem/libEMuShareMem.so /eqemu/server/libEMuShareMem.so
ln -s /eqemu/source/12152004/world/world /eqemu/server/world
ln -s /eqemu/source/12152004/zone/zone /eqemu/server/zone
Step 2 : map files
Create a directory named maps where you'll unpack your map files.
Code:
mkdir /eqemu/server/maps
copy and unpack the map files into that directory.
Step 3 : db.ini
We need to create several files that will contain eqemu configurations into the server's directory. I suggest you to create the files from nothing, that's the best way to understand what you're doing.
Code:
cd /eqemu/server
vi db.ini
Code:
[Database]
host=localhost
user=eqemu
password=eqpassword
database=eqemu
or, if you're using a deported mysql server
Code:
[Database]
host=192.168.0.120
user=eqemu
password=eqpassword
database=eqemu
Step 4 : Login process
Two alternatives here, choose the one that suits you :
go to step 5 if you create a Minilogin server (private server)
go to step 6 if you create a public server (using eqemulator login servers)
Step 5 : Minilogin
If you plan to use the public login servers, go directly to step 7.
Start by reading this :
http://www.eqemulator.net/forums/viewtopic.php?t=17843
Since we're running the server on a Linux box and Minilogin.exe is a Win32 software, we can't run it on the server box. Any Windows client on your Lan will do the job very well. Let's say that the computer you will play on is 192.168.0.30.
Edit LoginServer.ini
Code:
cd /eqemu/server
vi LoginServer.ini
Code:
[LoginServer]
loginserver=192.168.0.30
loginport=5999
worldname=My private world
worldaddress=192.168.0.100
locked=false
account=
password=
[WorldServer]
Defaultstatus=20
Unavailzone=
[ChatChannelServer]
worldshortname= PrivateWorld
chataddress=
chatport=
[LoginConfig]
ServerMode=MiniLogin
ServerPort=5999
Now, copy Minilogin.exe and LoginServer.ini on your Windows computer (192.168.0.30), and place them into a directory you'll remember, like c:\minilogin for example. Remember that you'll need to launch minilogin.exe each time you will start your eqemu server !
Step 6 : Public login servers
If you plan to use Minilogin as login server, go back to step 5.
Code:
Edit LoginServer.ini
vi LoginServer.ini
Code:
[LoginServer]
loginserver=newlogin1.eqemulator.net
loginport=5994
worldname=What a wonderfull world
worldaddress=EXTERNAL_IP_ADDRESS
locked=false
account=
password=
[WorldServer]
Defaultstatus=0
Unavailzone=
[ChatChannelServer]
worldshortname=
chataddress=
chatport=
As EXTERNAL_IP_ADDRESS, enter the address your known on internet.It's the IP address of your router. If you don't know it, a solution may be to visit
http://www.whatismyip.com/ but it won't work if you're using a HTTP proxy server. Another solution can be to run a traceroute command on an external server :
Code:
traceroute yahoo.com
Step 7 : A few tests
Launch Minilogin.exe on your Windows computer. It should display the following text :
Code:
LoginServer.ini read.
Server mode: Standalone
Login server listening on port:5999
(Don't try to do this if you don't use minilogin)
Go to your server directory :
And type this :
Code:
./world | grep EMuShare
Break with Ctrl+C.
If it says something about libEMuShareMem not loaded :
Code:
[Error] LoadEMuShareMemDLL::Load() failed to load library 'libEMuShareMem.so'. Error=0
Run this :
Code:
echo "/eqemu/server" >> /etc/ld.so.conf ; ldconfig
Re-run
Code:
./world | grep EMuShare
and it should now return :
Code:
[Status] libEMuShareMem.so loaded
Break with Ctrl+C.
Step 8 : zone script
Create a short script named zone, and put it somewhere in your path, /usr/bin for example.
Code:
#!/bin/sh
(cd /eqemu/server: ./zone EXTERNAL_IP_ADDRESS $1 77$2 192.168.0.100 &)
Save it, then make it executable :
Code:
chmod +x /usr/bin/zone
This script will allow you to launch some zones without having to remember the zone syntax, example :
will release a dynamic zone on port 7990.
will launch a static zone for West Commonlands on port 7991.
Step 9 : Finishing the install
Create a directory for the log files :
Code:
mkdir /eqemu/server/logs
Copy the following files into /eqemu/server : spells_us.txt, commands.pl, plugin.pl
Part 6 : Running the server
This is the typical process needed to run the server (take into consideration that Minilogin if you use it must be running on your Windows box) :
Code:
cd /eqemu/server
./world &
zone . 91
zone . 92
You can eventually add this into your init scripts, I won't go deeper, it's different on each distribution. A common way is to add it at the end of the file named rc.local.
You can also create a startup script that could looks like this :
Code:
#!/bin/sh
case "$1" in
'start')
echo "Starting EqEmu..."
echo " - starting world"
/eqemu/server/world 2>&1 1> /dev/null &
sleep 3
/eqemu/server/zone EXTERNAL_IP_ADDRESS . 7791 192.168.0.100 2>&1 1> /dev/null &
/eqemu/server/zone EXTERNAL_IP_ADDRESS . 7792 192.168.0.100 2>&1 1> /dev/null &
echo " - starting zones"
echo "... done";
;;
'stop')
echo "Killing EqEmu...";
killall world zone 2>/dev/null
echo "... done"
;;
'restart')
$0 stop
sleep 1
$0 start
;;
*)
echo "usage $0 start|stop|restart"
;;
esac
(replace EXTERNAL_IP_ADDRESS by your IP address...)
Part 7 : A few tips
- How to browse a logfile : tail -f /eqemu/server/logs/eqemu_zone.log
- Refer to Fathernitwit security post if you wanna secure your server.
- Kill telnet daemon and only use sshd.
- If you have samba, share /eqemu/server and copy Minilogin.exe in it. Doing this, you won't need it on your Windows computer, it can be ran thru a share.
- After your server crashed or when you started it with an incorrect database setup, zone could eventually refuse to boot up and will block on Loading doors or another table of the database. This problem is certainly linked to the fact that there’s a remaining and unvalid memory segment allocated by libEMuShareMem.so that wasn’t freed when the server crashed. To remove it, you will have to use ipcs and ipcrm commands.
This is a running server :
Code:
ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 0 webicim 600 46084 10 dest
0x49038098 393217 root 600 21003715 2
0x46038098 425986 root 600 3871168 1
0x4c038098 458755 root 600 1322356 1
0x44038098 491524 root 600 504730 1
This is the same server, after i killed it (notice the nattch fields)
Code:
ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x00000000 0 webicim 600 46084 10 dest
0x49038098 393217 root 600 21003715 0
0x46038098 425986 root 600 3871168 0
0x4c038098 458755 root 600 1322356 0
0x44038098 491524 root 600 504730 0
If zone hangs up when you try to boot it again, remove all the rows where nattch is 0. The command is ipcrm with –m as parameter and shmid field as identificator :
After you removed all the segments allocated by eqemu, it’ll boot up again normally.
Revisions
- Added the part concerning IPCs
- Added the archictecture specific note (suggested by residentninja)
- Added a fix for the mysql errors 1251 and 2006. (suggested by residentninja)
- Rewrote mysql_config so there’s no more compilation errors
- Completed mysql_config support for people who don’t have it (suggested by residentninja)
- Modified starting script so it doesn’t use /usr/bin/zone script but directly /eqemu/server/zone binary