Saturday, January 26, 2013

Got the web server up and running in the cloud now.

First the bad news. For some reason the Amazon Web Service console was running very badly under Firefox.  It was taking forever to load and Firefox kept popping up warnings about a script taking too long to run.  Not sure why, but the good news is that it flies under Google Chrome.

I finally got the login figured out, I just didn't have the right user name a couple of days ago.  Again, I followed the directions here:

The key was to use the proper user name for that image that was booted for my instance. 
ssh -i TestingForClass.pem
Of course this is not my real server number, you have to look your instance server name up on the amazon site in  aws -> ec2 -> instance or Again, your home may be in a different region, but you can jump around between regions very easily too.

The -i followed by the filename.pem file is that  private key that you downloaded when you were setting up the system following my other directions: Remember to never lose this file, because you cannot download a new one.  I'm not even sure how you would recover from losing this file.

Once I connected a banner came up from the system giving some info.  The system recommended that I install updates, which I did, then I rebooted, not because I had to, but because I wanted to see what would happen.
sudo yum update
About 40 packages were quickly updated.
sudo shutdown -r now
Of course this logged me out, and after a couple of minutes I was able to ssh back into the terminal.   It is great that the server didn't stop because it was restarted.

Now I wanted to see what services were installed on the system so I changed to
cd /etc/init.d
It only had a minimal set of services running to be as secure as possible.  Now, I need a LAMP server for class.  I already had the Linux, but now I needed the AMP.  So I ran the command
sudo yum install apache php mysql mysql-server
sudo ./httpd start
You want to make the database safer to run so run this command and follow the prompts:
Then you can run the mysql server
sudo ./mysqld start
If you type the hostname you found from your instance data on the ec2 instance console you will see a default page, but that is ugly and we must change that.  Plus you don't know if that is your box, or someone else's unconfigured box, so we must find out.
A non working example using the same  fake hostname I made up for my ssh login above is :  

You must find and use your real hostname or this won't work.

If you can't see anything here, then you may not have opened up ports 80 and 443 in the security tab for your instance.  I know that I did and I still don't see anything, so checking on the box for port 443 tells me the following;

Running this command in the ssh terminal:
netstat -an | grep 80
gives this output:
tcp        0      0 :::80                       :::*                        LISTEN  

Which tells me that the web server is listening on port 80.

But running the command: 
netstat -an | grep 80
Gives no output which means that Apache will have to be configured to listen on the secure port in order to be a secure ecommerce site.  I'll will write up an article on Apache by itself.
You want to customize  the web page that is showing: 
cd /var/www/html/ 
sudo vi index.html
Edit this file to your hearts content.   I just did a quick html set of tags, inside that I put a head and body set of tags and inside the body I made a paragraph set of tags and put Hello, World! inside the inner <p> tags.

When I type the url to my box in I see "Hello, World!" so we know that is working.

I still need to test the php, so I make a quick phpinfo.php file:
sudo vi phpinfo.php
And type in the following:

<?php phpinfo(); ?>

Then save and quit. 
Try to load this file using the same hostname as above followed by /phpinfo.php like this:

After going back and adding the php after the first question mark, it works just great and shows that my server has the required modules that I will need for the class.

Next thing for me to do is to select and try out a framework that I will use to create my e-commerce site for my college class.

Happy webbing, spider friends!

No comments:

Post a Comment