Jump to content

Recommended Posts

Posted (edited)

Hello once again,

 

My Apologies for being away for sometime, at this tutorial we gonna discuss working with Linux as Hosting OS for your L2J Server an we will be talking about the advantages of using Linux. so let’s cut this off and get started.

 

Table of Contents :

 

– Who can use this tutorial ?

– What is Linux ?

– Which Distribution to use ?

– Installing Linux on Personal PC or Virtual Machine

– Getting familiar with Linux Command Line { Terminal }

– Connect to Linux Server with through SSH Remotely

– Learn to Manage Users, Group and Access Control

– Repositories and Software

– Installing and Configuring MySQL Server

– Connect and Install Your Server Database

– Installing and Configuring Oracle Java

– Move and Setup your Server Files to Linux Server

– Run and Stop Server

– Installing and Configuring Apache2

– Host your Site and Domain

- Ports and Firewall > To be Added

– Manage Processes and Services > To Be Added

– Advanced and Helpful Commands > To Be Added

– What’s Next with Linux …. > To Be Added

 

In the beginning i would like to answer some frequently asked questions .

Who can use this Tutorial ?

This Guide is meant to be for non System Administrators , so it basically will be a Step by Step guide to help those didn’t worked with Linux before, so if you have no experience at all with Linux then don’t worry you’ll get familiar with it today .

 

What is Linux ?

Well, Linux as a name refers to multiple things but mainly it refers to OS Kernel that spreading more and more everyday and guess what most likely you’re using Linux too , Huh ?? oh yes actually Android is based on Linux Kernel.

For some people Linux is a monster, and actually it is a monster but a monster that fights you , or fighting in your side if you can deal with it

Linux is not that thing you can go download and get like that (Ofc you can but this needs alot of advanced skills), instead it comes as packages called Linux Distributions and can be called Linux Distro, this distributions are usable packages for Linux packed with some tools and software and some of them comes with a GUI as well, and actually there are many Distributions out there, for example : Ubuntu, Fedora, CentOS, BackTrack, Kali …. etc

 

Which Distribution to use ?

Well there are actually many good distributes but as an advice if you good or moderate with Linux then use Ubuntu Server Distribute if you are not a command line guy/girl then use something with GUI like Ubuntu Desktop, Kubuntu, Fedora. Also you may need a UI to make changes and stuff , but if you’re an experienced or a command line lover then u wont need this GUI, since everything can be done via Terminal.

Most likely when you buy your dedicated or VPS your hoster will ask your for which Distribute you want to be installed and this options are widely available in most if not all hosting providers like OVH which i recommend.

In this Guide i’ll use Ubuntu Desktop and Kubuntu

 

Installing Linux on Personal PC or Virtual Machine

I don’t like to repeat what’s already done, since there are alot of good tutorials out there , here is one of the good guides, also i’ll add a detailed guide about this later

 

 

– Getting familiar with Linux Command Line { Terminal }

First i expect now you have a clean install of Linux, i have also a clean install of Ubuntu Desktop, so let’s login with your password created in installing process or provided by your host, Type your password and hit Enter

 

image.jpg

 

 

Once you logged in Click on the Ubuntu Icon on left top corner then type “terminal” in search and click on terminal icon

 

image.jpg

 

Now we have our terminal up and running so we can start playing around with commands

 

image.jpg

 

Great, Let’s try same on another distribution ? Okay let’s go to Kubuntu Distribution

Login with your username and password

 

image.jpg

 

Then Click on Kubuntu Logo on the bottom left corner and type terminal in search then click on Konsole icon

 

image.jpg

 

Here we go again with our terminal

 

image.jpg

 

Now it’s the time to run some commands and get familiar with the new environment

 

List files in current Directory :

To see files in current working directory you can use command

 

ls

image.jpg

 

Here we can see all files and folders in current directory, but actually this is not all files and folders since by default the “ls” command wont show the hidden files, and to show all files including hidden files we can add options “-a” which stands for “list all”

 

ls -a

image.jpg

 

as you may notice in Linux hidden files and folders are those who starting with a dot “.”, any file starting with “.” will be considered as a hidden file

 

See the current directory :

To get the path of the current directory you’re working with you can use the command “pwd” which stands for “Print Working Directory”

pwd

image.jpg

 

Clear Screen :

To Clear Terminal screen you can use the command

clear

Yes it’s as simple as that

 

Make a new Folder :

first of all in Linux Community it’s usually called Directory not Folder, so in order to make a new directory u can use the command “mkdir”, which stands for “Make Directory” followed by Directory name, normally this command will return nothing but this is normal so getting nothing back doesn’t mean it’s not working

