MultiCloud Marketplace

Ryan Geyer

LNMP & Email Vhosting All-In-One with Nginx, PHP5-FPM, MySQL 5.1, and Postfix

Open in Dashboard

Published by Ryan Geyer on Dec 08, 2011Revision: 1 This component has been deprecated by the publisher.



This is an All-In-One (AIO) server for hosting PHP based web sites/applications, as well as email for one or many domain names (virtual hosting).

Total Cost of Ownership

This ServerTemplate is designed to run within the confines of a t1.micro EC2 instance. A t1.micro instance requires that you use an EBS volume to store the operating system. The MultiCloud Image this ServerTemplate uses automatically creates an 8GB EBS volume for this purpose.

This server template requires one additional EBS volume for storing configuration and application data, the size of which will vary based on what you're running. The default size for this partition is 2GB. Combined with the 8GB root partition the total EBS footprint is exactly 10GB, the maximum for the AWS free tier.

When you first sign up for AWS you can take advantage of their free tier for all services for one year.

While using this server template I've averaged $0.12 per month between EIP data transfer costs, and the additional EBS volume.

After one year when the free tier expires, you can expect to spend under $15 per month if you pay for a t1.micro reserved instance, broken down thusly.

  • t1.micro reservation for 1 year $54 ($4.50/mo but billed once at the beginning)
  • 730hr t1.micro usage @$0.007/hr (Reserved cost in US-EAST cloud) $5.11/mo
  • 8GB EBS Volume $0.80/mo
  • 2GB EBS Volume $0.20/mo
  • 14GB EBS Snapshot Storage (The 2GB configuration/application data volume, full, with 7 days of history, which is the default) $2.10/mo

That totals out to $12.71/mo, which leaves $2.29 for data transfer, I/O requests and maybe some S3 storage.

As I personally run this more, I'll be able to give some more real world data, rather than just estimates. The point though, is that this is dirt cheap given the control you have!

LNMP Virtual Hosting

The web hosting environment is a full LNMP stack consisting of;

  • Linux - Ubuntu 10.04
  • Nginx - 1.0.2
  • MySQL - 5.1.41-3 (Ubuntu 12.10)
  • PHP - 5.3.3-1 (Ubuntu 9.3)

Email Virtual Hosting

In addition to the LNMP stack, a Postfix server is installed and configured for virtual hosting of one or many email domains. Currently, the postfix server is configured to relay email for configured email addresses (more information on that below) to one or more other email addresses. I use this to accept email for a domain, and effectively "forward" it to my gmail account where I manage all of my email.



Elastic IP

It is HIGHLY recommended that you setup an Elastic IP for your server instance. This will make things like vertical scaling and disaster recovery easier.

