[Tutorial] SA:MP Server on a Linux Based Server
#1

Hello guys, galls and trolls.

Due to most people's aversion to Linux, and the SA:MP Wiki entry is unsympathetic towards Linux newbies, I've decided to throw together a real-world, step-by-step tutorial on how to set up a fresh Linux VPS/Dedicated Server with SA:MP.
However, explained a little more simply.

This may be quite long and detailed, but that's mainly so people freaked out by the command line interface actually understand what's going on.
Throwing in random commands won't help anyone in the long run, especially when things go wrong
Also, this server is made in the point of view of a Windows user. Users running Mac OSX/Linux, adjust certain areas accordingly.

So! With the introduction out of the way, let's begin.



UPDATE: I've added a web server tutorial later on in the thread.

Disclaimer:
This tutorial uses a VPS outside of the Cake.io Network.
In fact, it's a 64MB VPS from Inception Hosting. That's right kids, 64MB.
I, however, do not recommend using such a low specced system for production use.


Step 1: Hello, Linux.

Quote:

Presuming you've just rented an unmanaged VPS or Dedicated Server running Linux, they'll usually provide you with SSH login credentials, as well as your IP.
SSH stands for Secure Shell; think of it as a logging into a PC's cmd.exe remotely.

To log in to your server through SSH, you'll need an SSH client.
The most common SSH client for Windows is PuTTy, which you can download from...
http://www.chiark.greenend.org.uk/~s.../download.html
Quote:

Let's fire up PuTTy!


As you can see, from that lovely image, you'll need to put in your Server's IP in the Hostname field, in addition, make sure the connection type is SSH.
The default port for SSH is 22.

Once you're ready, hit 'Open'.

Quote:

You'll then be approached by the login prompt.
Type in 'root', hit enter, and then type in your password.
Note: The characters will not show when being typed.

If all goes well, you'll be logged in. Horray!

Step 2: User Accounts
Quote:

Generally speaking, running anything as the root user is a bad idea from a security point of view.
Because of this, let's create an account for the user.

Quote:

Supposing you want to create an account called 'samp', you'll use this command.
Code:
adduser -m samp
If you're running a Debian based system, remove the -m switch in the above command, and it'll also automatically prompt you to make a password.
If you're running a RedHat based system, like CentOS, you'll then want to give it a password, so you'll need to use this command.
Code:
passwd samp
Follow the onscreen prompts, and hey presto, you've got a user account for SA:MP

It would've looked a little bit like...

Step 3: Let's get SA:MP

Quote:

Got this far? Great! We're right on track to downloading SA:MP.

Firstly, you'll need to close the existing login to your root user acount, and log-in to your SA:MP user account.
So open up PuTTy, enter your server's IP address, log in with the username and password you just created.

In this section, you'll also learn how to download files, copy/paste in PuTTy, and avoid typing in incredibly long file names.
Brilliant stuff

Quote:
Download the server package.
To download files on a Linux based system, we'll use 'wget', since it's pretty simple and straight forward.

Navigate to the SA:MP downloads page, and find the link to the Linux server package.
Right click the link, click on 'Copy Link Address' and then go back to the PuTTy window.

Start by typing in wget, hit the space bar, and then right click onto the PuTTy window.
This pastes the link you've just copied, saving you a load of time from typing it out.
To execute the command, and download the files, just hit enter.

Your command should've looked something like this:
Quote:
Extracting the files
So, you've successfully downloaded the file, but what on Earth is that .tar.gz extension?!
Think of it as a file, within a file. The 'tar' part is basically cello-taping the files together, whilst the 'gz' part compresses the 'tar' file with Gzip compression.

To extract it, it's pretty darn simple, although the tar commands are horrible to look at.
But Hey, watch out kids, here's another Linux trick to show your friends. Remember I said I'll show you how to avoid typing out awkwardly long file names? Here we go.

