L2J Server on CentOS 7.6+

L2J is a complex piece of software engineering, it's divided in three main components, login server, game server and datapack.

Update and Upgrade your OS

CentOS 7.6+ comes with OpenJDK 11.

cat /etc/centos-release
yum update

Install OpenJDK

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

yum -y install java-11-openjdk java-11-openjdk-devel
java -version
openjdk version "11.0.4" 2019-07-16 LTS

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.

wget https://www-us.apache.org/dist/maven/maven-3/3.6.1/binaries/apache-maven-3.6.1-bin.tar.gz -P /tmp
tar xf /tmp/apache-maven-3.6.1-bin.tar.gz -C /opt
ln -s /opt/apache-maven-3.6.1 /opt/maven
vi /etc/profile.d/maven.sh
# Paste
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
chmod +x /etc/profile.d/maven.sh
source /etc/profile.d/maven.sh

Install the Database Server

Get latest version from here.

vi /etc/yum.repos.d/MariaDB.repo
# MariaDB 10.4 CentOS repository list - created 2019-08-11 20:34 UTC
# http://downloads.mariadb.org/mariadb/repositories/
name = MariaDB
baseurl = http://yum.mariadb.org/10.4/centos7-amd64
yum install MariaDB-server MariaDB-client
mariadb -u root -p
MariaDB > CREATE OR REPLACE USER 'l2j'@'%' IDENTIFIED BY 'l2jserver2019';
MariaDB > GRANT USAGE ON *.* TO 'l2j'@'%' IDENTIFIED BY 'l2jserver2019';

Get the Source Code

Our official repositores are the ones 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

We use Maven to build the server files.

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.zip -d /opt/l2j/server/login
mkdir -p /opt/l2j/server/game
unzip /opt/l2j/git/l2j-server-game/target/l2j-server-game- -d /opt/l2j/server/game
unzip /opt/l2j/git/l2j-server-datapack/target/l2j-server-datapack- -d /opt/l2j/server/game

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.

mkdir -p /opt/l2j/cli && cd /opt/l2j/cli
wget https://github.com/L2J/l2j-server-cli/releases/download/1.0.0-alpha1/l2jcli-1.0.0.zip -P /tmp
unzip /tmp/l2jcli-1.0.0-alpha.zip -d /opt/l2j/cli
chmod 755 l2jcli.sh
> db install -l /opt/l2j/server/login/sql -u l2j -pw l2jserver2019 -m FULL -t LOGIN
> db install -l /opt/l2j/server/game/sql -u l2j -pw l2jserver2019 -m FULL -t GAME
> 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
> account create -u Zoey76 -p -a 8
> quit

Start the Server

To start the server you need to run two scripts.

cd /opt/l2j/server/login
cd /opt/l2j/server/game

Open Server Ports

If you are not playing from localhost you may need to open the following ports.

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

Connect to the Server

In order to connect to the server you have the following options:

HOSTS file

Edit C:\Windows\System32\drivers\etc\hosts and add this line: l2authd.lineage2.com

BAT file

Create a .bat file with the following content:

@start l2.bin IP=

Custom exe

Here is a C++ Win32 exe example:

#define NOMINMAX
#include <windows.h>
#include <cstdlib>

// Start L2 as .bin with IP as parameter.
// You can use IP or DNS as IP parameter.
// You could include other parameters.
// You can change the path to the .bin file to avoid including the L2.exe inside the System folder.
// Author: Zoey76
int _stdcall wWinMain(HINSTANCE hInst, HINSTANCE prevInst, LPWSTR szCmdLine, int nCmdShow)
	ShellExecute(0, L"open", L"cmd.exe", L"/C start l2.bin IP=", 0, SW_HIDE);

More information here.