Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running your first OT on Ubuntu Linux #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
214 changes: 214 additions & 0 deletions running-your-first-ot-server/setup-webserver-linux.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
# Getting started
Rent a Ubuntu Server 18.04 or higher from a trusted hosting company or install for the sake of learning experience Ubuntu Server 18.04 or higher in VirtualBox.

Once you're set we will start by accessing our server. If you're on windows you should get putty(https://www.putty.org/), if you're on macOS or Linux you can use the terminal which is standard available. With putty just follow the screen ( insert your domain/ip-address and click ok ) for macOS and linux users type:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be safer to recommend using Windows Subsystem for Linux as a native SSH client or simply installing SSH client via Windows features.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you have a point indeed! WSL is safer, but putty would be easier for new people. It would be your call what you would like to be better in there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lot's of typos:

  • PuTTY not putty
  • No spaces inside ( and )
  • IP address not ip-address
  • click "OK" not click ok
  • Linux not linux

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a link to PuTTy instead


```bash
ssh username@domain/ipaddress
```
`username example => root
domain/ipaddress example => yourdomain.com or 127.0.0.1`

Now you will be prompted for your password (if in putty you will be prompted for the password as soon you click on Open) Insert your password and presh enter (you will not see what you type, so make sure you type your password in the right order). Now we are in our server :)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PuTTY misspelled
Missing full stop at the end of sentence.
presh -> press


## Update and Upgrade the system
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing newline after header

The first thing we will do is updating our Ubuntu Server with the following command
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

command: (colon missing)

```bash
sudo apt update && sudo apt upgrade -y
```
We are using 'sudo' since I do not know if you're running as root user or as regular user. When you're logged in as regular user. No problem! Just enter your password when the terminal asks for your password. With the command above you will update the connected repository's the server is connected to and when the server is done updating the repository's it will directly upgrade all the packages which were updated.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something here doesn't flow/make sense.
The guide should specify whether to work as root or regular user.


# Installing the webserver

Now we will get to the more difficult part of the entire server setup, installing nginx, php-fpm, mariadb-server with phpmyadmin.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Omit Now we will get to the more difficult part of the entire server setup - not informative.

```bash
sudo apt install nginx php-fpm mariadb-server -y
```
The installation process is now triggered.When this is finished we will install phpmyadmin to handle our database server
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typos

```bash
sudo apt install phpmyadmin -y
```
Now we are set to get some configurations going!

## Configuring the webserver

First we want to know which version of php-fpm is installed we will check this by writing the following command in the terminal
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package names should be marked as "code" with the tilde, e.g.: php-fpm

```bash
sudo php -v
```
The output will be looking similar to this:
```
PHP 7.2.24-0ubuntu0.18.04.3 (cli) (built: Feb 11 2020 15:55:52) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.24-0ubuntu0.18.04.3, Copyright (c) 1999-2018, by Zend Technologies
```

Second we want to do is enabling php in our nginx server and setting the configuration just as we want. So we will be going to edit our nginx config. Now we need to install a command line text editor called "vim". After that we installed it we will directly open the configuration file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nano is easier than vim but it's just a matter of preference.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I struggle with nano 🔢

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you know your audience already knows vi, nano is the safe bet. The audience that already knows vi probably wouldn't need this portion of the guide in the first place.

Though, if you are aiming for the neophytes and you know they are using modern systems, such as Ubuntu 20.04LTS, micro should take precedence over nano.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP not php

```bash
sudo apt install vim -y && sudo vim /etc/nginx/sites-available/default
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to chain commands, just put them in two separate lines.
Explaining what && does is unnecessary here, so let's just not use it.

```

I am going to give you a few options in the configuration. Underneath here you will find the default configuration file of nginx. ( I only took the part of the config file we are in need to use and left out all the comments which we do use in this tutorial )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
I am going to give you a few options in the configuration. Underneath here you will find the default configuration file of nginx. ( I only took the part of the config file we are in need to use and left out all the comments which we do use in this tutorial )
Below you will find the default configuration file of nginx (only relevant parts are shown, comments ommitted).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to avoid first-person narrative ("I did"), author is not important here.


## Changing the web-root
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally this section is not "necessary" as most people and guides do indeed keep the web root in /var/www/ / /var/www/html/ and rarely ever people need to put more than one "website" on a VPS for OTS.


