Run this script on an Ubuntu distro & your domain is set up and ready to browse to: new user, Nginx, PHP-FPM, Suhosin, XCache, MySQL, Postfix for email, iptables, SSH keys, SSHD security and more, the whole darn lot totally tweaked-tastic!
This script is a beast. After you have launched a new Ubuntu 10.04 LTS distribution, switched the nameservers and setup your DNS within your VPS control panel .. run this script and within minutes you can surf to your domain.
It is that simple *.
Setup Unmanaged VPS: The Ubuntu-Nginx Guide
Take your virtual private server from zero to hero
.. from blank box to cute-as server ..
with this easy-to-follow copy/paste guide.
22+ parts with video, here’s the index.
* There are some caveats. Let’s be frank:-
CAVEAT 10 MINUTES? For real, below you can see the list of what is installed in that execution time, and it’s all top of the range. But. This assumes you’ve launched the distro, sorted the DNS in your VPS CP and the nameservers are pointed already.
.. This tut shows you how to do that lot anyhow.
CAVEAT VPS providers vary. Your host’s Lucid distribution may vary, slightly, from those that this script has been tested on. In theory, perhaps edited a fraction, this will work on any half-decent virtual private server but, if an error is thrown, I’ll help you with that in the new stackscript forum.
It works flawlessly on a Linode 360 .. all vpsBible stacks have free-support for cross-VPS-compatibility.
CAVEAT This script has only been tested on Ubuntu Lucid Lynx 10.04 32 bit. If you want Ubuntu, that is almost certainly the kernel you want. I’ll be releasing a slightly adjusted Debian 5 equivalent next week and, in due course, further OS and web server forks. For news on new stacks check out the forum.
& a Request Please give me feedback. Here’s the deal: you help me test this script and I will help you set up a stunning server and, relatively, you’ll hardly have to think nor to trawl through all those docs (and my dodgy jokes, mind you a few slipped in here so sorry in advance.)
So, whether you are a webmaster needing to launch multiple machines or you’re just fed up of crunching the console, this script will save you anything from an hour’s time per box to a few days of research and toil.
Cross-VPS Lucid/LEMP Stackscript: Package Spec
Here’s the order of installation:-
- system update/upgrade
- locale settings
- USER with SuperUser (visudo) privileges & /home/USER directory
- embedded public authentication key
- hardened SSHD security
- an iptables firewall
- Postfix for email (ideal for Google Apps)
- MySQL, secured **
- PHP with PHP-FPM (‘separate’ compiled from source)
- .. secured with Suhosin
- caching with bespoke XCache
- Nginx web server (compiled from source)
** Once you execute the script this is the single instance when you are prompted to enter a password manually and answer a few simple questions. When you launch the script, wait about 90 seconds for this prompt and answer the questions – I’ll give you the answers in a mo – then leave the thing to run to its termination and automatic reboot. Then, provided your DNS has propagated, you can surf to your domain name.
The one key thing that is missing, IMHO, is DNS Setup using Bind. I intend to add this functionality to speed the setup process further and to assist those without a DNS Manager at their VPS host.
All packages are, AFAIK, the latest stable versions. The script is designed to easily update versions and I’ll keep a watch on that, and welcome your opinions.
How to Run the StackScript
1. Launch an Ubuntu Lucid 10.04 LTS * 32 bit distribution from your VPS provider’s control panel. Here is how – Set Up a VPS Linux Distribution.
* LTS = Long Term Support LTS versions are released every 2 years and are supported with official Ubuntu updates for longer, the server editions longer still. Lucid 10.04 will keep us liquid until April 2015. The last LTS, Hardy Heron 8.04, remains supported until April 2013. (Probably this script will run fine on that, someone tell me!) By contrast, a regular release like the upcoming Maverik Meercat 10.08, due in October 2010, will be supported only until April 2012. This is why Lucid, a kingpin edition, is so important. And yes, the names are silly.
2. Point your domain to your VPS providers nameservers They will be called something like ns1.vpsprovider.com, ns2.vpsprovider.com, ns3.vpsprovider.com and so on, depending on how many there are (generally just two). Once you have the ns1.correctSyntax.com, log into your domain registrar account (where you bought the domain name, else to where you transferred the registration) and change the values in the nameserver input boxes .. and wait for propagation. How long it takes can be anything from minutes to about 72 hours, depending on the registrar, it’s web location and who-knows-what.
.. you can do this last. For a seamless move with an existing site, it must be last. Read Moving Day! How to Move Your Blog or Site for tips.
3. Setup your DNS, those settings creating registration records for your domain with your VPS provider. Follow Add a Domain Zone to Your VPS for how to do that. I’ll build this into this StackScript using Bind but, hey, it’s a few minutes manually and generally very easy anyway.
4. Log into your VPS using a terminal ..
- If *locally*, you run Windows, follow Set Up Command Line Interface (CLI) using PuTTY
- Else for *local* Linux follow Create a Basic Local to Remote Server SSH Connection
5. Create SSH authentication keys My SSH directions, boxed in below, may sound scary but if you read the linked tutorials this is dead easy so no excuses. And bloomin’ ‘eck it’s worth it for the added security and the ease of password-free remote login.
Again, this bit varies depending on your *local* PC flavor:-
Windows locally?
Follow Encrypt Data with OpenSSH & Auto-Login with PuTTY, stopping before the section Add the Public Key to Your Remote VPS (read that section though). I’d recommend you also to carry out the later section Even Faster Login Using Pageant (on your local machine) although for our purpose it’s not essential.
As the above linked tutorial spells out, you want your local private key somewhere safe on your PC. For the public key, open its file with Notepad because we will be copy/pasting that into the stackscript as shown in a moment.
Linux locally?
Follow Create a Basic Local to Remote Server SSH Connection but do not upload the public key.
.. I’m not sure that tutorial is quite as clear as it might be for this job so here’s a brief recap (read the tutorial too because I am only filling in some blanks) ..
Create the keys on Linux with the command:-
.. following the terminal prompts to create a passphrase.
Open the public key with, say, the gedit text editor:-
.. and you’ll be copying that key in a moment, pasting as explained in our stackscript.
6. Edit the stackscript Bear in mind that the server we end up with is highly configured, especially when it comes to security but also, for instance, to enhance performance based on the resources of your VPS slice. To make that possible we have to edit some variables and, for some, to carry out some basic research.
To make life as easy as possible I’ve produced 2 identical scripts here (in terms of execution). They look different because one has comments to explain those all-important values. They do exactly the same thing.
Click on this link .. Show Me the Commented Script
Click on this link .. Show Me the Stripped Script
Toggle to and fro as you prefer, perhaps using the comment-strewn script to guide you while filling out the values on the tidier script, copied to your text editor. (That way you’re less likely to miss a value.)
.. Well come on, get on with it .. the notes are in the script now .. I’m taking a nap ..
Zzzzzzzzzzzzzzzz, yaaawwnnn .. er, right, er, all done, jolly good.
Problems Logging into the VPS?
As covered above and in linked tutorials, you log into your newly launched VPS server using the terminal’s syntax:-
.. where 12.34.56.78 is your IP address. If you don’t know what that is, look for IP address in the DNS setting section of your VPS provider control panel.
You’ll be asked to accept the connection .. do. And give the password you gave when you launched the Linux distribution (not the one in your PASSWORD value, necessarily).
If you’ve launched a new distro on a VPS (and its IP address) that you’ve used before, you may be given a warning telling you that you can’t log in.
.. In that case, you need to delete a line from your local hosts (Windows) or known-hosts(Linux) file, as directed in the message. So basically do what the message says, then try logging in again.
Let me be clear. Put another way, if you receive a warning and cannot log in – most likely if you have redeployed a new Linux distribution with a previously used IP address – you’ll need to delete a redundant key from your hosts file. Read the message carefully as it pinpoints the precise line and from what file to delete that line. The file itself can be found:-
Windows C:WINDOWSsystem32driversetchosts
Linux /home/USERNAME/.ssh/known-hosts
.. Very likely the line in question is the very last one, most particularly if you are relaunching from a failed setup immediately before.
.. And that’s the prerequisites done-dusted. We are ready to rock. I advise some very loud music.
Deploying the Stackscript
OK, you’re logged in remotely as root and therefore with Super-User permissions. Let’s go to town.
Type this:-
.. and within the new file, paste CTRL-SHIFT-v the entire contents of the script (with values amended).
Save and close the file .. CTRL-x > y > ENTER
Type this to give root permissions to execute the file:-
And kick up some dust:-
As I mentioned above, wait for the script to stop. It will soon ask you for your MySQL password, the one you used for your export MYSQL_PASSWORD=”some_password” value.
Having entered that, you’ll be asked yes or no to 5 pretty comprehensive questions. Here is the sequence of my suggested answers. After each, hit ENTER:-
The script will resume executing all manner of stuff. The PHP section in particular will take a long time as it – and Nginx afterwards – is being bespoke compiled with custom bells and whistles.
This is a perfect opportunity for a cup of tea.
After a 10 minute run (at least on my Linode 360 machine, but give or take) the script runs out of things to do, gets bored and issues a sulky reboot.
(Your VPS, by the way, is by now quite the sex kitten. Hmmn, I’ll shut up.)
Give a minute for the reboot to do its thing and again log into your VPS, this time as the USER you specified in the script and using the custom port you reserved in the PORT variable:-
.. the -P means we’re about to specify a port to connect with, by the way. (No other port will work.)
Troubleshooting Lockouts & Errors
Explosions aside I can envisage two scenarios.
I’m Locked Out
If you can’t get in that’s because you copied incorrectly the public key into its PUBLIC_KEY variable, coupled with the fact you opted not to allow PASSWORDAUTHENTICATION.
Relaunch the Linux distribution from scratch and be really careful with those values, with all the values.
This Script Sucks
While it’s highly unlikely that this script could provide a login problem with any Lucid VPS, as I say, there is the chance that it isn’t compatible with your VPS.
.. Fortunately though, the glitch will (famous last..) be pretty basic and pretty straight-forward to rectify.
Copy any error messages you see on running the script and paste them to me in the forum and I’ll do my utmost to help. Indeed, I’d be grateful to press out any creases.
Delete the Stackscript
Now we’re in, let’s get rid of that executable now. As you are not logged in as root, assume it:-
And, having given the root password (the one you used to deploy the distro) .. trash the script:-
Check Your Nginx-powered Domain
You may as well check to make sure you have a webpage:-
And edit it (deleting my automated spiel in the process) to check out your PHP, its extensions and XCache:-
.. but then delete that phpinfo request too, else you’re offering clues to hackers:-
Then head to your VPS forum and tell everyone how cool this is, and I’ll be seriously grateful.
(.. that last bit’s pretty important)
Cue the inspiration to this super-stacked cute cat ..
Setup Unmanaged VPS: The Ubuntu-Nginx Guide
Take your virtual private server from zero to hero
with this easy-to-follow copy/paste guide.
“My local PC runs Windows” Show me for Linux/Mac
“My local machine is Linux/Mac” Show me for Windows
22+ parts with video, here’s the index ..
-
Setup Unmanaged VPS: The Ubuntu-Nginx Guide
Introducing vpsBible’s how-to guide for setting up a super-charged unmanaged VPS featuring Ubuntu and Nginx.
-
VPS (Virtual Private Server) vs Shared vs Dedicated
Before getting stuck in, let’s compare the web host types in detail and weigh up the differences between managed & unmanaged VPS.
-
Set Up a VPS Linux Distribution
Opening a VPS hosting account, we’ll choose, configure & launch a Linux server ‘distribution’.
-
Set Up Command Line Interface (CLI) using PuTTY
Now we’ve got a server to play with, we’ll connect to it, using the ’ssh’ protocol for a super-secure link.
-
Create a Linux User & Set Permissions
Initially you’ve logged into your remote Linux machine as ‘root’. We’ll add you as a user now, with root or SuperUser permissions.
-
Encrypt Data with OpenSSH & Auto-Login with PuTTY
Now we can use ‘authentication keys’ to shore up our connection while simplifying login to an automated, password-free yet secure process.
-
Harden the Secure Shell (SSH) & Create a Firewall
The final security step: galvanizing the OpenSSH protocol and setting up an ‘iptables’ firewall. Now the server is rock ruddy solid.
-
Edit bashrc for User-Friendly Linux, plus System Updates
We use the terminal a whole lot so let’s cut ourselves a break and create some command shortcuts, then update the server.
-
Add a Domain Zone to Your VPS
To make your server aware of yourDomain.com you’ll need a few ‘DNS’ records. Damn this is simple I’m practically asleep!
-
Prepare Linux Server for Email with Postfix
In order to send and receive email from our web applications we’ll install some software and tweak the ‘RDNS’ record.
-
Install PHP5 & MySQL – The One-Stop FastCGI Index Page
Add PHP5 & MySQL, but which FastCGI method is best? Here’s the benchmarking, 4 ways to install/compile, add caching modules & more.
-
Nginx (better than Apache) Web Server
Let’s install this supersonic web server, tweaking its file structure & adding default configuration files.
-
Setup FileZilla for Secure FTP (SFTP)
There’s FTP, and then there’s ‘Secure FTP’. We’ll set up FileZilla using SFTP – and those authentication keys – for secure file transfers.
-
Serve Multiple Sites & Blogs with Virtual Hosts
We want a website folder structure, some permissions, some site-specific configuration files and, hey, we’ll hook up ‘FastCGI’.
-
Adding Sub-Domains with Nginx
Need a sub-domain? If you do, here’s how to add subDomain.yourSite.com with an ‘A record’ and a configuration file.
-
Integrate A CMS Like WordPress, WP MU, Drupal etc
For those of you wanting to use a specific content framework, such as a CMS, blogging or forum software, pop in here and we’ll sort that out.
-
Google Apps for Domain-Specific Email
GA’s free Standard Edition for catchall webmail – POP-ping or IMAP-ped to your desktop client – saves precious server resources for your webs.
-
Moving Day! How to Move Your Blog or Site
Nearly there. Here’s the web site or blog migration guide, relocating to your VPS with minimal or no downtime.
Manage Unmanaged VPS: Ubuntu-Nginx Administration
Already set it up? We’d best maintain it then.
Toggle to the .. Ubuntu-Nginx Admin Index
Manage Unmanaged VPS: Ubuntu-Nginx Administration
Maintain your virtual private server with ..
.. cheatsheets, tutorials, tips & guides.
Head back to the .. Ubuntu-Nginx Installation Index
-
Nginx Control Panel: Here’s the Deal
You’re migrating shared-to-VPS and want a GUI like cPanel? No you don’t, not after you read this! What’s more, you don’t need one either.
-
Nginx Control Panel Workarounds
For every control panel module there’s an equivalent (and faster) terminal command. Let’s compare these.
-
Upgrade to Nginx Latest Version with ZERO Downtime
Keep Nginx up-to-date – and optimized for security. This guide shows precisely how *with no missed server requests*.
-
Compile an Advanced Nginx Module Configuration
Need special web server functions? Here’s how to install or upgrade Nginx with bespoke required modules & parameters.
-
Add Web Sites Nginx Cheatsheet
Once you’ve set up your first site, adding more gets easier. Especially when you refer to this. (Let’s face it, I’m just too good to you.)
-
Adding Sub-Domains with Nginx
Rather than add somesite.tld, maybe you want some.subsite.tld? Here’s how to set your A record using a DNS manager and the vhost file for Nginx.
-
Add/Delete MySQL Database from Command Line
Need a database? Want to bin an old db? This tutorial shows you how using the terminal command line console whatnot.
-
Configure phpMyAdmin for Nginx to Maintain MySQL
Rather than have to crunch databases via the command line, we can make life easier by adding this splendid tool to manage them.
-
Backup/Export MySQL DB with CLI & mysqldump
Here’s how to backup a database from the command line using the handy mysqldump utility.
-
Import MySQL Database using Command Line
Import data to a new database with this simple mysqldump guide .. great for reinstating an old backed-up db, for instance.
-
Batch Replace/Delete Data in MySQL Database
Change repetitive db data with a single command. Rather than manually find & alter each instance, isolate the lot & update multiple content.
-
LOST a MySQL Password? How to RESET it
Lost your MySQL password? That’s a bit of a bummer .. or it would be if you didn’t have this new password setup guide, huh.
-
Backup or Upload with Secure Copy SCP (Linux to Linux)
Never mind FTP m8! Save time and download/upload your files using encrypted SCP (secure copy), the #1 Linux-Linux file transfer solution.
-
Backup or Upload with PuTTY PSFTP (Windows/Linux)
Equivalent to the above, how to transfer your files if you’re unlucky enough to be running Windows for your local PC. Not that I’m biased.
-
*USEFULLY* Park A Spare Domain with Nginx
Got a spare domain name sat around doing nothing? Put it to some use, have it point its traffic at your primary domain. Here’s the deal ..
-
Password Protect Nginx Web Files/Directories
Maybe you want a hidden website directory, say, for projects, or are developing a site and want it off-limits ’till launch day. Top tip ..
-
Redirect Web Pages with Nginx Rewrite Rule
Here’s the syntax to point a site or blog to another domain. That way, for instance, traffic from a passive site benefits an active one.
-
Nginx Error & Access Logs
Need to troubleshoot some error, or want to find out who’s trying to hack your site? Here’s a start .. those tell-tale logs.
-
Subversion for Easy CMS Updates ie WordPress/Drupal/etc
A brief introduction to install and know about the power of Subversion, the version control system to keep scripts and platforms up-to-date.
-
You Tell Me …
Something missing? Probably. Let me know what you’d like included. And if it’s listed below, shout out anyhow and I’ll try to bump it.
Nginx Admin: In the Works ..
This lot’s marked for addition already:-
- Setup or Edit DNS using Bind
- Network Tools Troubleshooting Guide
- The Comprehensive Permissions Guide
- Configuring Nginx Rewrites
- Custom Website Error Page
- Setting up Cron Jobs
- Rsync for Incremental Remote-to-Local Backup
- Cron & Rsync for Automatic Backup
- Cron & mysqldump for Auto DB Backup
- Safeguard Bandwidth with Hotlink Protection
- Block Access with Nginx’ IP Deny
Got a Question? Want to Comment?
This site has no comments system. We've got a better system!
Please use the link at the top of the post and goto this topic's forum thread:-
- to help build community
- for a superior knowledge base
- to keep info in one place, not diluted between forum & comments.
For those posts ported from Guvnr.com (pre-Feb/2010), archive comments remain.
Handy info from these comments is in the process of being ported to the forum and attributed to the original author.
If you think this idea sucks, let me know.
Thank you.























STACKSCRIPT: Auto Install/Connect WORDPRESS to NGINX: VPS BIBLE - vpsBible May 18th, 2010 at 10:27 pm
[...] as set out in the vpsBible’s Ubuntu/Debian guides, else using this site’s super-easy LEMP stackscript. If you’re not sure about that, logged into your VPS, run this [...]
SliceHost VPS, NGinX – Performance Outcome SEO Reporting To Come – The Recursive ISV May 23rd, 2010 at 8:28 pm
[...] at least have a play at setting up the good old manual way) he’s produced the first two of a series of automated scripts that, apart from a few edits to variables, will set the whole shebang up for you (only just added [...]
Setting up a Virtual Private Server with a Stackscript: VPS BIBLE - vpsBible June 1st, 2010 at 6:13 pm
[...] LEMP Stack: *10 Minute* VPS Install 4 Lucid 10.04SSH secured (with keyset) Nginx with PHP-FPM for Ubuntu Lucid 10.04 LTS [...]
** Cross-VPS-compatible ** LEMP STACKSCRIPT for DEBIAN: VPS BIBLE - vpsBible June 11th, 2010 at 12:47 am
[...] LEMP Stack: *10 Minute* VPS Install 4 Lucid 10.04 [...]