Home Guides L2J-Server Installation (CentOS 7 Edition)

L2J-Server Installation (CentOS 7 Edition)

In this guide we are using a VPS by Hetzner and we assume you know basic linux commands. We are also using ssh authentication and not user name + password as this is too much risky. You should as well avoid as much as you can using user name and password when dealing with servers!
The guide is inspired by Zoey76’s from L2jserver and can be found here and it is edited in our way with a few modifications. Zoey76, thank you for your original guide!
The L2jserver to this day is High Five

 

Firstly let’s update our instance.

yum update -y

In our case there was no update available but still, checking for updates is a must! Also if a reboot is needed, please do so!

Install OpenJDK

L2J is built using Java SE, to build you need Java JDK as well. L2JServer is using OpenJDK 11

yum -y install java-11-openjdk java-11-openjdk-devel
java -version

In the day/time we’re writing this guide the OpenJDK’s version is:

openjdk version "11.0.6" 2020-01-14 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.6+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.6+10-LTS, mixed mode, sharing)

Just highlight in your case the version 11.x.x for later use!.

 

Install Git

L2J uses Git as version control system on BitBucket, use it to get the latest versions.

yum install git

 

Install Maven

L2J uses Maven to build the components from the source code.

yum install wget nano unzip
wget http://apache.forthnet.gr/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz -P /tmp
tar xf /tmp/apache-maven-*-bin.tar.gz -C /opt
ln -s /opt/apache-maven-3.6.3 /opt/maven

Let’s check our JDK’s version and location

cd /usr/lib/jvm/
ls

The first command will send us to the directory that the JDK is installed and the second one will list the folders, there you will see your JDK’s version! In our case:
java-11-openjdk-11.0.6.10-1.el7_7.x86_64
You will need this bellow when we paste in the text.
Let’s create the file that we will paste in

nano /etc/profile.d/maven.sh

And paste in the following:

export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.6.10-1.el7_7.x86_64
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

Note here in the first line, you will have to fix it according to YOUR JDK’s version!

chmod +x /etc/profile.d/maven.sh
source /etc/profile.d/maven.sh

 

Install the Database Server

First we add the repo for it

nano /etc/yum.repos.d/MariaDB.repo

And paste in it

# MariaDB 10.4 CentOS repository list - created 2019-08-11 20:34 UTC
# http://downloads.mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

and we install by

yum install MariaDB-server MariaDB-client

And then we need to run the DB

systemctl start mariadb
systemctl enable mariadb
mysql_secure_installation

during the secure installation we will be asked a few questions, our answers were
Y, N, Y, Y, Y, Y

Then login to mariadb to create user and databases.
Please note here in the original guide, they allow the database user to connect by any (%) host which is ultra bad! Since the guide uses the default user name and password this is very bad because people can try to access your server’s database and ruin your game!
We will use only local access for our user and maybe, if people ask for it, we will make a guide on how to connect to your database with DBeaver using SSH tunnel!

mariadb -u root -p

just enter for password and 1 by 1 the commands bellow, this will create ther user l2j with password l2jserver2019 that can connect only locally. If you want to use your own name and password feel free to do so but be ready to edit login server, game server and l2jcli files from default to match what you’ve used.

CREATE OR REPLACE USER 'l2j'@'localhost' IDENTIFIED BY 'l2jserver2019';
GRANT ALL PRIVILEGES ON *.* TO 'l2j'@'localhost' IDENTIFIED BY 'l2jserver2019';
FLUSH PRIVILEGES;

exit

 

Get the Source Code

L2JServer’s official repositories are listed bellow.

mkdir -p /opt/l2j/git && cd /opt/l2j/git
git clone https://bitbucket.org/l2jserver/l2j-server-login.git
git clone https://bitbucket.org/l2jserver/l2j-server-game.git
git clone https://bitbucket.org/l2jserver/l2j-server-datapack.git

 

Build the Server from Source Code

Now we use Maven to build the server files. This can take a while depending on the processing speed of your server. In my VPS took some time :)

cd /opt/l2j/git/l2j-server-login && mvn install
cd /opt/l2j/git/l2j-server-game && mvn install
cd /opt/l2j/git/l2j-server-datapack && mvn install

 

Deploy the Server

The deployment process at the moment is simply unzipping the built files.

mkdir -p /opt/l2j/server/login
unzip /opt/l2j/git/l2j-server-login/target/l2jlogin-2.6.1.5.zip -d /opt/l2j/server/login
mkdir -p /opt/l2j/server/game
unzip /opt/l2j/git/l2j-server-game/target/l2j-server-game-*.zip -d /opt/l2j/server/game
unzip /opt/l2j/git/l2j-server-datapack/target/l2j-server-datapack-*.zip -d /opt/l2j/server/game

Warning! The file names may change with each new version, take that into consideration.

Get L2J CLI and Install the Database

L2J CLI is a tool developed by Zoey76 that allows us to implement automated deployments and initial configurations.
IF you have changed the default user/password for the database you will need to edit the config file. Otherwise you can’t install the database content!

mkdir -p /opt/l2j/cli && cd /opt/l2j/cli
wget https://l2jserver.com/files/binary/cli/l2jcli-1.0.2.zip -P /tmp
unzip /tmp/l2jcli-*.zip -d /opt/l2j/cli
chmod 755 l2jcli.sh
./l2jcli.sh
db install -sql /opt/l2j/server/login/sql -u l2j -p l2jserver2019 -m FULL -t LOGIN -c -mods
db install -sql /opt/l2j/server/game/sql -u l2j -p l2jserver2019 -m FULL -t GAME -c -mods
quit

Initial Configuration

You need to give certain permissions for the server to run properly.

cd /opt/l2j/server/login && mkdir -p log
chmod 755 LoginServer_loop.sh
chmod 755 startLoginServer.sh
cd /opt/l2j/server/game && mkdir -p log
chmod 755 GameServer_loop.sh
chmod 755 startGameServer.sh

 

Create Administrator Account

Use the L2J CLI to create an administrator account, 8 is the maximum account level (master).

cd /opt/l2j/cli
./l2jcli.sh
account create -u ADMIN -p -a 8
quit

 

Start the Server

To start the server you need to run two scripts.

cd /opt/l2j/server/login
./startLoginServer.sh
cd /opt/l2j/server/game
./startGameServer.sh

That was mostly it! For sure you need to configure your server but I will not bother with that in this guide!
Also depending on your host, in our case Hetzner, you might have to configure the firewall to allow connections. In our case we didn’t have to but if it comes to it

firewall-cmd --zone=public --add-port=2106/tcp --permanent
firewall-cmd --zone=public --add-port=7777/tcp --permanent
firewall-cmd --reload

 

As for how to connect to the game? The official guide says to edit hosts file but in our case we couldn’t connect because of gameguard. That thing is dead for years now and the only way in our case to connect to it was to mod a system.
Also we won’t list any details about it here. If you want contact us in our support and we can mod a system for you!

 

A few extra notes.

  • If you are uncomfortable running any of those commands, perhaps reconsider running your own server.
  • Those things above are elementary linux knowledge and you will have to know more on how to run the server and its services.
  • We are not affiliated with L2JServer or MariaDB or OpenJDK or CentOS or hetzner therefore we do NOT provide any support.
  • You shouldn’t try to run server at your home’s computer no matter how strong it is. Do not contact us for installing server software on home computers!

Exit mobile version