mkdir mxc_directory

image.jpg

 

Note : Linux is a case sensitive system unlike windows, so for example mxc directory is not Mxc directory since “m” is not “M” so you can have two directories in same directory with same name but different letter case

 

image.jpg

 

Change Current Directory :

Well in order to move to another directory you can simply use command “cd” which stands for “Change Directory” followed by the patch to go or directory name

cd mxc_directory

image.jpg

 

Go to Upper / Parent Folder

cd ..

image.jpg

 

 

If you wanna go to to the very top directory use “cd” without any path, and if you wanna go quickly to user directory you can use that command

 

cd ~

 

Create a new Empty file :

Creating a new files in linux is very simple, let’s go to mxc_directory and make a file in it called hello.txt, i think you know how to go to mxc_directory and then create the file using touch command

cd mxc_directory
touch hello.txt

image.jpg

 

Edit File Content in Terminal :

To edit a text based files in terminal you can use nano (available on many distributions, some have vim instead), for example

nano hello.txt

You’ll get GNU nano Editor like this

 

image.jpg

 

Now you can type or edit whatever you want and to Save Press CTRL+O then confirm file path and hit Enter, To Exist Nano Editor Press CTRL+X

 

image.jpg

 

Show File Content into Terminal :

If you wanna show a text based file contents into Terminal for a fast review you can use command “cat” followed by file name

cat hello.txt

image.jpg

 

Print Text to Terminal :

To show text to a screen or to print out a message you can use command “echo” followed by message or text quoted

echo "My Secret Message"

image.jpg

 

Useless huh ? , Well just stay with me for next trick

 

Send Terminal Output to a file :

 

If you have any terminal output that you want to save to a file instead of printing it to screen, like a log or something which you may need this when working with L2J to quickly redirect out errors to a file for later review then you can use output redirect command which is used by appending “>” followed by output file after any command that you expect an output from

echo "My Secret Message" > secret.txt

image.jpg

 

Copy file :

To copy a file you can use “cp” command followed by original file name/path followed by new file name/path, you have to provide path if it’s not in current working directory also you need to provide the name of the file on the new location

cp secret.txt copied.txt

image.jpg

 

But how to copy a folder instead of just a single file ? , well it’s simple you can still use “cp” command but this time followed by option “-R” which means Recursive , so let’s try to go to upper folder and copy mxc_directory

 

cd ..
cp -R mxc_directory copied_directory

image.jpg

 

 

Move File :

Moving files means it will be copied to another location and deleted from original one, and to do this we can use “mv” command followed by original file followed by new location along with the new file name, so for example to move copied.text to the upper directory we can do so

mv copied.text ../moved.txt

image.jpg

 

If you wanna move a directory we do as we did in coping directory by adding “-R” option

 

Delete / Remove a File :

To delete a file you can use command “rm” which stands for “remove” followed by file name

rm secret.txt

image.jpg

 

Same for Deleting Directory you can add -R option but take care since this operation can’t be undone

 

Connect to Linux Server with through SSH Remotely

Considering that you have a Linux VPS or Dedicated you will have what’s called SSH (Secure Shell) access in this case you’ll be able to login and control in terminal mode, and to do this there are many ways to connect through SSH but i prefer to use a small application called PuTTY which is free and easy to use.

 

Download PuTTY : Click Here

 

After downloading and installing (Really easy to install not a big deal) you can run this application, you’ll get something like this

 

image.png

 

Enter you VPS or Dedicated Host name of IP on selected input and by default port will be 22 and then hit “Open”, you’ll get a black window like command line and will ask u for a username, put the username u use to login to your Linux then will ask for your password and now you are logged and can issue Linux commands remotely

 

image.jpg

 

Learn to Manage Users, Group and Access Control

Learning how to manage users and groups is very important when dealing with Linux since learning this will save you from a lot of troubles. I’ll try to simplify this as possible.

In Linux in order to login into the system you must have a user credentials just like windows,  so you can have multiple users into a Linux system also this users can be grouped into “Groups”, and whenever a user create a file or something this file will be “Owned” by this user and this is the user who has full permission on this file.

Talking about Permissions there are 3 permission on each file : Read , Write and Execute, each one of this permission has something like a code as follow : Read (4), Write (2) and Execute (1). so for example full permission will be 4 + 2 + 1 = 7 => 7 is the code for Full Permission, 5 means you can Read and Execute but you can’t edit or modify the file, 0 means no permissions at all.

