Amazon EC2 webpage creation tutorial
There are a decent number of tutorials about setting up a webpage on Amazon's EC2-cloud, but it still took me a few hours to get everything working. This is my list of steps that were necessary and not entirely obvious.
Setting up the Server
This was incredibly straight-forward. Make an Account, launch a new instance. I chose the Amazon Linux AMI just because I could. I do not have significant experience with Ubuntu or other distributions, and figured going with what Amazon designed for their own service would probably work best. It will generate a keyfile for you, which you should store in an accessible but safe spot.
IP-Adress and Security
Also very simple: Add an elastic IP (create, then attach), and open up port 80 for your instance to the public.Logging in via SSH
In my case, I am running Windows 7, so all the clever terminal trickery of Linux and OS-X feels somewhat arcane. Install Cygwin (and don't forget to select SSH during its install!), copy the keyfile in its usr-directory so you can find it. It will probably have the wrong permissions, so fix that with chmod 600 keyfile.pem.The next trick is to know that the user-name of the root account is called "ec2-user" on the Linux AMI.
Finally log in with ssh -i keyfile.pem ec2-user@xxx.xxx.xxx.xxx.
Installing Apache
At this point, AMI will probably greet you with a list of required security-updates. And a command to do so. The following will be necessary.[1] sudo -q httpd
[2] sudo -q tomcat5
To check if httpd is installed and running. It probably is not.
[3] sudo yum install httpd tomcat5 mysql php
Install the usual packages: Apache, mysql, php.
[4] sudo service httpd start
Start the webserver.
[5] sudo chkconfig httpd on
Configuration that restarts the webservice on reboot. Not required, but certainly practical.
Webpage
Finally, you should be able to connect through your browser to the webpage by means of raw IP-adress, and see a generic Linux AMI Test informing you of your success.FTP
Lastly, the content of the webpage is in /var/www/html. If you are lazy like me, you want to do with with some sort of easy FTP-program. I use Filezilla. Open its server manager, add a new server with the EC2-IP, and choose SFTP as the protocol. That way, you need neither open any ports nor rely on passwords. Don't forget to change the user to "ec2-user" once more, and leave the password blank.Lastly, go into Filezilla's Settings/Connections/SFTP, and add the keyfile. It will convert it to the format that putty uses. Then you can finally connect, and browse to the folder where the webpages are.
[1] sudo chown -R ec2-user /var/www/html
This will make the ec2-user the owner of the html-file-folder, allowing you to upload stuff.
DNS
Forwarding your domain to your new webpage seems easy (though I cannot yet check if it works, as I'm waiting for DNS records to update). You have to start a new "Route 53" service instance from the Amazon AWS management page, and add your domain there. It will then display the nameservers that your domain registrar needs. Note that this service always costs money (half a dollar for my first month with literally zero traffic), unlike EC2 itself, which is free for the first year, and relatively expensive afterwards (around $25 for a 24/7 server).MySQL
Actually I prefer Postgres, but I digress. Installing it is easy enough, only two packages (mysql and mysql-server) are required. Start the service (and config for automatic starts on reboot), then launch the very practical script "mysql_secure_installation" and go through all those questions.Some of the sources I used to puzzle this together:
http://docs.moodle.org/24/en/Installation_Guide_for_Installing_on_Amazon_EC2