Raspberry Pi is not only a small board computer but a tinker card that can do almost anything and everything. Do you want to set up Pi-hole on Raspberry Pi to block ads and trackers from your entire home network? Yes, it does that. Do you want to set up a Raspberry Pi web server for web development and local file transfer? Well, it does that too. In fact, using a Raspberry Pi is a great and affordable way to build a personal web server. So if you are interested, follow this simple guide and turn your Raspberry Pi into a web server in no time.

To set up a Raspberry Pi web server, you first need to install a web server. There are two popular web servers: Apache and Nginx. But in this tutorial, we will use Apache because it’s reliable and easier to use. Apart from that, we will also install PHP so that you can host dynamic webpages on your Raspberry Pi. Now having said all of that, let’s jump to the steps.

  • Install Apache Web Server on Raspberry Pi

  • Install PHP on Raspberry Pi

  • Testing FileZilla on Raspberry Pi

  • Install Apache Web Server on Raspberry Pi

  1. First off, make sure you have flashed Raspberry Pi OS with desktop UI on the SD card. If you are new to all this, follow our guide on how to set up Raspberry Pi remotely. That said, if you have an external monitor, things will be much smoother.

Install Apache Web Server on Raspberry Pi

  1. Next, we need to install the Apache web server on Raspberry Pi. Run the below command in the Terminal.

  2. As you can see in the screenshot above, the index.html file is owned by root. So before modifying anything, you need to change the owner to pi (you). Run the below command to change the ownership.

As you can see in the screenshot below, pi is now the owner of the web server. You can also use the same format to change the ownership of folders such as html and www.

  1. Now, if I make any changes to the title and save it, then they will reflect on the web server right away. You will see the updated title when you open the web server in a browser window. This step confirms that your Raspberry Pi web server is working well.

Install PHP on Raspberry Pi

If you want to test your web pages on Raspberry Pi, installing just the webserver won’t cut it. You also need to install PHP to have a solution like XAMPP on Raspberry Pi. It will allow you to test dynamic web pages on your Raspberry Pi. Here is how to go about it.

  1. Next, move to the same var/www/html/ directory and create a PHP file using a text editor.

Testing FileZilla on Raspberry Pi

Once we have set up Apache web server and PHP on Raspberry Pi, it’s finally time to test if we can transfer our existing web assets to the RPi web server with the popular FTP client FileZilla. You can also use other FTP clients like WinSCP if you wish. Here are the steps to follow.

  1. Install FileZilla (Free) on another PC connected to the same Wi-Fi network.