When you wanna set a permission for a file you have to set it also for 3 things in order : Owner, Group and Others.

Owner : Is the user who create the file.

Group : Is users in same group as owner or the group owns the file

Others : Is anyone else

So for example Setting Permission for a file as 777 means everyone has all permissions, 775 means Owner user and Owner Group has full permissions while others can only Read and Execute but not Write or Modify

It’s Always preferable to do your stuff using non-root user, since root user have full permission over system files which may cause problems because it’s a “Super User”, which in shortened called “su”

 

Creating Users :

 

So Let’s create our user that we will use to sort our server, to create a new user you have to be on a “Super User” / Root , and we gonna use command “useradd” and we can specify some options for example :

-m : this will automatically create user home directory if not exist for example > /home/samdev/

-M : this option is used to tell Linux to no create user home directory even if system automatically create home directories for new users

-d : this will allow us to specify custom user home directory location

-U : will create a group with same name of username and add the new user to it automatically

-e : will allow us to set expiring date which will make the account auto expire at a specific date

There are many more options you can use but let’s Start small to keep thing as simple as possible, we gonna now create a user with a username of maxcheaters but issue this command

 

useradd -m maxcheaters

 

If you are not on a root user then prefix command with “sudo” then it will ask you for a root password, prefixing any command with “sudo” means that run this command as a “Super User”

 

sudo useradd -m maxcheaters

image.png

 

Well it’s created, we can confirm this by listing our users by cat the file /etc/passwd

 

cat /etc/passwd

 

 

Also here is a trick to show only usernames by cutting each line by delimiter “:” and print first one only

cut -d : -f 1 /etc/passwd

4.png?w=789&ssl=1

 

Well we have our new user create but actually we didn’t set a password for it , so how we can set a password for a user ? . Simple .. we can use the command “passwd” which stands for Password, and also this needs to be ran as “Super User” so you can prefix with “sudo” if you are not on root

sudo passwd maxcheaters

5.png?w=789&ssl=1

 

Nice, it’s not asking you for the new password, just enter a password and hit enter. then confirm it again

Note : you wont see what you are typing so make sure you are typing it right

 

6.png?w=789&ssl=1

 

Switch Accounts :

 

Now we want to switch to our newly created account, which can be done using command “su” which stands for “Switch User”, don’t get confused about “su” when talking about “Super User” or “Switch User” , when we talk about commands it’s “Switch User” when talking about Terms in Linux Community it’s “Super User”, so here is how to switch to another user

su - maxcheaters

It may ask you for the password, so enter it and hit Enter

 

7.png?w=789&ssl=1

 

Now if we check our current working directory using “pwd” command we will see that we automatically switched to maxcheaters user home directory

 

8.png?w=789&ssl=1

 

About Groups :

 

Each user has two different types of groups, Primary one and Secondary Groups, The primary group is usually a group with same name as username it’s created automatically when user created, this doesn’t mean it can’t be change .. no you can change this primary group but in most cases you wont need to do this. Secondary Groups are the groups that user subscribed to it after being created (ah it makes sense ) , so you can have your group and subscribe to other groups as well.

So first let’s see what groups our new user has by issuing command “id” followed by username

id maxcheaters

9.png?w=781&ssl=1

 

Now we can start working with groups but to do this we need to be on “Super User” mode so we can do things on root which is not very good choice for security concerns or we can give permissions to our new user.

 

Sudo Permissions :

To give a user on a Linux system a permission to run “sudo” commands all we need to do is to switch to root access and add our user to the “sudo” group, so first let’s switch to root, and enter required password

su - root

Now we need to add our user “maxcheaters” to “sudo” group using command “usermod” followed by option -a which means “Append” followed by “G” then group name “sudo” followed by user to add “maxcheaters”

usermod -aG sudo maxcheaters

10.png?w=781&ssl=1

 

Now let’s Switch back to “maxcheaters” user, i guess you know how … right ?

 

su - maxcheaters

Create Groups :

 

Creating is as simple as creating users with the command “groupadd” followed by new group name, note that this command is needs to be executed via a super user and since we switched to non-super user “maxcheaters” then we prefix it with “sudo” to do it as super user, not that it may ask you for the “maxcheaters password

sudo groupadd cheaters

11.png?w=789&ssl=1

 

To get list of all available groups you can cat the file “/etc/group”

cat /etc/group

12.png?w=789&ssl=1

 

Add a User to Group :

 

Huh ?? we already did this , cant you remember ? … well anyway you can add user to a group by modifying user with “usermod” command followed by -aG, followed by group name then user name, and this is also a super user command so you need to prefix with sudo

