Installing a Web Server on Ubuntu

Asif Ahmed

In the previous blog post we saw how to install Ubuntu on AWS EC2. Today we will see how to install a web server on this Ubuntu instance.

Here is a video of me installing all the necessary “stuff” on the Ubuntu instance. Below I’ll cover the install in more detail.

Once you have SSH’ed into your server, you can install Apache, MySQL, and PHP with pretty much a one line command. Apache is the web server which “serves” or delivers web pages to the user. MySQL is a database management software. PHP is the server side programming language for processing and communicating with MySQL. These programs along with Linux form the popular LAMP (Linux Apache MySQL PHP) stack. Here is the one line command that will install everything for you –

sudo apt-get install apache2 mysql-server php5 php5-mysql libapache2-mod-php5

The install should take 2-3 minutes. Once the installation is complete, go to the server IP address (remember, we set the IP address when setting up Ubuntu) and you should see a web page saying “It works” in the browser. Congratulations!

To add more pages and pretty much edit anything on your website, you will have to go the directory ‘/var/www’. This is the directory you should put all your web files initially.

  • eax

    I was able to complete your tutorial except for the last part. I can’t go to the server ip address. Can you provide some assistance? Do I need to change the file permission to the index.html file? I typed the elastic ip address that I associated to my aws web page into the address bar of my web browser, but it just times out.

  • eax

    I figured it out. I needed to update the security rules to allow http access on port 80.

  • Pradeep G

    It’s not working for me. I have installed the apache2 on the AWS Ubuntu 12.04 Server. But I’m not able to connect to it from the IP address.
    It would be of great help if you help in resolving this.

    Thank you !

  • Pradeep G

    Thanks !

    It worked I had done a mistake while adding ports in security groups.

    If any one is facing issues Please go through this awesome video tutorial. http://www.youtube.com/watch?v=ZXbri_UJfPI&NR=1&feature=endscreen

  • Wayland H

    I had the same Port 80 problem. Thanks for the tips! The video helped a lot. Here is the direct link to the time of video that is most important.