SA-MP Forums

Go Back   SA-MP Forums > SA-MP Server > Server Support

Reply
 
Thread Tools Display Modes
Old 20/03/2012, 04:45 PM   #1
VOXrr
Big Clucker
 
VOXrr's Avatar
 
Join Date: Dec 2010
Location: /var/Manchester/UK/
Posts: 191
Reputation: 51
Default [Tutorial] SA:MP Server on a Linux Based Server

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:
Code:
wget http://team.sa-mp.com/files/samp03dsvr_R2.tar.gz
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:
Code:
wget http://www.dotdeb.org/dotdeb.gpg
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:
Code:
http://www.atomicorp.com/installers/atomic
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!

Last edited by VOXrr; 25/08/2012 at 11:41 AM. Reason: Fixed images
VOXrr is offline   Reply With Quote
Old 20/03/2012, 05:28 PM   #2
[UE]Milan
High-roller
 
[UE]Milan's Avatar
 
Join Date: Jan 2012
Location: Right in front of forum.sa-mp.com
Posts: 1,214
Reputation: 160
Default Re: [Tutorial] SA:MP Server on a Linux Based Server

Nice. I was trying to learn to use Putty some how..
[UE]Milan is offline   Reply With Quote
Old 21/03/2012, 02:01 PM   #3
ColorHost-Kevin
High-roller
 
ColorHost-Kevin's Avatar
 
Join Date: May 2011
Location: Hollywood,MD
Posts: 1,599
Reputation: 138
Default Re: [Tutorial] SA:MP Server on a Linux Based Server

This was a great Linux tutorial!
__________________
█| Colorhost Premium Web Hosting And Cheap SAMP Servers in US and NL! 100 Slots For $7.95! With Hosted tab for $25.35!
█| Offering Services to customers since 2009! - Now Supporting Direct Credit Card Payments and Bitcoin!
█| Check us out today! https://colorhost.co
ColorHost-Kevin is offline   Reply With Quote
Old 21/03/2012, 02:56 PM   #4
VOXrr
Big Clucker
 
VOXrr's Avatar
 
Join Date: Dec 2010
Location: /var/Manchester/UK/
Posts: 191
Reputation: 51
Default Re: [Tutorial] SA:MP Server on a Linux Based Server

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.
VOXrr is offline   Reply With Quote
Old 25/04/2012, 09:03 AM   #5
[UE]Milan
High-roller
 
[UE]Milan's Avatar
 
Join Date: Jan 2012
Location: Right in front of forum.sa-mp.com
Posts: 1,214
Reputation: 160
Default Re: [Tutorial] SA:MP Server on a Linux Based Server

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

Last edited by [UE]Milan; 25/04/2012 at 10:54 AM.
[UE]Milan is offline   Reply With Quote
Old 01/06/2012, 05:12 PM   #6
DaRealShazz
Big Clucker
 
DaRealShazz's Avatar
 
Join Date: Jan 2012
Posts: 173
Reputation: 55
Default Re: [Tutorial] SA:MP Server on a Linux Based Server

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

Edit: Nevermind, use the "kill" command followed with the PID.
DaRealShazz is offline   Reply With Quote
Old 01/06/2012, 07:53 PM   #7
3ventic
Huge Clucker
 
3ventic's Avatar
 
Join Date: Jun 2009
Location: Finland
Posts: 318
Reputation: 70
Default Re: [Tutorial] SA:MP Server on a Linux Based Server

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.
__________________
Follow me on *******
3ventic is offline   Reply With Quote
Old 02/06/2012, 01:10 AM   #8
DaRealShazz
Big Clucker
 
DaRealShazz's Avatar
 
Join Date: Jan 2012
Posts: 173
Reputation: 55
Default Re: [Tutorial] SA:MP Server on a Linux Based Server

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.
DaRealShazz is offline   Reply With Quote
Old 02/06/2012, 03:57 AM   #9
Inverse
Huge Clucker
 
Inverse's Avatar
 
Join Date: Jun 2011
Location: Braavos
Posts: 251
Reputation: 19
Default Re: [Tutorial] SA:MP Server on a Linux Based Server

That's a complete and detailed tutorial. Thanks, will help the newbies.
__________________
[FS] xPlosions - NEW!
Inverse is offline   Reply With Quote
Old 02/06/2012, 04:07 AM   #10
Samp_India
High-roller
 
Samp_India's Avatar
 
Join Date: Feb 2012
Location: South India
Posts: 1,222
Reputation: 191
Default Re: [Tutorial] SA:MP Server on a Linux Based Server

Dosent this thread deserve to be a sticky?
__________________

Free Hosting For Linux SA-MP Game Server
Locations: Canada,France,USA and UK.
Checkout the fresh freecharge and paytm codes.
Samp_India is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
A roleplay server based on a military based war? CobraAziz General 21 05/05/2012 06:15 AM
[Tutorial] Server Restarter for linux ZuppR Server Support 13 10/02/2011 12:05 AM
Is there a way to run gta and samp on linux based os ? Leeroy. General 2 26/12/2010 04:53 PM
Server wont load plugins for linux on linux server! GrantLea Help Archive 3 24/10/2010 10:55 PM
samp linux server 03r5 doesn't run on 64 bits linux edelcat Server Support 2 08/09/2010 09:22 AM


All times are GMT. The time now is 06:19 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.