I use Cloud Servers from Rackspace for most of my application hosting. Through their control panel I can quickly create, rebuild, and delete virtual private servers quickly and easily whenever I want. The only frustrating part has been having to spend time doing the same initial configuration and LEMP stack installation tasks on each new server.

To make server deployment less tedious, I’ve created a shell script named quick-lemp to automate most of steps I go through when setting up new Ubuntu servers upon my first log in as root. Part of quick-lemp is intended for initial setup of a new Ubuntu server and the other part handles LEMP stack installation.

 

New Ubuntu 12.04 Server Setup

  • Creates a new user and adds them to sudo and www-data groups.
  • Updates sshd configuration to change the SSH port, disables root logins, and restricts the allowed users to the one previously created.
  • Implements iptables rules to block traffic to all ports aside for SSH, HTTP, and the default development server ports for Django and Flask.
  • Updates package list and performs necessary upgrades.

 

LEMP Stack

  • Installation and configuration for:
    • Nginx with one site/application.
    • uWSGI in Emperor Mode.
    • MariaDB 5.5 (can be replaced with MariaDB 10, PostgreSQL, or MySQL).
  • System installation of pip and virtualenv.
  • Deploys sample Flask application.

Since not everyone needs all pieces of the script, I’m distributing two versions. The Full version has the new server setup and the LEMP stack installation. The Core version has only the LEMP stack installation. The quick-lemp scripts and corresponding instructions are available on Github.

GitHub: https://github.com/jbradach/quick-lemp

%d bloggers like this: