Amazon EC2 provides a decent solution to highly scalable server and large data set processing. This little blog talks about the very beginning steps to make an Amazon EC2 server instance running with LAMP and SVN services. I will make it concise and expressive.
Of course! Sign up those whole bunch of services like Amazon EC2, S3…Well, you can definitely do it in this webpage. Then, you need to create an instance. Here I choose Ubuntu 11.10 Server 32-bit edition (for image ID, please refer to this page). For HOWTO create an instance, you can either google it, pretty simple. But please remember to keep the key associated with the instance well.
When your instance is ready to use, we will use SSH to login. Since the design choice requires the key is kept not so public that you’d better to change rights for the key file. In Ubuntu, try the following command in your Terminal:
$ sudo chmod 400 amazon-ec2.pem
After you get it done, you can login to your Amazon EC2 instance via the public DNS. Suppose you have the DNS: c2-192-168-10-90.compute-1.amazonaws.com.
Then you can login the instance with your key.
$ ssh -i amazon-ec2.pem firstname.lastname@example.org
Basically, you should use
ubuntu as the user name when login.
Once you login, things become easy as you do your local Ubuntu Server. Apparently, you need the following software.
$ sudo apt-get install lamp-server^
This two command line will guide you to setup your LAMP stack. Then try the URL: http://ec2-192-168-10-90.compute-1.amazonaws.com, which will show “It Works!!”.
However, this is not end for using phpmyadmin. You need a very small configuration to make it work, though sometime it works without doing anything. If you install those two packages, the Apache2 configuration file is in /etc/apache2/apache2.conf; the phpmyadmin configuration file is in /etc/phpmyadmin/apache.conf. So add the following line to Apache2 configuration file:
Now the phpmyadmin should work correctly, you may verify via the URL: http://ec2-192-168-10-90.compute-1.amazonaws.com/phpmyadmin. If you failed, you’d better to read this article.
Install the Subversion.
$ sudo apt-get install subversion
Config the SVN server. Suppose you want the following URL as your SVN repository: http://ec2-192-168-10-90.compute-1.amazonaws.com/repos/your-project-here.
First, you need two directories in the /var/www. One is /var/www/svn where you create your svn repository, the other is /var/www/svn-auth where stores users’ password. The /var/www/svn should belongs to www-data and have a more public rights. Run the command:
$ sudo chown -R www-data.www-data /var/www/svn
Second, you must modify the /etc/apache2/sites-avaliable/default:
$ sudo vim /etc/apache2/sites-available/default
Then add the following to the file:
ATTENTION: the red label part should be consistent, or you will be failed to find the correct URL.
Finally, restart the Apache server by using the following command:
$ sudo service apache2 restart
Now the configuration should be OK!
Create user name and password. Use the following command:
If it is the first time:
$ sudo htpasswd -cb /var/www/svn-auth/passwd user-name passwd
$ sudo htpasswd -b /var/www/svn-auth/passwd user-name passwd
Run more times if multiple user needed.
Create a test repository and start the SVN service.
Now the “test” project’s repository is ready to use! Don’t forget to chmod /var/www/svn every time you add a new repository, otherwise someone may not be able to commit.