sudo usermod -aG cheaters maxcheaters

13.png?w=789&ssl=1

 

Remove user from a Group :

To remove user from a group you can use command “deluser” yes it means delete user but no worries if you use it correctly it wont affect user itself, only remove it from a group, also it needs to be used with “sudo”

sudo deluser maxcheaters cheaters

14.png?w=789&ssl=1

 

Delete a Group :

Well we deleted the user from the group but we didn’t deleted the group it self , it still exist so if we wanna to delete the group “cheaters” we can use command “groupdel” followed by group name, also it will delete the group from all users subscribed to it automatically

sudo groupdel cheaters

15.png?w=789&ssl=1

 

Repositories and Software

 

Repositories are some kind of online sources for downloading and getting software, Linux distributions comes with some default repositories that contains most and commonly used software, so it helps you to download software easy and fast and your system will search available or registered repositories for the software you want to install and download it for you.

Note : this part of guide is for Distributions that uses “apt” as packages manager which is very common, some others like for example ArchLinux using “pacman” as packages manager, so if you have a different package manager lemme know the Distribution you use and i’ll try to assist you though it

 

Update APT Database :

 

It’s always good to update your repositories and this means let your system scan registered repositories and see if anything added or changed, and we do this using command “apt-get” followed by “update”

sudo apt-get update

16.png?w=774&ssl=1

 

Install a Software :

 

To install a software you know first to know it’s name (logically ), then you can use command “apt-get” followed by “install” then application name, but actually in Linux community it’s usually called Package instead of application and things like this . so let’s try by installing “unzip” to be able to unzip .zip files

 

sudo apt-get install unzip

17.png?w=773&ssl=1

 

Very simple isn’t , it’s just like that, no annoying pop ups and dialogs … etc

Note : Some Packages during installing will ask you about something needs confirm and you’ll be able to answer by typing “Y” for yes, and “n” for no

 

Uninstall a Package :

 

Maybe at some point you want to uninstall / remove a package installed before, and it’s not hard to do all u need is same “apt-get” command followed by “remove” instead of “install” followed by package name to remove

sudo apt-get remove unzip

But wait a moment cause this is not best way all the times, it can be good at sometimes and not in some other cases, since this way you removing only the package it self ,but sometimes a packages comes with another package and configuration files so to remove it all we can use another way by using “purge” instead of “remove”

sudo apt-get purge unzip

18.png?w=781&ssl=1

 

Installing and Configuring MySQL Server

 

Now it’s time to install MySQL server on our Linux Server, but installing package named “mysql-server”

sudo apt-get install mysql-server

1-2.png?w=781&ssl=1

 

2.png?w=805&ssl=1

 

Congratulations it’s installed, but hold on … it’s not the time to celebrate … we still need to configure it

Currently if we tried to log into our database it will be with username “root” and no password (by default) so it’s time to harden our database security a bit.

 

MySQL Security Hardening :

First thing after installing mysql server on Linux is to harden its default security configurations and this can be done by running the command that comes with mysql installation “mysql_secure_installation” as a super user

sudo mysql_secure_installation

3-1.png?w=805&ssl=1

 

At this part you need to enter the current password of root username (which is none by default ) so just hit enter,  then it will ask you if you want to set a password for the “root” username (root of mysql server not system), just answer with “Y” for Yes

 

4-1.png?w=805&ssl=1

 

Now it will ask you to set a new password for the “root” user, write a password (it wont show so just type it carefully) and Confirm it again

 

5-1.png?w=805&ssl=1

 

Done, and it’s asking you if you wanna remove anonymous users, Of course “Y” we don’t want anonymous access to our database

 

6-1.png?w=805&ssl=1

 

The Good Question is here … Do you want to “Disallow” root user to be logged remotely ? well maybe you need remote access to manage your database from your pc or from any where and i also want that but it’s really a bad idea to allow remote access for “root” so i would say “Y”es Disallow root login remotely and later i’ll tell you how to make a good remote access without root.

 

7-1.png?w=805&ssl=1

 

Do you want to remove test database and access to it ?? Hell yeah who needs a test database .. do you ?

Now Let’s Reload Privileges ?? YES

 

8-1.png?w=805&ssl=1

 

Now our MySQL Server has a better security .

 

Login to MySQL Server

 

We have our Database Server now ,why not trying to login via Linux , Let’s go for it …

Note : this method is applicable to all Operating Systems since it’s related to MySQL it self not OS.