We can change the 'root' directory of the website folder, if you're only using your server as root leave it in '/var/www/html'. When using it as for example 'john' you can change the directory to your default directory when you come when you login which is: '/home/john' in the default directory of john you can do 'mkdir www' to create a directory for the website and set: '/home/john/www' on line '5' instead of '/var/www/html'.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Linux, the term in use is directory, not folder. Since this is technical documentation, you have to try to use proper terms.


## Configuring php

I already enabled php here by writing 'index.php' on line number '24'. I've uncommented the php location settings we need to use. To make it easy and understanding I made own comments for you guys to know which lines to comment and uncomment, depending on which Ubuntu Server version you are running ( and assuming you're using Ubuntu Server 18.04 LTS ).
```bash
server {
listen 80 default_server;
listen [::]:80 default_server;

root /var/www/html;

# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;

server_name _;

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}

# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
################## UBUNTU 18.04 LTS ##################
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
################## UBUNTU 20.04 LTS ##################
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

}

}

```
Now we have to save the file and quit the file, we do this the following way:
`CTRL+C` After that you will just write `:wq` press enter and we have saved and quit the file :)

We are set with the entire webserver now and so its time to check if we actually did everything as we supposed to do, but first we have to restart our web features. We do this with the following commands:
`Change the number of the php-fpm version to one you're using!!!`
```bash
sudo systemctl restart nginx
sudo systemctl restart php7.4-fpm
```
Lets open our browser and goto your ip-address and see how wonderful you are!
Your very own setup and configured server!

# Setup the database user + phpmyadmin

We need to create ourselves a mysql admin account. We will be doing this the following way. Please follow the steps carefully :)

```bash
sudo mariadb
```

###### You are inside the database right now!

We will be creating the user 'otadmin' with the password of 'otadminpassword', change these values to what you want it to be!
```bash
create user 'otadmin'@'localhost' identified by 'otadminpassword';
grant all privileges on *.* to 'otadmin'@'localhost';
flush privileges;
exit;
```
Insert these lines one by one.
Now we have setup our database superuser :)

## Configure phpmyadmin

Setup phpmyadmin to access your database via the browser.

Insert the following configuration in a new file inside the nginx folder. The following command will create the file and when you are in insert the configuration posted below.
( same as for the webserver nginx configuration I have made comments for the ubuntu versions inside the php location )
`sudo vim /etc/nginx/sites-available/phpmyadmin`
```bash
server {
listen 2344;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this port?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just took a random port, can be changed to what you desire.

server_name _;
root /usr/share/phpmyadmin;

add_header X-Frame-Options DENY;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";

client_max_body_size 256M;
error_page 404 @notfound;

location / {
index index.html index.php;
try_files $uri $uri/ /index.php?$args;
}

location ~* \.(gif|jpg|jpeg|png|bmp|js|css)$ {
expires max;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;

################## UBUNTU 18.04 LTS ##################
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
################## UBUNTU 20.04 LTS ##################
# fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

}

location @notfound {
return 404 "You're not browsing correctly.";
add_header Content-Type text/plain always;
}

}
```
Now we have to save the file and quit the file, we do this the following way:
`CTRL+C` After that you will just write `:wq` press enter and we have saved and quit the file :)

Now we have to enable the phpmyadmin configuration for nginx we do that by running the next command:
`sudo ln -s /etc/nginx/sites-available/phpmyadmin /etc/nginx/sites-enabled/phpmyadmin`

Finally restart the nginx server with `sudo systemctl restart nginx` and we will be able to access phpmyadmin by http://youripordomain:2344 login with the database username and password we've created.

# Setup your Server for TFS

First of all we need to install a few packages to our system which makes us able to build the TFS sources.

Directly copy'd from the TFS github wiki(https://github.com/otland/forgottenserver/wiki/Compiling-on-Ubuntu):

## Install the required software
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content from this line is duplicated - it's already documented in the TFS wiki, which we might move over to the OTS Guide.

It's not wrong but it will quickly get outdated. It's best to link to the wiki which is kept up to date.
In fact, the package list is already outdated below and the instructions wouldn't work.


The following command will install Git, CMake, a compiler and the libraries used by The Forgotten Server.

Git will be used to download the source code, and CMake will be used to generate the build files.
```bash
sudo apt install git cmake build-essential libluajit-5.1-dev libmysqlclient-dev libboost-system-dev libboost-iostreams-dev libboost-filesystem-dev libpugixml-dev libcrypto++-dev
```

## Download the source code

```bash
git clone --recursive https://github.com/otland/forgottenserver.git
```

## Generate the build files

```bash
cd forgottenserver
mkdir build && cd build
cmake ..
```

## Build
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try to leave one empty line above every header.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍


```bash
make
```