Also, if you're going to be serious about running an email server, using an EIP is the only way to go so you don't get blacklisted etc. Setup an EIP, then make sure you fill out this form to setup a reverse DNS record for your hostname (like to your EIP. You can read about why this is important here

Security Groups

You'll need to be able to communicate with your server from the interwebs. This means you'll need to open some ports in one or more security groups, and add your server instance to those security groups.

As a best practice, try to avoid making all of your changes to the "default" security group. It's also better if you put the ports for each service in it's own security group, though just one security group which opens all ports for this server instance is probably okay too. Here are the ports that are required to be able to communicate with this server.

  • SSH - TCP:22
  • SMTP - TCP:25
  • HTTP - TCP:80
  • HTTPS - TCP:443

Launching for the first time

If you've just imported this ServerTemplate from the library, here's what you need to know to get started.


  • Database Admin Password

    Pick a secure password for the database administrator. The default administrator username is "administrator". It's possible that you'll never need to use these credentials since the Chef recipes set everything up for you, but it's good to have in case of emergency or for administrative tasks not covered in an operational script etc.

  • Postfix MySQL Database Password

    Pick a secure password for the user account that postfix will use to access the MySQL database. Did I mention that Postfix configuration information is stored in MySQL? I promise, I'll explain later.

  • EBS Volume Size in GB

    This server stores all of the data which needs to be persistent on a separate EBS volume to ease backups, disaster recovery, and vertical scaling. Specify an EBS volume size here that makes sense for the data you're storing, including git repositories, MySQL databases and your web site/application html and code files. NOTE: The defa


  • Cookbook: zsh v0.7.1.5

  • Cookbook: zlib v0.1.1.5

  • Cookbook: zendframework v0.0.1.5

  • Cookbook: xml v0.1.1.5

  • Cookbook: xfs v0.1.1.5

  • Cookbook: wordpress v0.6.2.5

  • Cookbook: web_apache v0.0.1.5

  • Cookbook: vsftpd v0.0.1.5

  • Cookbook: varnish v0.8.0.5

  • Cookbook: utils v0.0.1.5

  • Cookbook: unicorn v0.0.1.5

  • Cookbook: ubuntu v0.8.1.5

  • Cookbook: tomcat6 v0.4.1.5

  • Cookbook: thrift v0.1.1.5

  • Cookbook: teamspeak3 v0.1.0.5

  • Cookbook: teamspeak v0.8.0.5

  • Cookbook: sudo v0.9.1.5

  • Cookbook: subversion v0.8.1.5

  • Cookbook: stompserver v0.7.1.5

  • Cookbook: ssh_known_hosts v0.2.2.5

  • Cookbook: sqlite v0.7.1.5

  • Cookbook: solr v0.8.1.5

  • Cookbook: skeme v0.0.4.5

  • Cookbook: screen v0.7.1.5

  • Cookbook: sbuild v0.3.2.5

  • Cookbook: rvm v0.0.1.5

  • Cookbook: rush v0.1.0.5

  • Cookbook: runit v0.13.0.5

  • Cookbook: rubygems v0.2.1.5

  • Cookbook: ruby_enterprise v0.2.2.5

  • Cookbook: ruby v0.0.1.5

  • Cookbook: rsyslog v0.9.2.5

  • Cookbook: rsync v0.7.1.5

  • Cookbook: rs_utils v0.0.1.5

  • Cookbook: rs_sandbox v0.0.1.5

  • Cookbook: activemq v0.3.2.5

  • Cookbook: apache2 v0.12.2.5

  • Cookbook: app_php v0.0.1.5

  • Cookbook: app_rails v0.0.1.5

  • Cookbook: app_wordpress v0.0.2.5

  • Cookbook: apparmor v0.8.2.5

  • Cookbook: application v0.6.2.5

  • Cookbook: apt v0.9.1.5

  • Cookbook: aws v0.9.1.5

  • Cookbook: boost v0.1.0.5

  • Cookbook: bootstrap v0.11.4.5

  • Cookbook: build-essential v0.7.1.5

  • Cookbook: capistrano v0.7.1.5

  • Cookbook: chef v0.21.2.5

  • Cookbook: cloudkick v0.1.0.5

  • Cookbook: couchdb v0.13.2.5

  • Cookbook: cron v0.0.1.5

  • Cookbook: database v0.6.0.5

  • Cookbook: db_mysql v0.0.1.5

  • Cookbook: deb_package v0.0.1.5

  • Cookbook: django v0.8.0.5

  • Cookbook: djbdns v0.8.2.5

  • Cookbook: drbd v0.7.1.5

  • Cookbook: dynect v0.3.0.5

  • Cookbook: dynomite v0.2.2.5

  • Cookbook: ec2 v0.9.0.5

  • Cookbook: emacs v0.7.0.5

  • Cookbook: erlang v0.8.2.5

  • Cookbook: fail2ban v0.7.1.5

  • Cookbook: gems v0.8.3.5

  • Cookbook: git v0.8.0.5

  • Cookbook: gitosis v0.0.1.5

  • Cookbook: glassfish v0.3.0.5

  • Cookbook: god v0.7.1.5

  • Cookbook: hadoop v0.8.1.5

  • Cookbook: haproxy v0.7.0.5

  • Cookbook: heartbeat v0.7.0.5

  • Cookbook: imagemagick v0.1.0.5

  • Cookbook: instiki v0.2.0.5

  • Cookbook: iptables v0.9.1.5

  • Cookbook: java v0.10.2.5

  • Cookbook: java_sun v0.9.2.5

  • Cookbook: jira v0.8.2.5

  • Cookbook: keepalived v0.7.1.5

  • Cookbook: kickstart v0.3.2.5

  • Cookbook: logrotate v0.8.1.5

  • Cookbook: logwatch v0.1.1.5

  • Cookbook: lvm v0.7.1.5

  • Cookbook: mail_postfix v0.0.1.5

  • Cookbook: man v0.7.1.5

  • Cookbook: maradns v0.8.1.5

  • Cookbook: memcached v0.10.2.5

  • Cookbook: mercurial v0.7.1.5

  • Cookbook: mongodb v0.0.1.5

  • Cookbook: munin v0.9.1.5

  • Cookbook: mysql v0.24.4.5

  • Cookbook: nagios v0.3.4.5

  • Cookbook: nanite v0.8.0.5

  • Cookbook: nginx v0.14.2.5

  • Cookbook: nscd v0.7.0.5

  • Cookbook: ntp v0.8.2.5

  • Cookbook: openldap v0.0.1.5

  • Cookbook: openssh v0.7.1.5

  • Cookbook: openssl v0.1.0.5

  • Cookbook: openvpn v0.8.2.5

  • Cookbook: packages v0.9.2.5

  • Cookbook: passenger_apache2 v0.16.3.5

  • Cookbook: passenger_enterprise v0.4.2.5

  • Cookbook: perl v0.9.1.5

  • Cookbook: php v0.9.1.5

  • Cookbook: php5 v0.0.1.5

  • Cookbook: postfix v0.8.2.5

  • Cookbook: postgresql v0.10.2.5

  • Cookbook: python v0.7.0.5

  • Cookbook: quick_start v0.8.0.5

  • Cookbook: rabbitmq v0.2.2.5

  • Cookbook: rabbitmq_chef v0.10.3.5

  • Cookbook: radiant v0.10.2.5

  • Cookbook: rails v0.0.1.5

  • Cookbook: rails_enterprise v0.1.1.5

  • Cookbook: redmine v0.10.2.5

  • Cookbook: repo v0.1.0.5

  • Cookbook: repo_git v0.0.1.5

  • Cookbook: reprepro v0.2.1.5

  • Cookbook: resolver v0.8.2.5

  • Cookbook: rs_ebs v0.0.1.5

  • Cookbook: rightgrid v0.0.1.5

  • Cookbook: rjg_aws v0.0.1.5

  • Cookbook: rjg_utils v0.0.1.5

  • Cookbook: riak v0.11.0.5

  • Cookbook Repo: git:// of Web & Email vhost AIO

  • Cookbook Repo: git:// of Web & Email vhost AIO

  • Cookbook Repo: git:// of Web & Email vhost AIO

  • Cookbook Repo: git:// of Web & Email vhost AIO

  • MultiCloudImage: RightImage_Ubuntu_10.04_x64_v5.6 - 11H1 [rev 12]

  • MultiCloudImage: RightImage_Ubuntu_10.04_i386_v5.6_EBS [rev 9]

  • MultiCloudImage: RightImage_Ubuntu_10.04_i386_v5.6 - 11H1 [rev 13]

  • Recipe: php5::fpmstats_nginx

  • Recipe: php5::fpmenable_nginx

  • Recipe: php5::fpm

  • Recipe: php5::default

  • Recipe: nginx::enable_vhost

  • Recipe: nginx::enable_stats

  • Recipe: nginx::default

  • Recipe: mail_postfix::s3_restore

  • Recipe: mail_postfix::s3_backup

  • Recipe: mail_postfix::default

  • Recipe: rjg_aws::default

  • Recipe: rjg_utils::aio_ebs_volume

  • Recipe: rjg_utils::aio_ebs_volume_disable_continuous_backup

  • Recipe: rjg_utils::aio_ebs_volume_enable_continuous_backup

  • Recipe: rjg_utils::aio_ebs_volume_snapshot

  • Recipe: db_mysql::install_mysql

  • Recipe: app_wordpress::update

  • Recipe: app_wordpress::s3_restore

  • Recipe: app_wordpress::s3_backup

  • Recipe: app_wordpress::deploy

  • Recipe: rs_utils::install_mysql_collectd_plugin

  • Recipe: rs_utils::default

  • Recipe: db_mysql::setup_admin_privileges

  • RepoPath: Web & Email vhost AIO [rev 5]

  • RightScript: [OpsCode] Connect Node [rev 3]

  • RightScript: [OpsCode] Chef Run [rev 1]

  • RightScript: [OpsCode] Delete Node [rev 1]

  • RightScript: [OpsCode] Initial Chef Run [rev 1]

  • See More



C573c6abf06d31e58803f1a91348a407Luis Abarca on Dec 13, 2011 | Re: v1

i'll going to try it, thanks !

9c4fcb2916a9c49d62bb45247ea28cb0Ryan Geyer on Jan 14, 2012 | Re: v1

Hi Luis, How did your attempts to use this go? I'm happy to help if you ran into any snags!

5d14954409a7ac094b44329918b89dd2Cary Fowler on Mar 20, 2012 | Re: v1

just wondering if there were any updates on how this worked out


No Ratings

Supported Clouds


All Users

Sign-up for RightScale

Support Information

Have problems? Have suggestions for improvement? Just wanna chat with a really cool guy that likes to automate cloud stuff?

Drop me a line