AWS (Amazon Web Services) is an advanced cloud platform which offers lots of features. As cloud platforms go it is mostly for larger projects that need to be able to scale. That said Amazon offers a free tier, which means that you can test out their features for one year for free. Yes, you get cloud services to play with for free! More info on Amazon’s Free Tier page.
AWS can have a slightly steep learning curve if you haven’t worked with cloud administration before so here is a straight forward guide to get your own LAMP box up and running on AWS.
1. Create a new AWS account here, if you are an existing Amazon customer you can simply login with that account. Once you are logged in go into the AWS Management Console, from the menu in the upper right of the page.
2. Now we need to set up your security group, the basics for allowing you to login to your server. Click on EC2 to enter the EC2 Dashboard. EC stands for Elastic Cloud which is Amazon’s name for their Cloud Servers. Click on Security Groups under Network & Security in the left menu and select the default group in the table. Select the Inbound tab and add rules forSSH, HTTP and HTTPS, then click apply Rule Changes. If you need other protocols for your server you need to add them here.
3. Let’s create an instance. Click on Instances under instances in the left menu and click launch Instance. Select the quick Launch Wizard and type in a descriptive name for your instance. Choose to create a new key pair and download the key, which is a .pem file you need to access your server securely. Then select a launch configuration from the list, my suggestion is one of the Ubuntu Server configurations which are eligible for the free tier. You always need to keep an eye on what you do in the AWS Management Console since you don’t want to enable stuff Amazon will charge you for. ClickContinueand then Edit Details. Make sure that under security Settingsthedefaultsecurity group is selected. It is important that you configure the security groups before launching the respective instance since you won’t be able to change it after launch. ClickLaunchand in a couple of seconds your instance will be up and running. Congratulations you have a new LAMP box to play with.
4. In order to connect to the instance, we need to assign an IP address. In the left menu in theEC2 Management Console select Elastic IPs under Network & Security. Allocate a new address and assign it to your instance. Elastic IPs are free as long as they are assigned to an instance, so remember not to leave any unallocated IP addresses as you will get charged by the hour. Remember the assigned IP.
5. On your local machine use the .pem key to SSH into your instance. On OS X change the permission of the key to 600 and use the following command in terminal:
ssh -i yourkeyname.pem ubuntu@yourelasticip
and boom you are in.
6. Update the Ubuntu package manager and the installed packages:
sudo apt-get update sudo apt-get dist-upgrade
7. Install Apache:
sudo apt-get install apache2
8. Enable .htaccess files by editing the /etc/apache2/sites-available/default file, fx with vi. Look for the /var/www directory and make sure it contains AllowOverride All.
9. Enable the rewrite module in Apache:
sudo a2enmod rewrite
10. Install PHP
sudo apt-get install libapache2-mod-php5
11. Restart Apache:
sudo /etc/init.d/apache2 restart
12. Ensure that Apache is running by typing the instance IP in your browser.
13. Allow the Ubuntu user to work with the /var/www folder:
sudo adduser ubuntu www-data sudo chown -R www-data:www-data /var/www sudo chmod -R ug+rw /var/www
Logout and login again to pick up the new user group. Test by creating a directory and deleting it again in www without having to sudo. This will make your life easier since permissions will get messed up less once you start adding frameworks and tools to your web service.
14. Test PHP by cd into /var/www folder and typing sudo vi phptest.php. Hit i key to enter insert mode and just write a simple php script with a phpinfo() call. Hit ESC to exit insert mode and type :wq to save and quit the vi editor. Go to instanceIP/phptest.php in your browser and you should see the phpinfo displayed.
15. Install MySQL:
sudo apt-get install mysql-server sudo apt-get install php5-mysql
Insert root password for the database and remember it.
16. To test MySQL let’s install PHPMyAdmin:
sudo apt-get install phpmyadmin
Select Apache2 as server and Create Databases, just follow the instructions. Go to instance IP/phpmyadmin to test.
If there are any issues check the ubuntu community for help.