Self-Hosting Guides  ->  The Basics

Upload Our Content

Checklist

Create Our Content

For this guide we're primarily concerned with the process itself, we aren't here to create a fancy website, so we're going to create the most basic web page you can, a single HTML file with nothing but the text, "Hello, World!" in it.

Using any text editor, create a new document and type the below text into it:

Hello, World!

Save the file as index.html. Pay attention to the folder you save the file in, as we'll need this later.

Here's a screenshot of a what I mean. We literally want nothing but "Hello, World!" in the index.html file.

Text editor

That's it, our super basic "website" is ready to upload.

Upload Our Content

Now that we've created our content, it's time to upload it to the Raspberry Pi. We're going to use the scp (secure copy) command to copy our index.html file from our local machine to the Raspberry Pi.

We should now open the terminal and change to the local folder that contains our index.html file. In our case, it's /home/greg/website.

cd /home/greg/website

Once there, you should run the following scp command, swapping your username in for greg (2 instances) and your IP address in for 10.23.4.14.

scp index.html [email protected]:/home/greg

After running this command, your new website, aka, the index.html file, will be uploaded to the Raspberry Pi and placed in the /home/greg directory.

Although the live web files on the Raspberry Pi are actually stored in /var/www/html, our standard user, greg, doesn't have permission to write to this directory. To work around this, we've uploaded the index.html file to our home directory, /home/greg, and now we need to move it to the correct location using the mv (move) command, after we SSH back into the Raspberry Pi.

ssh [email protected]

And then once you're on the server, run the mv command to move the file to the correct location.

Again we have to use the sudo command, which gives us temporary root privileges, otherwise we wouldn't be able to write the file to the /var/www/html directory.

sudo mv /home/greg/index.html /var/www/html

We can then use the cat (concatenate) command to view the contents of the index.html file in order to make sure that the contents are correct.

cat /home/greg/index.html

This is what everything will look like together:

All steps

With our super fancy new website uploaded, it's time to make sure that it's working properly. Open a web browser on your local computer and type your Raspberry Pi's IP address into the address bar. You should see nothing but the text, "Hello, World!" displayed on the page.

Local website


Content Uploaded

Congratulations, you've successfully replaced the default nginx welcome page on your Pi!

Next, it's time for the most exciting part of the entire guide, making your website publicly accessible to the entire world!