How we gonna do this ? Simple use command “mysql” followed by -h (to identify host default is localhost) followed by host “localhost” followed by -u ( to identify user) followed by username (root is the only one we got now) followed by -p to identify that this username has a password

mysql -h localhost -u root -p

and it will ask you to enter the password just type it and hit Enter

 

9-1.png?w=805&ssl=1

 

Now we can run any MySQL Queries / Commands for example let’s see the databases we have so far

 

SHOW DATABASES;

Note : All MySQL Queries and Commands ends with ; (semi-colon)

 

10-1.png?w=805&ssl=1

 

Create a Database :

 

Since in this Guide i’m planning to demonstrate using aCis Server pack so i’ll create a database called acis_db, using mysql command “CREATE DATABASE” followed by database name

 

CREATE DATABASE acis_db;

11-1.png?w=805&ssl=1

 

Succeed .

 

Create a Database User :

 

Isn’t the time to use another user for MySQL instead of root ?, i guess it’s good idea to create a new user with limited access using this MySQL Command

CREATE USER 'USERNAME'@'HOST' IDENTIFIED BY 'PASSWORD';

USERNAME : is the username you want to create

HOST : This is really important since by default this is “localhost” but doing this wont allow you to connect remotely with this user, since connection from this user will be accepted only if it’s from “localhost”  or same machine , so if you want to allow remote access from anywhere you can set it to (%), or even set it to a specific host if you wanna a very specific security layers

PASSWORD : is where you put this user password

 

12-2.png?w=805&ssl=1

 

Now just Hit Enter after you customize this command as you need … and your new user will be created

 

Give Access on Database :

 

You successfully create a database user, but actually this user by default will have no access on any database so it’s time to give this user access on our “acis_db” database, using “GRANT” command

GRANT ALL ON acis_db.* TO 'maxcheaters'@'%' IDENTIFIED BY 'PASSWORD';

This line of MySQL command means :

Give All Permission on the Database “acis_db” including All (*) Tables to the user “maxcheaters” that have remote access and password of “PASSWORD”

 

13-1.png?w=805&ssl=1

 

Amazing , But to be honest with you this wont affect database instantly , we need to force MySQL server to reload permissions and access by issuing this command

 

FLUSH PRIVILEGES;

 

Maintain Remote Access :

 

We Created our user with remote access , so let’s try to connect to the host with your favorite MySQL Database App, most L2 Admins uses Navicat but i hate that Application so i use an application called HeidiSQL , so just connect with whatever you want …

 

14-1.png?w=775&ssl=1

 

Oh Come on, we created a user with remote access why it’s not working ? ……

Actually we set this user to have remote access but MySQL Server it self is not yet configured to support remote access Support, so let’s Do this. but first quit MySQL Command Line by typing “exit” and hit Enter.

First we need to modify MySQL configuration file which by default on location of /etc/mysql/my.cnf , so i’ll use nano editor for this, as we did before to edit files .

 

sudo nano /etc/mysql/my.cnf

Scroll down a lil bit using Keyboard Arrows til you find “bind-address” and set its value to your public ip or DNS

 

15-1.png?w=805&ssl=1

 

Then Save it using CTRL+O, then Exit Editor using CTRL+X, and to make this changes has effect we need to restart MySQL Server or Service using this command

 

sudo service mysql restart

16-1.png?w=805&ssl=1

 

Now it should work if we test again …

 

17-1.png?w=805&ssl=1

 

Yes it does ….

Note : it you may can’t login to your database server remotely also if your firewall blocked 3306 port, if that’s the case, no worries we will take about Firewalls later.

 

Connect and Install Your Server Database

 

Well i guess you already connected not it’s time to export your database and import it into your new database server.

To do so on HeidiSQL, right click on your local database and click on Export Database as SQL

 

18-1.png?w=775&ssl=1

 

Now Select your Exporting Preferences and Export Location then click on Export

 

19-1.png?w=914&ssl=1

 

After SQL File Exported Now back to your Remote MySQL Session and Select “acis_db” database and activate “Query” Tab

 

20.png?w=914&ssl=1

 

On “Query” Tab Script Area Right Click and Choose “Load SQL File…” and check where you saved the exported SQL Script and then Hit Run Icon

 

22.png?w=914&ssl=1

 

Now your Server Database Installed, Congratulations so far

 

Installing and Configuring Oracle Java

 

Since you have your database up and running we still need Java to be installed on our Linux System to be able to run GameServer and LoginServer, so let’s learn how to install “Oracle” Java successfully .

