Host Your Own Website On Your Raspberry Pi
Whatsapp Pinterest

Need to run a website but can’t afford the hosting costs? One way around this is with the Raspberry Pi, which is more than capable of running basic web server software. Best of all, setting it up is simple.

Why Use A Raspberry Pi?

We’ve previously looked at the many amazing uses for the Raspberry Pi The Top 5 Amazing Uses For Your Raspberry Pi Computer The Top 5 Amazing Uses For Your Raspberry Pi Computer I’ve recently received my Raspberry Pi after a long wait – and I’ve got quite a few plans for it. The problem is, I’m not totally sure which project I want to attempt first. While... Read More – but who knew it could run as a web server? Whether you’re looking for an Internet-facing site (perhaps as a basic home page), a small-scale corporate intranet, or a test machine you run a WordPress development system on (or even the new Ghost blogging platform Wordpress Killer? Welcome To Ghost (and How to Install it on a Raspberry Pi) Wordpress Killer? Welcome To Ghost (and How to Install it on a Raspberry Pi) Read More ), it’s easy to setup.

There are various good reasons to setup a Raspberry Pi as a webserver. For instance, your desktop computer may not have the available system resources to serve pages reliably. Alternatively you might be interested in using it as an always-on web server offering content that anyone can access, which means leaving the device switched on for lengths of time. As the Raspberry Pi has a very low energy footprint, this makes it an ideal choice.

Other reasons exist. The size of the computer makes it useful as a portable device, something that might prove useful if you are trying to run a web server in a territory where this isn’t usually allowed, or if hosting is expensive for you.


Getting Started: Setup Your Server Hardware!

Before you get started, ensure you have all of the necessary hardware. Our guide to the basic Raspberry Pi setup What Is The True Cost Of Running a Raspberry Pi? What Is The True Cost Of Running a Raspberry Pi? The Raspberry Pi - a small, compact and versatile computer, capable of processing HDMI and MPEG-2 being the central component of any number of weekend projects from retro gaming stations and media centres to smart... Read More should help you here. In addition, you should ensure your device is connected to your local network. This might be via Ethernet or you can setup Wi-Fi with a suitable dongle Setting Up Wireless Networking on Your Raspberry Pi Setting Up Wireless Networking on Your Raspberry Pi Virtually every Raspberry Pi project will require a network connection, and considerable flexibility can be gained by ignoring the Ethernet port in favour of a wireless USB dongle. Read More .

You should also have a suitable distro installed to your SD card. Several are available 11 Operating Systems You Can Run on Raspberry Pi 11 Operating Systems You Can Run on Raspberry Pi The Raspberry Pi's hardware is only one side of the coin. Here are some different Raspberry Pi operating systems you can install. Read More ; the steps in this guide were performed using Raspbian.

It is worth taking the time to setup SSH on your Raspberry Pi Setting Up Your Raspberry Pi For Headless Use With SSH Setting Up Your Raspberry Pi For Headless Use With SSH The Raspberry Pi can accept SSH commands when connected to a local network (either by Ethernet or Wi-Fi), enabling you to easily set it up. The benefits of SSH go beyond upsetting the daily screening... Read More too, as well as TightVNC VNC, SSH and HDMI: Three Options for Viewing Your Raspberry Pi VNC, SSH and HDMI: Three Options for Viewing Your Raspberry Pi The Raspberry Pi is a remarkable little computer, but it can be time consuming to set it up and connect it to your monitor. Read More .

Configuring Your Raspberry Pi As A Webserver

Before you upload your HTML pages to your Raspberry Pi, you’ll need to configure the server and its software.


Begin by running an update using sudo apt-get update. You’ll then need to install Apache and associated libraries, which can be done by entering:

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

Finally, enter:

sudo service apache2 restart

Next, open a browser on your computer and enter the IP address in the address bar. You’ll see confirmation that Apache is installed.

Your Raspberry Pi is now setup as a basic web server. All you need to do is add pages!

Configuring FTP On The Raspberry Pi

While you can check in the browser that your Pi is running as a web server, the page on offer will be very basic. This is a typical placeholder index.php file, one that you will have to replace with your own PHP or HTML document.

This will be far easier with FTP installed, and you can do this by first creating a suitable www directory and then installing the FTP software:

sudo chown -R pi /var/www
sudo apt-get install vsftpd

With the FTP application vsftpd (“Very Secure FTP Daemon”) installed you’ll need to make some changes to the configuration. First, open the config file in nano…

sudo nano /etc/vsftpd.conf


…and make the following permissions/security changes:





Uncomment the following lines (remove the # symbol)


Finally add this line to the end of the file:


This will force the display of server files starting with a “.”, such as .htaccess.

Press CTRL+X to save and exit, confirming with Y and Enter.

You should then restart FTP with

sudo service vsftpd restart

Using a standard desktop FTP you will then be able to connect to your Raspberry Pi. Files should be uploaded to /var/www.

Want More Than HTML? Raspberry Pi Also Supports LAMP!

The Raspberry Pi isn’t only capable of serving basic HTML pages. The LAMP server configuration can be installed if you want full MySQL with PHP support using

sudo apt-get install mysql-server mysql-client php5-mysql

As with any web server project, you need to first determine if the method you plan to use will be suitable for your needs. While it is possible to setup WordPress to run on the Raspberry Pi, adding a multitude of plugins and multiple daily updates will make it extremely slow. The website you plan to run – at least with a sole Raspberry Pi – should be light on resources and software requirements. By all means use a database driven solution if necessary, but limit the number of pages/volume of content that can be viewed.

Security & Technical Considerations

You’re unlikely to get anything nearing production-level speed when using the Raspberry Pi as a web server for anything resembling a popular website.

There are ways you can improve performance, however, such as setting up your server software on a USB hard disk drive rather than on the SD card in order to reduce degradation through regular read/write processes. Alternatively, using your device RAM for temporary read/write file storage is an option too. This is something you will perhaps want to change when you have decided how you’re going to use your very small web server.


Although suitable for setting up a test version of a database-driven PHP website, the Raspberry Pi’s online duties are probably best suited to a small collection of static pages.

Note that if you do plan to open access to your Raspberry Pi as an Internet-connected web server, you’ll need to setup your router with a static IP address What Is a Static IP Address, How Do I Get One & Its Advantages/Disadvantages What Is a Static IP Address, How Do I Get One & Its Advantages/Disadvantages In home networks, IP addresses aren't usually fixed, but they do fall within specific ranges. A static IP address doesn't change. What are the advantages to this, and why would you want one? Read More .

Finally, take the time to change your Raspberry Pi’s default password. This can be done in the command line via SSH using


You will then be prompted to input and confirm a new password. Doing this will stop anyone familiar with Raspbian from being able to access the backend of your web page.

Conclusion: A Portable Website!

The potential for using a Raspberry Pi as a web server is considerable. While it is unlikely you’ll be able to host games or a website like MakeUseOf, by employing some portable tools (such as a battery pack and mobile Internet dongle) you could use the mini-computer to host a website wherever in the world you may find yourself.

Alternatively, you might host a home intranet Quickly Set Up Your Own Home Intranet With ocPortal Quickly Set Up Your Own Home Intranet With ocPortal Have you ever thought about what it might be like to have a "portal page" for your family, just like many companies offer to employees? Wouldn't it be convenient to have a central web-based repository... Read More !

Try it out, and let us know how you used your Raspberry Pi web server.

Image Credits: Johan Larsson Via Flickr

Explore more about: Apache Server, Web Hosting.

Enjoyed this article? Stay informed by joining our newsletter!

Enter your Email

Leave a Reply

Your email address will not be published. Required fields are marked *

  1. Siamak
    August 20, 2017 at 9:15 am

    Hi All,

    I will set this up in a very near future, what I would like to know is when it is set-up and it will be located in the UK, would it allow me to geospoof my location where ever I will be.

    Please advise.


  2. Margareta
    February 8, 2017 at 12:12 am

    fantastic post you guys have at this time how everyone's first impressions on mine website on the subject of mino monsters
    2 evolution cheats free

  3. Prasanna
    May 18, 2015 at 2:23 am

    How to make this website accessed from any where in the world

  4. David
    May 7, 2015 at 8:39 am

    Good article and it works, but other than editing "index.html" can someone tell me how to add content to the default web page or how to add another web page?

  5. Henry
    April 12, 2015 at 12:57 am

    Nice article. I love the Raspberry Pi.. I have a couple of self hosted websites that are working well for the moment using old Windows machines. I am using WAMP Server which is simple to setup --> Maybe I will try the Pi soon.

  6. Anonymous
    April 2, 2015 at 2:43 pm

    Can I set it up as a AD HOC network and when people connect to it will it show my webpage

  7. shardros
    March 1, 2015 at 4:56 pm

    how do you change the html file?

  8. Vic C
    June 1, 2014 at 12:12 am

    Nice usage. I'll give it a try.

  9. Josemon M
    May 30, 2014 at 9:14 am

    Nice one..But the problem with this is that , it can't handle a lot's of user's limited capacity to traffic ..

  10. pmshah
    May 30, 2014 at 1:55 am

    I think the page loading problem has more to do with the upload speed provided by the ISP than the data fed by the server.

  11. Don Gateley
    May 30, 2014 at 12:25 am

    How is Comcast likely to respond to this use of their service? Assuming first that they'll give you a static IP.

    • Christian C
      May 30, 2014 at 6:42 am

      As I'm in Britain, I couldn't comment on Comcast. However there are alternatives to straightforward static IPs:

  12. ????? ????
    May 29, 2014 at 10:22 pm

    Great post.This article is very helpful. keep sharing such information

  13. Melroy D
    May 29, 2014 at 3:39 am

    I cannot thank MUO enough for this. I've been breaking my head over it for weeks. This is just perfect. Kudos.

  14. Simen B
    May 28, 2014 at 7:58 pm

    Nice article! I've been running a little server on my Pi for a year now, and it works great!
    However, it requires a bit of patience. Ten seconds to load each page on WordPress is common, depending on the theme. My current setup, which is a theme using mostly the same logic as _S (same as I use on and two plugins, takes about five seconds to load frontend pages, and up to twenty on the backend.

    On the other hand, you could use a ultrasimple cms., like this one: [Broken Link Removed] . Simply unzip it somewhere on your computer, change the password in img.php and new.php, and replace the logo in menu.php. Please note that this was something I made while getting bored to death in IT class a few months ago, so I wouldn't consider it bulletproof.

    Finally, to anyone setting up a server for the first time: have fun, you'll learn a lot while doing this!

  15. Pijush G
    May 28, 2014 at 6:56 pm is now on right track. Very good article!