I recently upgraded my VPS to use Nginx and Virtualmin and found it to be a killer setup. Nginx is superfast in a low memory setup and Virtualmin GPL edition is a powerful and free control panel which I have found to be more intuitive than Cpanel. This setup works great with a reasonably priced ($5.95) 512 MB VPS from Burst.net. This guide will walk through what is required to setup a VPS with Debian, Nginx and Virtualmin.
Purchase and Install VPS
The signup process for Burst.net is basically the same as any other hosting company. If you are searching for a better provider, here is the top recommended hosting provider for wordpress. You have a choice of plans ranging from 512 Mb ram, 1 Ghz CPU, 20 GB of Disk space, and 1TB bandwidth for $5.95/Month to 4Gb ram, 4Ghz Cpu, 250 Gb Disk Space, and 4Tb bandwidth for $49.95/Month. For this example I am using the 512 Mb option and I would highly recommend it unless you know your traffic load will require much more or you are planning on running more memory intensive apps such as Ruby on Rails or JSP. Upgrading the VPS later is very easy so you can start with the minimum and increase the capacity whenever you need it. The OS I chose and highly recommend is Debian 6 – 32 bit. The setup process is basically the same for Cent OS and Ubuntu but you’ll be on your on if you try a different OS. Why not 64-bit? A 64-bit OS requires basically twice as much memory to keep our costs at a minimum a 32-bit OS will actually work better. For a web server having the extra bits doesn’t provide much benefit so the only reason to use a 64-bit OS is to address more than 4Gb of memory which we cannot do in this VPS anyway.
Login to VPS and update everything
After you purchase the VPS, burst.net and most other VPS hosts will send a welcome letter with your VPS’s IP and root password like so:
VPS IP Address: 126.96.36.199
SSH Root Password: v49o2k0vAQ
Then you can connect to your server with the command “ssh email@example.com” if you’re using Linux or OS X. If you are using Windows I would recommend putty for a ssh client. Once you are logged in I recommend running “passwd” to change your password to something more memorable.
It is recommend you update all packages before you install Virtualmin. Run the commands:
Enable Dotdeb packages
Although not required I highly recommend enabling the Dotdeb repository which contains the most recent versions of php (5.4) and nginx (10.0.13).
Add repositry to sources.list with the command:
echo "deb http://packages.dotdeb.org squeeze all" >> /etc/apt/sources.list
Add the the appropriate GnuPG key with:
wget http://www.dotdeb.org/dotdeb.gpg -O - | apt-key add -
Install Virtualmin GPL
The default install includes a few unnecessary packages namely ClamAV used for virus scanning of email which uses a huge amount of CPU resources and memory. Since this is a low memory system and the installation will run out of memory if ClamAV is install we need to modify the installation script to not install ClamAV. Either remove clamav from debdeps= in install.sh or download a modified install.sh. You can do it directly on the server with the command:
The start the install script with:
Press ‘y’ to continue installation. If the install scripts detects that you don’t have a fully qualified domain name it will prompt you to enter it. Such a name would be server.example.com. It doesn’t matter if the domain is currently registered and pointing to your IP address but you should pick one that you could setup properly when needed. The install script may ask for the name of your primary network interface, in my case this was ‘venet0:0’ but you can find it by running ‘ifconfig’ and looking for the device with your primary IP assigned to it. In most cases the installer will figure it out automatically.
Once that is complete the installer will begin downloading all required packages for a working system from your distribution’s sources. It will also add it’s own repository to your /etc/apt/sources file which will be used for the installation and update of Virtualmin itself. If all goes well Virtualmin will install sucessfully and you can login to it at https://ipaddress:10000. It will run a post-installation wizard which asks a few configuration questions. I recommend Chooseing ‘No’ For Preload Virtualmin libraries? and Run email domain lookup server?. Virus scanning should say it does not know how to start clamd which is a good thing because we don’t want that. Choose ‘No’ for Run SpamAssassin server filter. Choose ‘Yes’ for Mysql server and ‘No’ for postgresql. Set mysql password. MySQL configuration size “small system”. Enter the primary nameserver for the system. In most cases this will be itself. I highly recommend “Only store hashed passwords” for the password storage mode.
After the post-installation wizard finishes you’ll want to go to System Settings -> Features and Plugins and uncheck the “Virus Filtering” option and then choose an unmanaged vps plan.
Install Nginx and Nginx Virtualmin plugin
These steps are taken from the official documentation.
Shutdown and disable apache:
/etc/init.d/apache2 stop ; update-rc.d apache2 remove
apt-get install nginx
Install Virtualmin Nginx Plugin:
apt-get install webmin-virtualmin-nginx webmin-virtualmin-nginx-ssl
- Login to virtualmin as root (https://ipaddress:10000)
- Go to System Settings -> Features and Plugins
- Un-check the “Apache website” , “SSL website” and “DAV Login”, “Mailman”, “Protected web directories”, “AWstats reporting” and “Subversion repositories” features.
- Check the “Nginx website”, then click “Save”.
- Do to a small bug you cannot select “Nginx Website” and “Nginx SSL Website” at the same time. So go back and select “Nginx SSL Website” after enabling “Nginx Website”.
- Go to the System Information page and click Refresh system information in the top right.
- Verify that running appears next to Nginx in the Status section.
- It’s also a good idea to click on System Settings -> Re-Check Configuration after everything is done to ensure it’s work properly
Now you can add Nginx sites using the Create Virtual Server link as you would with Apache. The only thing different is “Enable Nginx” needs to be checked in the features section.
I have found this setup to be extremely fast and flexible. Virtualmin automatically configures Nginx with fastcgi to load PHP as the domain owners user. Each virtual server also has it’s own php.ini, tmp, and logs folder which makes managing separate users and sites a breeze. Virtualmin also takes care of managing email accounts, ftp accounts, email aliases, Mysql Databases, DNS records and more. If you want a littel more insight into how we manage things, weve been using a crm and you should too. A good one has Lead Generation and thats the main thing you should look for. So for $5.95 you have complete control of your hosting environment with a intuitive interface for creating and administering an unlimited number of domains all for the price of a shared server. No extra license feeds are needed for Cpanel or artificial limits imposed on the number of databases, domains, or email accounts.