First some Linux Distributions comes with java already but “Open”JDK not “Oracle” JDK and we need to install Oracle JDK to run without problems, so we can use “apt-get” command as before but the problem is Oracle JDK is not always available on Default Repositories so we may need to add that Repository contains Oracle Java.

 

Adding a Repository :

 

Adding a Repository is just a 1 line command that self explanatory using command “add-apt-repository” followed by repository identifier, and the repository that contains Oracle Java is “ppa:webupd8team/java” , so let’s add this

 

sudo add-apt-repository ppa:webupd8team/java

It May ask you for Confirming just Hit Enter

 

1-3.png?w=805&ssl=1

 

Since we added a new Repository so we may need to update our APT database as we learned before

 

sudo apt-get update

Install Required Packages :

Before Proceeding with installing java we need to install a required package to avoid further errors, this is the “python-software-properties” software

sudo apt-get install python-software-properties

2-1.png?w=805&ssl=1

 

Accept Oracle License :

 

Usually if this is your first time installing Oracle Java then you’ll get Error with exit code of -1, and this is happens since you’re required to accept Oracle License before installing Java, and to do this via Terminal is very easy , i’ll give you the solution, just run this command once

 

echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | sudo /usr/bin/debconf-set-selections

3-2.png?w=805&ssl=1

 

Install Java 8 :

 

Now we can Proceed with Installation normally with “apt-get” command to install the package “oracle-java8-installer”

sudo apt-get install oracle-java8-installer

It may ask you for some confirmations just answer with “Y” for Yes

 

4-2.png?w=805&ssl=1

 

Well it’s Installed Successfully

 

Set Default Java :

 

By default Java 8 will set it self as default but if you have multiple java installation you can change default one using command “update-alternatives” followed by option “–config” to set what you wanna configure followed by “java”

sudo update-alternatives --config java

5-2.png?w=805&ssl=1

 

Here you can type the number of which installation to be default, or leave blank to keep settings as is, and i can see java 8 is selected by default so i’ll keep it as is.

Also you can confirm this by running java version command

java -version

6-2.png?w=805&ssl=1

 

Move and Setup your Server Files

Now things getting more excited .. so let’s stay focused til the end

 

Uploading Files :

Since you need to upload your server so let’s zip our “compiled” server, and now to upload it actually you have many ways it’s all about your taste

 

1st : Using Files Hosting

This way is very simple all you need is just upload to a Files Hosting Service , i prefer mega.nz , or you can use any Hosting you want and go to your Linux Desktop and download it with Firefox (Default Browser for many Linux Distributions) but this way considering that you have Remote Desktop Access to the Linux Server, and you can’t simply use “Windows Remote Desktop” directly since it’s for Windows Only.

Note : You can make “Windows Remote Desktop” able to access a Linux Desktop but installing a package called “xrdp”, but actually it’s very bad and slow

So if you have a way to remotely access your Linux Desktop go for it , if not then i’ll tell you how you can do this using VNC.

 

Installing VNC Server :

VNC Server is a good way to remotely connect to a Linux Desktop and it’s much faster than XRDP, so let’s start installing it

sudo apt-get install tightvncserver

1-4.png?w=805&ssl=1

 

Once installed let’s start it by issuing this command

tightvncserver

2-2.png?w=805&ssl=1

 

At First time it will ask you for a password, enter the password and hit Enter

Note : VNC support only 8 characters length for password, so even if you entered more than 8 characters it will use only first 8 characters

Then it will ask you if you want a view-only password which means with this view only password you can only see the desktop but not interact

 

3-3.png?w=805&ssl=1

 

Now you need to download and install VNC Viewer on your machine to connect to VNC Server where you can Download Here .

Once Downloaded and Install, Run it will you get this window, where you want to add your Linux IP or DNS followed by ( :: ) then default port of 590x then click Connect, where x is the id of your Session ID you got in your Linux when started VNC, for Example “SamDev:1” means port is 5901, SamDev:2 means port is 5902 .

 

4-3.png?resize=430,314&ssl=1

 

After Clicking Connect, it will ask you for the Password you set for this Session , Enter it and Click Ok

 

6-3.png?resize=310,176&ssl=1

 

Now you are finally Connected

7-2.png?resize=1024,830&ssl=1

 

So lets start downloading our Server Zip file

 

8-2.png?resize=1024,830&ssl=1

 

By Default it will be Downloaded to the Current Logged User Downloads Folder

Note : More way will be added soon

 

Let’s go to User Directory and Downloads Folder

 

cd ~/Downloads

