1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Quick and dirty guide to setting up a VPS

Discussion in 'Web Hosting' started by Mr Magoo, Apr 10, 2011.

  1. Mr Magoo

    Mr Magoo Newbie

    Joined:
    Sep 6, 2010
    Messages:
    19
    Likes Received:
    15
    Occupation:
    Defense
    Location:
    Amurrika
    I make no claims and offer no warranty. This is just a basic guide to help with the setup of a new VPS using Linux.

    So!

    I browse often and see lots of questions concerning VPSs and what they are/how to set one up, so I did a quick and dirty guide based on my experience. I've set up about 15 separate VPSs using Linux and will use my limited experience for this article.

    This guide is written as if you are installing Ubuntu 10.04, but is relevant to most other Linux distros as well.

    What you will need
    • A VPS host with your Linux distro of choice installed
    • WebMin (similar to CPanel) (will be installed after the server)
    • FileZilla FTP client for moving files to/from your VPS server
    • Putty SSH terminal client for sending commands to your VPS server
    • General Linux knowledge (Google for basic commands for your system of choice)

    Finding a VPS Host
    First and foremost, you need to find a reliable VPS provider. Make sure you do your homework on each host as they have varying technical support, available Operating Systems, add-on software, specifications and so on.

    If you have experience with VPSs or have installed and configured remote servers before then the technical support probably won't be that big of a deal for you. If you are unfamiliar with setting up a remote server, or even dealing with Linux, then find a host that can set most everything up for you. Most VPS hosts will install the Operating System that you choose and you'll have a basic system up and running in a few minutes, although pretty bare.
     
    • Thanks Thanks x 4
    Last edited: Apr 10, 2011
  2. Mr Magoo

    Mr Magoo Newbie

    Joined:
    Sep 6, 2010
    Messages:
    19
    Likes Received:
    15
    Occupation:
    Defense
    Location:
    Amurrika
    Choosing a Linux Distro
    Now that you have your host picked out, it's time to install your Linux distro of choice. Personally I use Ubuntu 10.04 since there is a ton of information and free help as well as upgrades for the system. Also, the server edition doesn't have a graphic interface so it uses very little RAM and CPU while running. For example: My Ubuntu 10.04 server, while serving multiple connections, making backups, dealing with mail, and utilizing SQL databases sits right around 270MB of RAM and has a footprint of about 2GB (including pictures, videos, content, user data etc).

    You can chooses a different Linux distro as there are many options, and some are better at being webservers than Ubuntu, so there it is all based on your comfort level. Some Linux distros require extensive, custom modifications to set up, while others are more user-friendly.

    Note: Some distros come with preconfigured software such as WordPress, Joomla, etc. These are easy to install and ready to go within minutes. If you are setting up a content system and you are using Wordpress, Joomla, or just want less frustration, check out TurnKey Linux. Be warned, that these distros are usually heavily modified and if you want to add other programs, extensive custom configurations may be required.

    I recommend any of the following:

    TurnKey Linux (come with preconfigured WordPress, Joomla, Wiki, BitTorrent etc)
    Any Ubuntu LTS version (LTS means Long-Term Support and are generally more stable) I recommend 10.04 or 8.04 LTS versions
    CentOS
    Debian Stable
     
    • Thanks Thanks x 2
    Last edited: Apr 10, 2011
  3. Mr Magoo

    Mr Magoo Newbie

    Joined:
    Sep 6, 2010
    Messages:
    19
    Likes Received:
    15
    Occupation:
    Defense
    Location:
    Amurrika
    Setting Up Your Server
    Most, if not all, VPS hosts will install your Operating System for you and show you how to access it via commandline. You should be provided with a ROOT password which is what you will use to initially access the server. If you used a version of TurnKey Linux make sure you follow their directions since it will be a different setup and may require you to take different steps.

    At this point, your server should have an address assigned to it (ex 222.222.222.222), which can be used to access your site immediately.

    If you have a domain name, you need to login to your account at your domain's registrar, and point your domain towards your new VPS host's DNS servers. Your registrar and VPS host can help with this and is a fairly simple process. It may take a few days before you can access your new server via your domain name, because many ISPs cache DNS settings and you will need to wait for them to update it.

    If you install a version of TurnKey Linux, WordPress or LAMP for example:

    Then everything is already installed for you and just need to follow their basic instructions for logging in. WebMin and iptables probably won't be installed but you need to check with the documentation to be sure. As I said previously, this route is easier but it may make server customizations more difficult. If you don't plan on anything beyond a basic WordPress content system then this route is just fine.

    If you are doing a fresh, basic Ubuntu server install, then you need to:

    Open up Putty and login to your server using SSH, port 22, login name root and the password your host provided to you. Immediately change your password and write it down so you don't forget it. If you forget this password you are screwed.

    Perform the following commands:
    apt-get update
    apt-get upgrade

    The server will want to install and/or update files. You want to say Yes. Think of those 2 commands as the same as doing an update on a Microsoft Windows OS.

    Install the following programs and FOLLOW THEIR DOCUMENTATION, ONE-BY-ONE STEP-BY-STEP

    Install Apache webserver (command: apt-get install apache)
    Install PHP (command: apt-get install php5)
    Install iptables for firewall (command: apt-get install iptables)
    Install Webmin (like CPanel but free) (command: apt-get install webmin)
    Install MySQL (if you are using databases) (command: apt-get install mysql-server)
    Install phpMyAdmin (if you are using databases) (command: apt-get install phpmyadmin)


    This is really all you need for a basic webserver. If you want to use WordPress, Joomla or any other content system then you need to install these as well.

    If you want to send/receive mail from your domain (example: admin at mydomain.whatever)

    Install PostFix (command: apt-get install postfix)
    Install Dovecot (command: apt-get install dovecot)
    Install squirrelmail (if you want to check mail through a seperate email service in your browser)

    Set them up according to their documentation for your Linux Distro.
     
    • Thanks Thanks x 2
    Last edited: Apr 10, 2011
  4. Mr Magoo

    Mr Magoo Newbie

    Joined:
    Sep 6, 2010
    Messages:
    19
    Likes Received:
    15
    Occupation:
    Defense
    Location:
    Amurrika
    Server protection
    Regardless of your server type, you need to make sure you have WebMin and iptables installed in order to properly and easily administrate your server.

    Think of WebMin as a free Cpanel. You can access automated tasks, firewall, users, filesystem etc. Pretty much every aspect of your server can be controlled through here. After installation, it can be accessed using root login and password, and you can add/modify additional users once logged in.

    Iptables is a firewall system for Linux. There are other systems as well which are easier for new Linux users, so check out the forums and Google search for your Linux distro. I use a basic iptables install since it easily integrates into WebMin and can be managed from there.

    To make this process easier, in WebMin, go to Networking > Linux Firewall, and allow it to control your firewall. Instead of having to use the commandline you can now modify it within WebMin. Make sure you allow enable firewall at boot.

    There are thousands of guides on how to set up a proper server firewall all over the internet. Check the documentation for the firewall you chose and look for a howto guide for it. Heres a basic run-through of how it should appear/work: (Accept/Deny refers to what the server does with incoming connections that meet the parameters that follow)


    Accept if input interface is "lo"
    Accept Always
    Accept if connection is RELATED, ESTABLISHED
    Accept if protocol is TCP and destination port is 80 (this allows visitors to view your content)
    Accept if protocol is TCP and destination port is 22 (this is for SSH/putty/filezilla FTP access)
    Accept if protocol is TCP and destination is port 10000 (this is for Webmin access)
    Accept if protocol is TCP and destination is port 25 (for email to work, if you installed it)
    Accept if protocol is TCP and destination is port 143 (for email to work, if you installed it)
    Drop Always (deny everything else that isn't specifically allowed here)

    Just installing a firewall doesn't make you safe. You need to make sure you set it up correctly to ensure that your server is protected, so don't skip it! You can also modify some of the parameters so that only your IP address can access SSH, FTP, WebMin etc but you can check your documentation for details.
     
    • Thanks Thanks x 2
    Last edited: Apr 10, 2011
  5. Mr Magoo

    Mr Magoo Newbie

    Joined:
    Sep 6, 2010
    Messages:
    19
    Likes Received:
    15
    Occupation:
    Defense
    Location:
    Amurrika
    Basic Server Settings
    You need to setup basic server settings so that visitors have a decent experience. You need to create custom 404, 403, and 500 error pages so your visitors don't get dumped on a blank page with some foreign text. Make your error pages with the same template as the rest of the site, and save them on your server's root (probably /var/www). In WebMin, go to Servers > Apache Webserver > Virtual Server, and click "Error Handling." This is where you can set up where users are redirected when they view certain error pages. Since you save your custom error pages on the root of your system, they can be accessed by visiting yourdomain dot whatever / whatever_you_named_it.

    If using a prebuilt system like TurnKey this may be done for you already. You can test it by visiting a non-existing page on your server and see where you land.

    Now is a good time to make sure all visitors land on the same domain URL. If you plan on using "www" in front of your domain, you can add a single line to your .htaccess file which is also located in the root folder of your site (probably /var/www). This makes sure all your pages will be indexed with "www" in the domain name, and prevents duplicates.

    Now is a good time to register your site with Webmaster Tools on Google. Add your site to your account TWICE, once using the www and again without, and make the preferred URL for both of your added domains the same so Google knows which one you are trying to use. There are a few tutorials on BHW about this.

    Backups
    Backup often and use multiple systems if you can!

    Backup your database and server daily if you can. I highly recommend using RSYNC to do daily backups. RSYNC only backs up files that have changed since the last backup, so it doesn't move your entire server at every backup). I also have daily Snapshots of just the web directory for quick backup if the system is still good. With RSYNC you need another server that it can send the files to. These are usually provided for cheap by your VPS host.

    Viruses
    Install ClamAV and setup a CRON job (automated task) to run a virus check daily, or even weekly. It only takes about 1-5 minutes and doesn't impair the speed of the server. Run it during slow hours just to be sure.

    That's it!

    Change your passwords often, backup frequently, and make money!
     
    • Thanks Thanks x 3
    Last edited: Apr 10, 2011
  6. hackNstuff

    hackNstuff BANNED BANNED Premium Member

    Joined:
    Jun 10, 2010
    Messages:
    136
    Likes Received:
    15
    Goodness, tons of info there, good job putting it together. If anyone is looking for VPSs, I can provide one that does all of the above + some management tools for $15/mo. It'll host anywhere between 20-50 sites easily, depending on server load. PM me for info.
     
  7. Hostwinds

    Hostwinds Power Member UnGagged Attendee Enterprise Member

    Joined:
    May 17, 2010
    Messages:
    768
    Likes Received:
    544
    Occupation:
    C.E.O.
    Location:
    Oklahoma
    Home Page:
    Very nice guide, I was planing on writing a similar guide to go in the knowledge base on Hostwinds, This will be a good reference so I am sure to include everything