I've started looking at Amazon Web Services as a cheap and easy way to host my various projects. Yes valued reader, that is another reason for this blog to die!
Since my memory is horrible I'm going to make a couple posts about the "problems" I faced. And by problems I mean things that weren't immediately obvious.
Creating a server
So you want to create a server? That's pretty vague. Let's attach some context.
> PHP, Linux, potential for autoscaled instances, auto load balancing, MySQL, simple code upload process.
Great! Let's use AWS Elastic Beanstalk!
- Click the 'Create New Application' link in the top right.
- Enter all the details, paying attention to:
- Environment Tier
- Instance Type
- Application Source
- The "Create an RDS DB Instance with this environment" option
- Creating the RDS
Things of note.
- You don't have to choose an auto-scaled application right off the bat. You can select a single instance and change it later. This is great for testing that things actually work.
- You can add multiple environments later. If you want to separate dev, test and prod, you can do that.
- It gives you a readable URL. That's nice.
How do I create my Application Source
A .war file for Java or a .zip for other supported languages. Pretty simple.
Uploading a new Version
- Click on the environment you want to upload the new application version to.
- Click "Upload and Deploy"
- Upload your version and give it a name
- Click Deploy
Connecting to your RDS through PHP in your EC2
Now that you have an RDS and your PHP in an EC2 (or a couple of them), you are going to need to find a way to connect to the RDS.
Here is the PHP Guide for accessing your RDS and here is a link to all the guides for accessing your RDS from each language.
Setting environment variables
Now that you can connect to your RDS you are probably going to want to store your database access credentials as environment variables. Here's how you do that:
- Select the Environment for which you would like to add the variables
- Select Configuration from the left hand panel
- Click the gear icon on the Software Configuration box
- Scroll to the bottom of the page
I'm sure there will be more stuff but this will do as a quick post for now.