9-2.png?w=805&ssl=1

 

Do you still have “unzip” installed ? np if you removed it install it again

sudo apt-get install unzip

10-2.png?w=805&ssl=1

 

Unzipping a Zipped File :

To unzip a file using unzip package it’s really easy

unzip ACIS_Live.zip

11-2.png?w=805&ssl=1

 

Rename File/Directory :

Do you need to rename this folder to L2Server for example ? no problem we didn’t mentioned this but it’s very simple since there is no direct command for renaming but instead we use the moving command “mv”

mv Live L2Server

12-3.png?w=805&ssl=1

 

Create Starting Shells [OPTIONAL] :

Well this Step is optional but i prefer to do it like this since original Shell Scripts are running automatically running with no-hup ( No Hanging Up ), which is really good but actually i prefer to do this manually and to have default Shell Scripts beside the custom HUP Scripts specially in development Level.

So let’s Create our Shell for GameServer, First head to “gameserver” directory

cd ~/Downloads/L2Server/gameserver

and then i’ll use nano to create and edit a new Shell Script file .

Note : Shell Files should end with .sh extension

nano StartGame.sh

Then Add this Script

 

#!/bin/bash
java -Xmx2G -cp ./libs/*:l2jserver.jar net.sf.l2j.gameserver.GameServer

13-2.png?w=805&ssl=1

 

Now Save and Exit : CTRL + O > CTRL + X

 

14-2.png?w=805&ssl=1

 

Let’s Head to login Directory and do almost same

 

cd ../login

15-2.png?w=805&ssl=1

 

And Create our Login Shell

 

nano StartLogin.sh

and Add this Script

 

#!/bin/bash
nice -n -2 java -Xmx512m -cp ./libs/*:l2jserver.jar net.sf.l2j.loginserver.L2LoginServer

16-2.png?w=805&ssl=1

 

Save and Exit Again : CTRL+O > CTRL+X

 

Configure Server :

Now you need to Configure your server Database Information, which is located in

Login : login/config/loginserver.properties

GameServer : gameserver/config/server.properties

 

Configure Game Server :

Change Directory to Game Server Config Folder

cd ~/Downloads/L2Server/gameserver/config

Then i’ll use Nano to Edit server.properties

nano server.properties

Locate this Configs and Change them with your database name , username and password

 

17-2.png?w=821&ssl=1

 

When you done > CTRL + O to Save, CTRL + X to Exit

 

Configure Login :

Change Directory to Game Server Config Folder

cd ~/Downloads/L2Server/login/config

Then i’ll use Nano to Edit loginserver.properties

nano loginserver.properties

Locate this Configs and Change them with your database name , username and password

 

18-2.png?w=821&ssl=1

 

When you done > CTRL + O to Save, CTRL + X to Exit

 

Allow Shells to be Executable :

Before you start server you need to know that in Linux you need to run .sh scripts instead of .bat, and by default .sh has no permission to run so we need to give those files permission to run using command “chmod” followed by permissions followed by file name, but changing each file would be time consuming so here is a trick to set a permission for all .sh files in one line by adding a wildcard in file name (*), so let’s first go to gameserver directory

cd ~/Downloads/L2Server/gameserver

Then we change permissions for .sh files

sudo chmod -R a+x *.sh

19-2.png?w=821&ssl=1

 

Now our .sh files turned Green which means it’s executable. So let’s do Same with login directory

cd ../login
sudo chmod -R a+x *.sh

20-1.png?w=821&ssl=1

 

Congratulations i think your server now is well configured.

Run and Stop Server

Well let’s log to our server via VNC as we learned before , remember ? then open your terminal

Note : if you wanna do this via SSH, you can use a package called Screen , Find more

 

Run Login Server

First we need to go to our login folder of the server

cd ~/Downloads/L2Server/login

21.png?w=848&ssl=1

 

Now we need to execute our Shell Script, you can execute original one or our created one depends on the situation and stability level of your server, so it’s all up to you

sudo ./StartLogin.sh

22-1.png?w=848&ssl=1

 

Great, Login Server is Running, now time for Game Server.

 

Run Game Server

Open a New Terminal or a new Tab, File > new Tab or CTRL + SHIFT + T

23.png?w=848&ssl=1

 

on the New Tab go to gameserver Directory location

cd ../gameserver

24.png?w=848&ssl=1

 

Now time to start gameserver

sudo ./StartGame.sh

25.png?w=848&ssl=1

 

You L2 Server is not up and running

 

Close Game / Login Server :

To Close either Login or Game Server just close the terminal or click CTRL+C to close but keep Terminal open.

Installing and Configuring Apache2

To get Apache Server or a Web Hosting Server you can simply install LAMPP , it’s full package of Apache, PHP and MySQL together, but personally i don’t like to go this way, since i always prefer to go with non-preconfigured stuff to be able to have full control over every little detail, also it will be good for you to know how everything work and how they linked smoothly together.

 

Install Apache2 :

Installing Apache2 is same as installing any package we did before

sudo apt-get install apache2

1-6.png?w=814&ssl=1

 

Apache2 Installed Successfully now let’s Install PHP as well .

 

Install PHP 7 :

 

In this Guide i’ll install PHP 7, but you can install older versions if you want, it’s just same procedures ..

First we need to add the Repository that has what we need

sudo add-apt-repository ppa:ondrej/php 

2-3.png?w=814&ssl=1

 

Now let’s Update our Repositories Database

sudo apt-get update

After that we gonna install PHP 7 along with some PHP Extensions needed commonly :

sudo apt-get install php7.0 php7.0-cli php7.0-common libapache2-mod-php7.0 php7.0-mysql php7.0-fpm php7.0-curl php7.0-gd php7.0-bz2

Here i’m installing PHP 7.0 with some extra PHP library all in one command, then we need to host our site…

 Host your Site and Domain

First of all you need to have your domain which can be bought from any provider, i would suggest GoDaddy.com , very good services, skilled support team and really fast orders and problems processing.

For this guide we will try to host the domain “lineage.ninja” on our Linux Server, so first go to your domain provider panel , in this case it’s GoDaddy, so go to your domains and click “DNS” :

 

3-6.png?resize=1024,377&ssl=1

 

Now we need to modify the “A” record

 

4-4.png?resize=1024,518&ssl=1

 

When you get into edit mode, add your server IPv4 into Value/Points to. then save.

 

5-3.png?resize=1024,518&ssl=1

 

Sometimes this modification takes time to propagate but in GoDaddy as i been using it for many years i found that it’s one of the fastest, most of times it takes less than 10 seconds to take effect. so let’s see if our domain working and connected to our server

 

6-4.png?resize=1024,518&ssl=1

 

Yeah, as it says “It works!”  … But why it show the main page of server, we need it to have a separate content … well then let’s do this

 

Create Apache2 Host :

To Create an Apache2 Host we need to follow few step, by creating the directory that will contain our site files, then we create a configuration file for this site to tell Apache how this site will work and where its files located, then we have to enable it.

So First let’s create a directory that will host our site , by default Apache look in files inside Directory /var/www , so i’ll create a directory on the path of /var/www/lineage.ninja/public_html , and in this case we gonna use the command “mkdir” to make a directory with option “-p” to automatically create all parent directories required for us.

sudo mkdir -p /var/www/lineage.ninja/public_html

7-3.png?w=771&ssl=1

 

Maybe now we need to change Owner and Permission to avoid further problems

sudo chown -R $USER:$USER /var/www/lineage.ninja/public_html
sudo chmod -R 755 /var/www/lineage.ninja/public_html

8-3.png?w=771&ssl=1

 

Now we need to create the configuration file, so let’s start by copy the default configuration file.

sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/lineage.ninja.conf

9-3.png?w=771&ssl=1

 

We need now to edit that configuration file …

sudo nano /etc/apache2/sites-available/lineage.ninja.conf

10-3.png?w=781&ssl=1

 

Note : All Lines starting with ( # ) is just a comments, so it wont affect anything, you can remove it or leave it , doesn’t matter

At this moment we need to modify this file to look like this

 

11-3.png?w=781&ssl=1

 

CTRL+O to Save, CTRL+X to Exit …

One more step to go .. we need now to Enable our new site using command a2ensite (Apache2 Enable Site).

sudo a2ensite lineage.ninja.conf

12-4.png?w=781&ssl=1

 

To Take Effect we need to restart our Apache2 Server

sudo service apache2 restart

Let’s Create a simple php file to test …

sudo echo "<?php echo 'Greetings from PHP';?>" > /var/www/lineage.ninja/public_html/index.php

So time to test …

 

13-3.png?w=781&ssl=1

 

Yes, it's working :)

Thanks for taking a look into this guide and i hope it's useful for someone out there ... lemme know if you got question and i'll update this topic soon with more parts

 

Thanks and Regard,

 

Edited by SamDev-Coder
Updating and Fixing Images
  • Upvote 2
  • 3 weeks later...
  • 3 weeks later...
  • 7 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...