You'll need to start out by typing 'tar zxf'
Press space.
Then type the first couple letters of the server package (sa) then hit tab. As if like magic, the full filename has appeared.
Now just hit enter, and the package will silently extract itself.

The command should've looked a bit like
Code:
tar zxf samp03dsvr_R2.tar.gz
To see where the files have gone, use the 'ls' command, and it'll show you the files in the directory you're in.

Quote:

Here's a screenshot showing what just happened on my screen.

Notice at the end, I've used the 'ls' command.
It's showing the .tar.gz file we downloaded, and the samp03 directory that's been extracted.

Step 4: First Start-up
Quote:

So, you want to get the server started up?
Fair enough. Let's get to it.

You'll need to change your directory to the samp03 directory.
Quite simply, use the following command:
Code:
cd samp03
Quote:
Editing the server.cfg
As you're most likely aware, if you use the default server.cfg file when trying to start the server up, it'll complain and refuse to run, because you haven't changed the default password.

So, let's use a simple editor called 'nano' to edit the server.cfg
Code:
nano server.cfg

A screen looking like that should've popped up.
You'll be happy to know, that you can browse around the server.cfg by using your arrow keys, and just typing to edit the file. Simple stuff, right?

Once you've finished editing the file, hit CTRL+X, press 'Y', then Enter.
Your file is now saved!

Quote:
STARTEN THE SERVER!
Although an interesting command, it won't get your server started.
At the very least, because you don't have the correct permissions to launch the server.

That's right, you'll need to let your system know that the SA:MP binaries are allowed to be ran.
Luckily, it's just this simple command, where '-x' denotes 'executable'

Code:
chmod +x samp-npc samp03svr announce
Now you've got the formalities sorted, you can use the nohup command to run the server in the background.
This means it'll run without any intervention, and you can close your PuTTy session without the server closing.

An example command would be
Code:
nohup ./samp03svr &
Yes, the & was intentional
Congratulations, you now have a server running.
Here's a few things you'll probably want to do post-setup:
  • Upload GameModes/FilterScripts/Plugins
  • Install a MySQL Server
Quote:
Uploading Files to your Linux Based Server
Although I've previously shown wget as a method of getting files onto your server, it isn't convenient when you're updating your script, or just uploading a few filterscripts.
It should be noted, that you don't need FTP to do this, oh no. Most SSHd's come with a SFTP server built in, so there's nothing you need to install on your server

Anyhow, let's get to it.
You'll need to get a SFTP client, for the sake of simplicity, go download FileZilla
In your FileZilla window, enter your server's IP, your SA:MP username, and your password into the QuickConnect bar. Remember, you're using Port 22, since you're still using SSH.

Navigate to your samp03 server folder, and drop your files into the correct folders.
Remember, Linux is CaSe SeNsItIve. LVDM isn't the same as lvdm.
Also, you need to set the correct permissions.

Make sure your 'scriptfiles' folder is writeable.
Right click the folder, and ensure that both read and write permissions are set.

Make sure any plugins are executable
Right click the file, and ensure the executable permissions are set

Quote:
Installing a MySQL Server, properly.
'Properly?!' You say with shock? Yes. If you're running a Debian or CentOS, and decide to 'apt-get' or 'yum' the MySQL server packages, you'll most likely get a very old version.
Since the latest plugins generally need newer versions, and the performance of the latest MySQL versions are significantly better, it's worth spending an extra couple minutes to do things properly.

Debian Systems
We're going to add the DotDeb repository to our apt-get sources.
The bloke who runs it compiles the latest Web-Server packages and serves them up for free, but you'll need to enable it first.
Oh, also, this is for Debian 6 (Squeeze) only. If you're running Debian 5 (Lenny), it's time to upgrade. It's reached it's end of life.

Using the root account, we'll need to add a couple lines to our /apt/sources.list file.
So, use nano to open the file:
Code:
nano /apt/sources.list
and then put these two lines at the end of the file
Code:
deb http://packages.dotdeb.org squeeze all
deb-src http://packages.dotdeb.org squeeze all
You'll then need to let Debian know that this package repository is safe
Download the PGP key:
and add it.
Quote:

