How to Deploy a Cloud Webserver in 5 minutes – LAMP

By Matt Dunlap on January 4th, 2010 6 comments
Tags: , , , , ,

Cloud based webhosting is all the rage. The ability to deploy servers, upgrade, downgrade and delete on the fly is a huge advantage over having to buy or rent a full server with co-location rackspace. With cloud prices starting at .015 cents/hour… It’s a no brainer if you need a full webserver.

Start a Rackspace Cloud Server now

When you control the full server, you have many more options on how the websites are ran. Of course, maintaining a full server with little experience can be risky for production servers, but if you want to learn how to set one up, here are the steps. I’m going to install LAMP (Linux, Apache, Mysql, and PHP) That is all you need to build powerful database driven websites. I’ll then update the Iptables to allow for secure access to the server and provide a fairly secure server.

You will see that most of the heavy lifting will be done with yum, Fedora’s package manager. It is used to install and upgrade software.

Install Mysql (Database Server)

yum install mysql mysql-server
/etc/init.d/mysqld start
mysqladmin -u root password YOUR_UNIQUE_PASSWORD

Install Apache2 (Webserver)

yum install httpd
/etc/init.d/httpd start

If httpd starts you will be able to enter the ip number of the server into the browser address bar and visit the website. One thing to note is that fresh Fedora installs do not allow access to port 80. So you will not be able to see the website until you edit your Iptables. for now let’s just flush them so we can look at the new webpage.

iptables -F

Flush and try again, if you see the Fedora test page, congrats, your up and running. You can only server HTML files. We now need to install PHP for server side scripting.

Install PHP5

yum install php
/etc/init.d/httpd restart

To check PHP, go to the default www folder located at /var/www/html/ and make a new file called info.php. In that file add this code

<?= phpinfo(); ?>

Then hit that page in your browser and you should get all the information about your PHP installation.

Everything looks good, but PHP is not talking to Mysql yet, we need to connect them.

yum install php-mysql
/etc/init.d/httpd restart

Optional, but recommended

In our current state, if the server gets restarted, our LAMP server will have to be started manually and the iptables will have to be flushed again. So, enter the following commands to make sure httpd and mysql start automatically on boot up.

chkconfig --levels 235 mysqld on
chkconfig --levels 235 httpd on

You will probably need a few more php modules installed

yum install php-gd php-xml php-xmlrpc php-eaccelerator php-mbstring php-mcrypt php-mhash php-soap php-tidy

Don’t forget to restart httpd after you install the modules
There are many more, to do a search for all modules

yum search php

Then for the iptables, instead of flushing them, and opening up the server, we are going to just open port 80 so you can display your website. Port 22 is the only port open by default. Make sure you don’t remove that or else you will not be able to access the server.
First reload the old iptables

iptables-restore /etc/sysconfig/iptables.old

Then append the new iptables entry:

iptables -A INPUT -p tcp --dport 80 -j ACCEPT
services iptables save

Next check the iptables again to make sure you are allowing SSH and HTTP

iptables -L

If they are there, restart iptables

/etc/init.d/iptables restart

Check your website again to see if you can access it. If you server gets restarted you should reboot with these two ports open.
Here is a list of common entries for Fedora
Another helpful page for iptables at ubuntu.com

Now that the server is up and running we need to start adding  virtual directories and domain names. The next couple of posts will cover setting up virtual directories and parking domains, how to set up a templated website directory so you can deploy many websites fast, and I’ll cover more on how to set up WPMU with top level domain names. I have a post about TLD’s, wpmu and godaddy… but with your own server it is much easier and you can automate it!


My next post is going to be awesome... Subscribe to my feed so you don't miss it

Large RSS Feed Button


Previous Post Next Post

6 Responses to How to Deploy a Cloud Webserver in 5 minutes – LAMP

Anonymouse
Comment added: 5 January, 2010 at 9:57 pm

Setting up a server with a bunch of shell scripts sounds fun, until you need to tweak something on a running server. Do you update the server, then update the shell script and hope you didn’t make a mistake? Ick.

You should look into Chef (opscode.com).

koko
Comment added: 17 April, 2010 at 8:19 am

After VPS installation, How Can I add the domain(s).?

regards,
koko

Matt Dunlap
Comment added: 17 April, 2010 at 8:45 pm

you need to edit the /etc/httpd/conf/httpd.conf file and add the virtual websites there. make a virtual host for each website you want to host. The httpd.conf file has some examples that are commented out. don’t forget to restart the webserver after each change with /etc/init.d/httpd restart


[...] You will need full access to a webserver. This will not work on a shared host. I’ve written tutorials for WPMU and Godaddy here. You can still run WPMU, or WordPress 3.0 multisites on Godaddy (or any other shared host), you just can’t do it dynamically. Here is my tutorial for deploying a cloud server in 5 minutes [...]


[...] Setting up a cloud server is ridiculously easy and fast. I’ve already created a 5 minute tutorial to set up a webserver on a Rackspace cloud complete with mysql, apache and PHP. All you have to do is copy a paste the [...]

How to secure a cloud webserver with iptables | Blog Smarter
Comment added: 16 July, 2010 at 8:01 am

[...] then go and do my business of installing LAMP and [...]

Post a Comment

Name:   
Email:   
Website:   
Comments:   
alert icon Do you need help with your website? I can offer full system admin, website development and Internet marketing services
Domain Name Deals
.COM for $1.99
With any non domain name purchase
Free Private Registration - When you buy or transfer 5 domains at opendls.com
Domain Name Reseller Accounts
Low buy rates - Very Profitable
Matt Dunlap on Why am I getting redirect loop errors with FireFox 3.6.8?
Hi, thanks for the heads up... Have you experienced this problem with any other websites? It's reall[...]
Stacy on Why am I getting redirect loop errors with FireFox 3.6.8?
I was attempting to follow your links to these tutorials from your youtube video, and I was using th[...]
Matt Dunlap on 301 redirects will lower your Google Pagerank
You want 301 redirect on same site redirects mainly to eliminate duplicate content. For example, if [...]
Kate Mag on 301 redirects will lower your Google Pagerank
great info. Does this mean that only affecting 301 redirect to another domain. I have 301 redirect t[...]
Mike Johnson - Real Estate Agent on Why is making extra money a bad habit?
Hey man, this is some great stuff. The only thing I can't figure out is why this sort of thing isn'[...]

Top Guest Bloggers

LoneWolf
View Posts | RSS

Guest Bloggers Welcome!


Powered By: Free Premium WordPress Theme | Copyright 2007 - 2010 mattdunlap.org Sitemap