Error message

Deprecated function: The each() function is deprecated. This message will be suppressed on further calls in book_prev() (line 775 of /home/mindpiss/mindpiss.com/modules/book/book.module).

My first unmanaged Virtual Server - I. Pre-thoughts

My initial thoughts are:

- http server (apache, Lighttpd or nginx)
- php
- mysql
- phpmyadmin
- mailserver
- webmail
- maybe ftp/sftp server
- maybe my own nameserver (or maybe continue to use the hosts or registrars?)
- possibly tomcat / jre
- security!! (unmanaged means I have to make sure my VPS stays hack-free)

Having only limited linux experience (i've only used bin/bash and .sh scripts to administer, update and backup my current hosting accounts) I googled and found many examples for how to set up the products I wanted. But they all semed to be slightly different, so I decided to keep a record for myself as to how I did it:

Log in to your VPS as root user using SSH (PuTTY for example).
Now the very first thing to do is to change your 'root' user password. Since you are already logged into your VPS as the user 'root' you can simply do this by typing:

# passwd

Enter your new UNIX password twice and make sure you have it stored safely. Do not forget or lose this password!!

Now let's create a new user. Using 'root' to log in is not good practice!
We'll use the 'adduser' script instead of the 'useradd' command. (the script gives you a setup menu to configure the user)

# adduser USERNAME

Add the password, but you can leave the other options blank, maybe add the full name if any.

Now we want to give this user admin rights by editing the '/etc/sudoers' file.
If the file does not exist, you probably havn't installed sudo yet, so do that first:

# apt-get install sudo

Now edit the sudoers file:

#  pico /etc/sudoers

To add the sudo (admin) rights to your new user, add a new line below

root    ALL=(ALL) ALL

Now add your new user like so:

root    ALL=(ALL) ALL
USERNAME    ALL=(ALL) ALL

Ctrl+o to save the file and Ctrl+x to exit.
Now exit and log back in with the new user you just created and avoid logging in with root from now on, but use sudo to grant admin rights to specific processes.

Change your SSH port from the default 22 to something else.

# sudo pico /etc/ssh/sshd_config

Change 'Port 22' to a number of your choice - you will need to remember it for putty / sftp connections:

# What ports, IPs and protocols we listen for
Port 54321

and disable root login by changing 'PermitRootLogin' to 'no'

PermitRootLogin no

make sure this line is uncommented:

PasswordAuthentication yes

and set

X11Forwarding no

Now add the following lines at the end of the file:

UseDNS no
AllowUsers USERNAME

Obviously replace USERNAME with then admin user you created before!

Ctrl+o to save the file and Ctrl+x to exit.

Now make sure your server is up to date by running:

# apt-get update && apt-get upgrade --show-upgraded

Now we're ready to get started ...