Host Static Files with Apache on Digitalocean

1. Setup Digital Ocean Server

Login or create an account and spin up a new ubuntu 14.04 droplet at www.digitalocean.com, it is pretty self explanatory. In the options, you should choose login through SSH if you want to follow this article step by step.

Then login to your Server:
ssh root@<yourIp> (e.g. ssh root@46.101.131.21).

2. Install Apache

sudo apt-get update
sudo apt-get install apache2
When you type <yourIp> into your browser (e.g. Screen Shot 2016-04-29 at 12.12.09), you should now be able to see the following:
Screen Shot 2016-04-29 at 12.10.23

3. Change index.html

Now “hosting static files” can mean two things. Either you want to host something like mycoolfile.txt or you want a classic website.

Option 1: Host files for downloading

  1. Switch directory to cd /var/www/html and remove the index.html file (rm index.html)
  2. Copy the files to your server. Navigate to the directory containing your file in a new terminal window and scp mycoolfile.txt root@<yourIp>:/var/www/html.

You should see the following result when navigating to yourIp in your browser:

Screen Shot 2016-04-29 at 12.40.03

Option 2: Host your personal website

  1. Switch directory to cd /var/www/html and remove the index.html file (rm index.html)
  2. Then nano index.html. Then you can write any valid html, for example:
    <!DOCTYPE html>
    <html>
    <body>
    
    <h2>Much Doge! Wow!</h2>
    <img src="https://s-media-cache-ak0.pinimg.com/736x/ee/b7/71/eeb771122eebac79dda2eb99d43e3d82.jpg" alt="Doge" width=300px>
    
    </body>
    </html>
    

    which should yield:
    Screen Shot 2016-04-29 at 12.54.40

 

Leave a Reply

Your email address will not be published.