Deploying WebCalendar to AWS

In this post, I am going to go over some of the options for installing WebCalendar using Amazon AWS. While both GCP and Azure provide a lot of the same services, AWS has the most market share in cloud services. So, let’s start with AWS. There are 200+ products and services available in AWS. That’s a lot of services! That means there is more than one way to deploy WebCalendar in AWS. I’ll go over the most common ways and discuss the benefits and issues with each here. Also, note I don’t tackle setting up HTTPS with a certificate here. That’s a discussion for another post.

Lightsail LAMP

Lightsail is a cost-effect way to get a LAMP system up and running in AWS with minimal work on your end. In fact, this very website (k5n.us) is hosted using Lightsail. This essentially sets up an EC2 instance (more about that below) for you so that you don’t need to be bothered with some of the security and network knowledge typically required to properly setup and secure an EC2 instance that hosts a website. Amazon provides a tutorial on how to setup LAMP with Lightsail right here. Once you have your LAMP setup working, the remaining steps are pretty simple and familiar if you’ve installed WebCalendar before:

  • Download a copy of WebCalendar. You can use curl, wget or even git clone to do this. Place a copy of the unzipped WebCalendar files in your document root (often /var/www/html).
  • Access WebCalendar with your web browser using the external IP address for your EC2 and follow the install pages.

Pros:

  • Easiest setup. No AWS networking experience required.
  • If you need cron jobs (to send email reminders), that is simple to do since you have a full Linux operating system.
  • Cost effective. ($4 USD per month on average as of 2022, which beats most PHP hosting providers.)

Cons:

  • Slow. You’re not paying for a premium VM here, so your site may run a bit slow.
  • Unlike many of the AWS managed services, your system will not be updated before you. It’s up to you to upgrade your installation, and there is not a lot of good documentation on how to do this. If you leave it up and running for a year, your OS and PHP installation may be vulnerable to attack.
  • This is a manual hands-on process.
  • There are no automated database back-ups. You’ll need to do that yourself.
  • There is no simple way to scale up this architecture other than exporting the database and reinstalling using one of the architectures below.

EC2 Instance

An EC2 instance is essentially a cloud-based VM (virtual machine). For those unfamiliar with AWS, using a single EC2 instance is perhaps the best place to start learning (if you want to learn more about AWS). If you are unfamiliar with AWS but comfortable with a VM (perhaps from using VirtualBox or VMWare), this is an easy transition. You’ll need to get familiar with AWS networking to set this up and make it secure (VPCs, Subnets, Security Groups, etc.). To get started, you’ll need to select an operating system for your install. There are many Linux operating systems to choose from (Ubuntu, etc.) including one provided by Amazon. I normally go with Amazon Linux for a number of reasons (optimized for AWS, frequently updated, used in many online tutorials/examples, etc.) You’ll pick your base AMI (starting image), choose your storage and network settings, and off you go. Once your EC2 is up and running, you can login from your desktop using your SSH keys (normally creating and downloaded when setting up your EC2). From your EC2 command line, you can do the following:

  • Configure LAMP (Apache & MySQL). Here is a simple tutorial on how to do this in Amazon Linux.
  • Configure MySQL access for WebCalendar by following the WebCalendar install instructions.
  • Download a copy of WebCalendar. You can use curl, wget or even git clone to do this. Place a copy of the unzipped WebCalendar files in your document root (often /var/www/html).
  • Access WebCalendar with your web browser using the external IP address for your EC2 and follow the install pages.

Pros:

  • Easy for those comfortable with a VM.
  • If you need cron jobs (to send email reminders), that is simple to do since you have a full Linux operating system.
  • If you choose the right EC2 instance type, this is Free Tier eligible
  • To scale this architecture up, you can move your database to AWS RDS and you can choose a different EC2 instance type with better performance (see here).

Cons:

  • Requires knowledge of Amazon’s networking terminology (VPC, Subnets, Security Groups, etc.)
  • Requires manually updating your EC2 to keep everything current (OS patches, etc.)
  • This is a manual hands-on process.
  • If you choose a powerful EC2 instance, this can get very expensive.
  • There are no automated database back-ups. You’ll need to do that yourself.

ECS Fargate and RDS

This is the most robust way to install and run WebCalendar in AWS. Of course, it will be the most expensive and complicated to setup. The main cost drive here is AWS RDS, which is the managed service AWS offers for MySQL. AWS managed services (see here for Amazon’s explanation for why managed services are great) take care of a lot of worries for you, so that you don’t need to. For RDS, that means guaranteed uptime and automatic back-ups. You don’t need to worry about all that… you just need to pay for it.

ECS Fargate is how you deploy a docker container in AWS. There is no public docker image for WebCalendar yet, so you would need to build the image and deploy it to ECR. You can then setup a task definition in ECS pull down the image from ECR and run it. There is a learning curve to using ECS. This is more complicated than using either Lightsail or EC2. You would likely need to use AWS Secrets Manager to store your RDS credentials. You would likely have an Application Load Balancer (ALB) to sit in front of your running container. And you may also want to configure a Web Application Firewall (WAF) to either limit access or protect against certain attacks. To keep your WebCalendar installation secure, you will want to periodically rebuild your container image with the latest PHP and OS updates and redeploy the container.

Pros:

  • Most scalable solution.
  • Automated database backups and guaranteed uptime.
  • Most secure solution.

Cons:

  • Most expensive solution.
  • Requires significant AWS knowledge to do properly.
  • This is still a manual process (subject to human error).
  • If you need email reminders, you’ll need to setup another method to send them out (e.g. Lambda function that reaches out to the send reminders script on a scheduled trigger).

The Best Solution: Infrastructure as Code

The best solution would be to automate the ECS Fargate and RDS deployment above using AWS CloudFormation. This would take a bit of work to do. You would need to include a method of installing and configuring WebCalendar on first startup. But once properly coded in a CloudFormation YAML template, you could deploy the entire stack with a few mouse clicks. You could also easily do multiple deployments in the same AWS account (development, test, integration, production). This could also be done with Terraform instead of CloudFormation, which would allow you to deploy to other cloud providers like GCP and Azure.

What about other PHP applications?

Yes, you may have noticed that almost everything discussed above applies to any PHP/MySQL application you want to deploy. An alternate title to this article could have been How to Deploy and LAMP Application to AWS.

Leave a Reply

Your email address will not be published. Required fields are marked *