cat dotdeb.gpg | sudo apt-key add -

and now you'll want to install the MySQL server. Simples!
Code:
apt-get update
apt-get install mysql-server
RedHat Based Systems (CentOS/Scientific Linux)
We'll be using the Atomic Repo for the latest MySQL packages, luckily, the installation is a little more straightforward than Debian.

Download the Atomic Repo Installation Script:
Then run it
Code:
bash atomic
Now you'll want to install the MySQL server. Easy Peasy.

Code:
yum update
yum install mysql-server
Conclusion

If you've followed this tutorial correctly, you'll have set up a SA:MP server, and installed the MySQL server as well.

If I have time, I'll update this to include administrating the MySQL server using Phpmyadmin, but it'll involve installing a web server, and optimising it to reduce memory usage.

If you have any questions, pointers, or things you think I've missed out, reply to the thread.
Someone might be thinking the same thing

Anyone, I hoped I've helped someone out.
Good luck!
Reply
#2

Nice. I was trying to learn to use Putty some how..
Reply
#3

This was a great Linux tutorial!
Reply
#4

Thanks for the feedback guys, it's appreciated

Quote:
Originally Posted by niyaz
View Post
Nice tut
Who can make my IP Stay the same? Im home hosted
Well, you could phone up your ISP and ask politely for a static IP.
Alternatively, you could find a way to stop your modem from rebooting/disconnecting/turning off, which might prolong your IP lease.
Reply
#5

Could you explain to me abt setting permissions? i get permission denied on sub-user accounts
Quote:

Make sure your 'scriptfiles' folder is writeable.
Right click the folder, and ensure that both read and write permissions are set.

Make sure any plugins are executable
Right click the file, and ensure the executable permissions are set

Reply
#6

That is good and all, but how do you turn it off?

Edit: Nevermind, use the "kill" command followed with the PID.
Reply
#7

Quote:
Originally Posted by [UE]Milan
View Post
Could you explain to me abt setting permissions? i get permission denied on sub-user accounts
If you can't change permissions on the sub-account, you can hop on the root account and use
Code:
cd /home/sub-user/path-to-samp03
and then chmod as usual. It should work just fine on the sub-user though.
Reply
#8

Hmm, It worked on CentOS, but I tried it on Ubuntu and this is what it says: "nohup: failed to run command `./samp03svr': No such file or directory" I have the file in the directory.
Reply
#9

That's a complete and detailed tutorial. Thanks, will help the newbies.
Reply
#10

Dosent this thread deserve to be a sticky?
Reply
#11

Quote:
Originally Posted by Samp_India
View Post
Dosent this thread deserve to be a sticky?
It does.
A question to OP: Are you going to cover the installing webserver for PHPmyAdmin anytime soon?
Reply
#12

Quote:
Originally Posted by DaRealShazz
View Post
It does.
A question to OP: Are you going to cover the installing webserver for PHPmyAdmin anytime soon?
Code:
yum -y install httpd
service httpd start
Reply
#13

I have one question, if I'm trying to make a server based on a Linux server, and the gamemode was originally created for Windows, is there any chance that it'll work for Linux?
Reply
#14

Quote:
Originally Posted by Genuine
View Post
I have one question, if I'm trying to make a server based on a Linux server, and the gamemode was originally created for Windows, is there any chance that it'll work for Linux?
Gamemode will work but you will need to find the Linux version of the plugins.
Reply
#15

Thanks But How Can i GMX?
Reply
#16

Very profissional thread - good job
Reply
#17

Good work bro/lady. I am using putty from now
Reply
#18

Good work!
Reply
#19

i really Need To GMX my Server
Any SSH Command? Please HelP! (((((
Reply
#20

GREAT ! I LOVE YOU TUTORIAL Thanks men ! REP +++
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)