In an earlier post, I explained that I migrated from my regular web host over to Amazon EC2 for the purpose of running my various websites. Here, I will detail how I got up and running and configured with a full blown CentOS 5 LAMP (Linux, Apache, MySql, PHP) server including support for .NET via Mono.
First off, if you are new to Amazon’s Elastic Compute Cloud (EC2) then I highly recommend taking a look at t their Getting Started Guide first.
Signup for Amazon EC2 if you haven’t already done so. The Sign Up for EC2 guide is helpful here.
Launch a new EC2 instance from the AWS Management Console: I recommend using the community AMI ID ami-48f90621 which is CentOS 5, 64 bit. To select this AMI when launching, click “Community AMIs” and search for the ID. See the screen shot below.
- Connect to your new instance using the ssh client of your choice. Note, you’ll need to use the Key Pair your generated when you launched your instance to connect. When asked for the username enter root. I use PuTTY from Windows and it was a little tricky to get connected but the Appendix: PuTTY helped.
- Prepare for software installation. In order to install Mono, you’ll need to add the Novell Mono Repository to yum so the mono packages can be found. * Create the file /etc/yum.repos.d/mono.repo (i.e. nano /etc/yum.repos.d/mono.repo) with the following contents. Optionally, you can run the following command and skip this step to make things a bit easier: wget /wp-content/uploads/mono.repo /etc/yum.repos.d/
[novel] Name=Novell Mono Repository baseurl=http://ftp.novell.com/pub/mono/download-stable/RHEL_5/ enabled=1 gpgcheck=0
- Install software packages by issuing the following commands from the shell:
- yum install httpd [enter]
- yum install php [enter]
- yum install mysql-server mysql[enter]
- yum install mono* –disablerepo=epel,extras[enter]
- yum install mod_mono* –disablerepo=epel,extras[enter]
- Start services by issuing the following command:
- service httpd start [enter]
- service mysql start [enter]
- Configure PATH environment variable for mono by running this command: export PATH=/opt/novell/mono/bin:$PATH **. To persist this after a system bounce, add the same line to the end of the /etc/profile file.
- Test your server by opening a browser and navigating to your “Public DNS” domain (i.e. http://ec2-00-00-00-000.compute-1.amazonaws.com). The Public DNS domain can be found on the properties of your EC2 instance in the AWS Management Console. If you get a page that says “Apache 2 Test Page” you are good to go.
That’s it. You are now up and running with a CentOS x64 LAMP Server capable of running .NET applications. There is obviously more you will want to do depending on your needs but the steps above give you server that is “ready to go”.