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 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 ALL PRIVILEGES ON *.* TO 'l2j'@'%' IDENTIFIED BY 'l2jserver2019';

Get the Source Code

Our official repositories 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 && mvnw install
cd /opt/l2j/git/l2j-server-game && chmod 755 mvnw && ./mvnw install
cd /opt/l2j/git/l2j-server-datapack && chmod 755 mvnw && ./mvnw 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-*.zip -d /opt/l2j/server/game
unzip /opt/l2j/git/l2j-server-datapack/target/l2j-server-datapack-*.zip -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.

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

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 hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) {
	ShellExecute(0, L"open", L"cmd.exe", L"/C start l2.bin IP=", 0, SW_HIDE);

Download compiled version from here.

More information here.