How to set up a personal web server with a Raspberry Pi (2024)

A personal web server is "the cloud,"exceptyou own and control it as opposed to a large corporation.

Owning a little cloud has a lot of benefits, including customization, free storage, free Internet services, a path into open source software, high-quality security, full control over your content, the ability to make quick changes, a place to experiment with code, and much more. Most of these benefits are immeasurable, but financially these benefits can save you over $100 per month.

How to set up a personal web server with a Raspberry Pi (1)

Image by:

Raspberry Pi as a web server, by Raspberry Pi Guy, CC-BY-SA 4.0

I could have used AWS, but I prefer complete freedom, full control over security, and learning how things are built.

  • Self web-hosting: No BlueHost or DreamHost
  • Cloud storage: No Dropbox, Box, Google Drive, Microsoft Azure, iCloud, or AWS
  • On-premise security
  • HTTPS: Let’s Encrypt
  • Analytics: Google
  • OpenVPN: Do not need private Internet access (at an estimated $7 per month)

Things I used:

  • Raspberry Pi 3 Model B
  • MicroSD Card (32GB recommended, Raspberry Pi Compatible SD Cards)
  • USB microSD card reader
  • Ethernet cable
  • Router connected to Wi-Fi
  • Raspberry Pi case
  • Amazon Basics MicroUSB cable
  • Apple wall charger
  • USB mouse
  • USB keyboard
  • HDMI cable
  • Monitor (with HDMI input)
  • MacBook Pro

More on Raspberry Pi

Step 1: Setting up the Raspberry Pi

Download the most recent release of Raspbian (the Raspberry Pi operating system). Raspbian Jessie ZIP version is ideal [1]. Unzip or extract the downloaded file. Copy it onto the SD card. Pi Filler makes this process easy. Download Pi Filer 1.3 or the most recent version. Unzip or extract the downloaded file and open it. You should be greeted with this prompt:

How to set up a personal web server with a Raspberry Pi (2)

Make sure the USB card reader has NOT been inserted yet. If it has, eject it. Proceed by clicking Continue. A file explorer should appear. Locate the uncompressed Raspberry Pi OS file from your Mac or PC and select it. You should see another prompt like the one pictured below:

How to set up a personal web server with a Raspberry Pi (3)

Insert the MicroSD card (32GB recommended, 16GB minimum) into the USB MicroSD Card Reader. Then insert the USB reader into the Mac or PC. You can rename the SD card to "Raspberry" to distinguish it from others. Click Continue. Make sure the SD card is empty. Pi Filler will eraseall previous storage at runtime. If you need to back up the card, do so now. When you are ready to continue, the Raspbian OS will be written to the SD card. It should take between one to three minutes. Once the write is completed, eject the USB reader, remove the SD card, and insert it into the Raspberry Pi SD card slot. Give the Raspberry Pi power by plugging the power cord into the wall. It should start booting up. The Raspberry Pi default login is:

username: pi

password: raspberry

When the Raspberry Pi has completed booting for the first time, a configuration screen titled "Setup Options" should appear like the image below [2]:

How to set up a personal web server with a Raspberry Pi (4)

Select the "Expand Filesystem" option and hit the Enter key [3]. Also, I recommend selecting the second option, "Change User Password." It is important for security. It also personalizes your Raspberry Pi.

(Note: For an extra layer of security install fail2ban. Fail2Ban blocks suspicious requests coming from the internet. For example, if there are too many attempts to guess the password, it will block that IP address. It can be installed by typing into terminal: $ sudo apt-get install fail2ban)

Select the third option in the setup options list, "Enable Boot To Desktop/Scratch" and hit the Enter key. It will take you to another window titled "Choose boot option" as shown in the image below.

How to set up a personal web server with a Raspberry Pi (5)

In the "Choose boot option" window, select the second option, "Desktop log in as user 'pi' at the graphical desktop" and hit the Enter button [4]. Once this is done you will be taken back to the "Setup Options" page. If not, select the "OK" button at the bottom of this window and you will be taken back to the previous window.

Once both these steps are done, select the "Finish" button at the bottom of the page and it should reboot automatically. If it does not, then use the following command in the terminal to reboot.

$ sudo reboot

After the reboot from the previous step, if everything went well, you will end up on the desktop similar to the image below.

How to set up a personal web server with a Raspberry Pi (6)

Once you are on the desktop, open a terminal and enter the following commands to update the firmware of the Raspberry Pi.

$ sudo apt-get update$ sudo apt-get upgrade -y$ sudo apt-get dist-upgrade -y$ sudo rpi-update

This may take a few minutes. Now the Raspberry Pi is up-to-date and running.

Step 2: Configuring the Raspberry Pi

SSH, which stands for Secure Shell, is a cryptographic network protocol that lets you securely transfer data between your computer and your Raspberry Pi. You can control your Raspberry Pi from your Mac's command line without a monitor or keyboard.

To use SSH, first, you need your Pi's IP address. Open the terminal and type:

$ sudo ifconfig

If you are using Ethernet, look at the "eth0" section. If you are using Wi-Fi, look at the "wlan0" section.

Find "inet addr" followed by an IP address—something like 192.168.1.115, a common default IP I will use for the duration of this article.

With this address, open terminal and type:

$ ssh pi@192.168.1.115

For SSH on PC, see footnote [5].

Enter the default password "raspberry" when prompted, unless you changed it.

You are now logged in via SSH.

Remote desktop

Using a GUI (graphical user interface) is sometimes easier than a command line. On the Raspberry Pi's command line (using SSH) type:

$ sudo apt-get install xrdp

Xrdp supports the Microsoft Remote Desktop Client for Mac and PC.

On Mac, navigate to the app store and search for "Microsoft Remote Desktop." Download it. (For a PC, see footnote [6].)

After installation, search your Mac for a program called "Microsoft Remote Desktop."Open it. You should see this:

How to set up a personal web server with a Raspberry Pi (7)

Image by:

Image by Raspberry Pi Guy, CC BY-SA 4.0

Click "New" to set up a remote connection. Fill in the blanks as shown below.

Save it by exiting out of the "New" window.

You should now see the remote connection listed under "My Desktops."Double click it.

After briefly loading, you should see your Raspberry Pi desktop in a window on your screen, which looks like this:

How to set up a personal web server with a Raspberry Pi (9)

Perfect. Now, you don't need a separate mouse, keyboard, or monitor to control the Pi. This is a much more lightweightsetup.

Static local IP address

Sometimes the local IP address 192.168.1.115 will change. We need to make it static. Type:

$ sudo ifconfig

Write down from the "eth0" section or the "wlan0" section, the "inet addr" (Pi's current IP), the "bcast" (the broadcast IP range), and the "mask" (subnet mask address). Then, type:

$ netstat -nr

Write down the "destination" and the "gateway/network."

How to set up a personal web server with a Raspberry Pi (10)

The cumulative records should look something like this:

net address 192.168.1.115bcast 192.168.1.255mask 255.255.255.0gateway 192.168.1.1network 192.168.1.1destination 192.168.1.0

With this information, you can set a static internal IP easily. Type:

$ sudo nano /etc/dhcpcd.conf

Do not use /etc/network/interfaces.

Then all you need to do is append this to the bottom of the file, substituting the correct IP address you want.

interface eth0static ip_address=192.168.1.115static routers=192.168.1.1static domain_name_servers=192.168.1.1

Once you have set the static internal IP address, reboot the Raspberry Pi with:

$ sudo reboot

After rebooting, from terminal type:

$ sudo ifconfig

Your new static settings should appear for your Raspberry Pi.

Static global IP address

If your ISP (internet service provider) has already given you a static external IP address, you can skip ahead to the port forwarding section. If not, continue reading.

You have set up SSH, a remote desktop, and a static internal IP address, so now computers inside the local network will know where to find the Pi. But you still can't access your Raspberry Pi from outside the local Wi-Fi network. You need your Raspberry Pi to be accessible publicly from anywhere on the Internet. This requires a static external IP address [7].

It can be a sensitive process initially. Call your ISP and request a static external (sometimes referred to as static global) IP address. The ISP holds the decision-making power, so I would be extremely careful dealing with them. They may refuse your static external IP address request. If they do, you can't fault the ISP because there is a legal and operational risk with this type of request. They particularly do not want customers running medium- orlarge-scale Internet services. They might explicitly ask why you need a static external IP address. It is probably best to be honest and tell them you plan on hosting a low-traffic personal website or a similar small not-for-profit internet service. If all goes well, they should open a ticket and call you in a week or two with an address.

Port forwarding

This newly obtained static global IP address your ISP assigned is for accessing the router. The Raspberry Pi is still unreachable. You need to set up port forwarding to access the Raspberry Pi specifically.

Ports are virtual pathways where information travels on the Internet. You sometimes need to forward a port in order to make a computer, like the Raspberry Pi, accessible to the Internet because it is behind a network router. A YouTube video titled What is TCP/IP, port, routing, intranet, firewall, Internet by VollmilchTV helped me visually understand ports.

Port forwarding can be used for projects like a Raspberry Pi web server, or applications like VoIP or peer-to-peer downloading. There are 65,000+ ports to choose from, so you can assign a different port for every Internet application you build.

The way to set up port forwarding can depend on your router. If you have a Linksys, a YouTube video titled How to go online with your Apache Ubuntu server by Gabriel Ramirez explains how to set it up. If you don't have a Linksys, read the documentation that comes with your router in order to customize and define ports to forward.

You will need to port forward for SSH as well as the remote desktop.

Once you believe you have port forwarding configured, check to see if it is working via SSH by typing:

$ ssh pi@your_global_ip_address

It should prompt you for the password.

Check to see if port forwarding is working for the remote desktop as well. Open Microsoft Remote Desktop. Your previous remote connection settings should be saved, but you need to update the "PC name" field with the static external IP address (for example, 195.198.227.116) instead of the static internal address (for example, 192.168.1.115).

Now, try connecting via remote desktop. It should briefly load and arrive at the Pi's desktop.

How to set up a personal web server with a Raspberry Pi (11)

Good job. The Raspberry Pi is now accessible from the Internet and ready for advanced projects.

As a bonus option, you can maintain two remote connections to your Pi. One via the Internet and the other via the LAN (local area network). It's easy to set up. In Microsoft Remote Desktop, keep one remote connection called "Pi Internet" and another called "Pi Local." Configure Pi Internet's "PC name" to the static external IP address—for example, 195.198.227.116. Configure Pi Local's"PC name" to the static internal IP address—for example, 192.168.1.115. Now, you have the option to connect globally or locally.

If you have not seen it already, watchHow to go online with your Apache Ubuntu server by Gabriel Ramirez as a transition into Project 2. It will show you the technical architecture behind your project. In ourcase, you are using a Raspberry Pi instead of an Ubuntu server. The dynamic DNS sits between the domain company and your router, which Ramirez omits. Beside this subtlety, the video is spot on when explaining visually how the system works. You might notice this tutorial coversthe Raspberry Pi setup and port forwarding, which is the server-side or back end. See the original source for more advanced projectscoveringthe domain name, dynamic DNS, Jekyll (static HTML generator), and Apache (web hosting), which is the client-side or front end.

Footnotes

[1] I do not recommend starting with the NOOBS operating system. I prefer starting with the fully functional Raspbian Jessie operating system.

[2] If "Setup Options" does not pop up, you can always find it by opening Terminal and executing this command:

$ sudo-raspi-config

[3] We do this to make use of all the space present on the SD card as a full partition. All this does is expand the operating system to fit the entirespace on the SD card, which can then be used as storage memory for the Raspberry Pi.

[4] We do this because we want to boot into a familiardesktop environment. If we do not do this step, the Raspberry Pi boots into a terminal each time with no GUI.

[5]

How to set up a personal web server with a Raspberry Pi (12)

Download and run PuTTY or another SSH client for Windows. Enter your IP address in the field, as shown in the above screenshot. Keep the default port at 22. Hit Enter, and PuTTY will open a terminal window, which will prompt you for your username and password. Fill those in, and begin working remotely on your Pi.

[6] If it is not already installed, download Microsoft Remote Desktop. Search your computer for Microsoft Remote Desktop. Run it. Input the IP address when prompted. Next, an xrdp window will pop up, prompting you for your username and password.

[7] The router has a dynamically assigned external IP address, so in theory, it can be reached from the Internet momentarily, but you'llneed the help of your ISP to make it permanently accessible. If this wasnot the case, you wouldneed to reconfigure the remote connectionon each use.

For the original source, visit Mitchell McLaughlin's Full-Stack Computer Projects.

22 Comments

These comments are closed.

How to set up a personal web server with a Raspberry Pi (2024)

FAQs

How to set up a personal web server with a Raspberry Pi? ›

Raspberry Pis are perfect for testing your web pages, hosting a media server, or a Minecraft server for you and your friends. You should keep in mind that the efficiency of your code also affects site performance, so keep this in mind when developing your website.

How to set up your Raspberry Pi as a web server? ›

How to Set Up a Raspberry Pi Web Server
  1. Navigate to the command prompt / terminal. ...
  2. Update your packages by typing.
  3. Install apache2 with the command:
  4. Install php for your sever by typing:
  5. Install mariadb so you can use a mysql database with your website. ...
  6. Install the php-mysql connector so php pages can access the DB.
Sep 16, 2022

Is A Raspberry Pi good enough for a web server? ›

Raspberry Pis are perfect for testing your web pages, hosting a media server, or a Minecraft server for you and your friends. You should keep in mind that the efficiency of your code also affects site performance, so keep this in mind when developing your website.

How do I setup a personal web server? ›

How To Setup Your Own Server For Web Hosting
  1. Quick Summary.
  2. Make Sure Your Connection Is Suitable For Web Hosting.
  3. Choose Your Hardware.
  4. Choose Your Operating System (OS) And Install It. Linux. ...
  5. Set Up And Configure Your Server At Home.
  6. Set Up Virtual Network Computing (VNC)
  7. Install File Transfer Protocol (FTP)
  8. Install HTTP.

Can I host my own website on a Raspberry Pi? ›

Host Your Website on Raspberry Pi
  1. Step 1: Connect Via SSH. Now connect your raspberry pi to home router using a Ethernet cable. ...
  2. Step 2: Setting Up You Rasberry Pi. ...
  3. Step 3: Installing Your Server. ...
  4. Step 4: Setup Up PORT Triggers. ...
  5. Step 5: Have Your Domain Name. ...
  6. Step 6: Visit You Website.

How to make home server with Raspberry Pi? ›

Turning Your Raspberry Pi Into a Personal Web Server
  1. Step 1: Materials. - Raspberry Pi. ...
  2. Step 2: Preparation. ...
  3. Step 3: Initial Configuration. ...
  4. Step 4: SSH Set Up. ...
  5. Step 5: Installing Apache. ...
  6. Step 6: Install MySQL. ...
  7. Step 7: Install FTP. ...
  8. Step 8: Finalization.

How much does a Raspberry Pi web server cost? ›

List of Raspberry Pi in Bangladesh
Product NamePrice BDTClick to Buy
Raspberry Pi 3 Model B10990Buy Now
Raspberry Pi 3 Model B+11990Buy Now
Raspberry Pi 4 Model B 2GB18990Buy Now
Raspberry Pi 4 Model B 4GB22990Buy Now
1 more row

Which Raspberry Pi to buy for web server? ›

The model with the highest potential specification is the Raspberry Pi 4, so for many general purpose projects this is your best bet. It's the most powerful Pi, with a fast clock speed, the most RAM available on a Pi yet, Wi-Fi and Bluetooth, and the ability to run two screens at 4k resolution.

Is a Raspberry Pi good for a home server? ›

Yes, you can use various Raspberry Pi models for a home server. However, it's recommended to choose a model with sufficient processing power and RAM to handle the server applications you intend to run.

What is the cheapest Raspberry Pi for web server? ›

Raspberry Pi Models

RPi Zero is the cheapest, lightest, and smallest Raspberry Pi available. The zero board doesn't include a USB and Ethernet port and has less computing power than the other models. It does, however, use less energy.

Can I host my website myself? ›

If you don't want to hire a company to host your website for you, you can do it yourself if you have the time. You won't need a lot to be able to host your own website, and it's relatively simple if you're tech-savvy.

Can I build my own server for my website? ›

Yes, you can. But before you do so, there are limitations you need to take into consideration: You should know how to setup a WWW server software on your computer. This is a software that allows Internet users to access the web files on your computer.

Can I host my own website for free? ›

There are free website hosting services available, but all free plans have limitations. Customer support, storage, bandwidth and perks, such as free domain names, are usually lacking in free plans. Free web hosting can work for personal websites and blogs, developer testing, side gigs and startup sites.

Why use Raspberry Pi as a web server? ›

One benefit of using a Raspberry Pi as a low-volume server is that the low power requirements.

How to secure a Raspberry Pi web server? ›

Restrict Access to Raspberry Pi Web Server
  1. Step 1: Gather Parts. ...
  2. Step 3: ​Enable SSL and Generate Certificate (use HTTPS) ...
  3. Step 4: Creating Server/client Certificate Pair Using OpenSSL. ...
  4. Step 5: Add Client-side Certificate to Devices. ...
  5. Step 6: ​Disable HTTP in Apache. ...
  6. Step 7: Disable HTTP on U-verse Gateway.

Is pi tunnel free? ›

Sign up to get started with your free account.

Can I run web browser on Raspberry Pi? ›

"can web browser software be loaded onto the Pi and then used as a web browser?" Yes. But it is even easier than that. If you install the full (desktop and software) version of the recommended Raspbian Buster Operating System then the Chromium web browser is already installed and ready to use.

How to make a Raspberry Pi Python web server? ›

How to make your own Python dev-server with Raspberry Pi
  1. Define the goal. Before we begin, it is important to understand what is it that we are trying to build. ...
  2. State the assumptions. ...
  3. Find the Pi's IP address. ...
  4. Connect to the Pi using ssh. ...
  5. Create a project directory. ...
  6. Install Flask. ...
  7. Write some basic code. ...
  8. Add more routes.
Sep 15, 2018

How do I turn my Raspberry Pi into a media server? ›

Raspberry Pi and Plex: how to turn a single-board computer into a media server
  1. Step 1: update Raspbian to the latest version.
  2. Step 2: enable HTTPS transfer during downloads.
  3. Step 3: add the dev2day repository as a package source.
  4. Step 4: install the Plex Media Server.
  5. Step 5: change server users.
Jan 31, 2023

What is the best web server for Raspberry Pi Zero? ›

Re: Best web server OS for RPi Zero W

I'd go for Apache or Nginx. They may be a little heavy for a simple home server, but there are lots of examples of how to use them and the basic set up is simple. A Pi Zero should be able to handle the load.

Top Articles
Food items to fight body odour in summer - Times of India
Series B funding: guide for startup founders | SeedLegals
9.4: Resonance Lewis Structures
neither of the twins was arrested,传说中的800句记7000词
Swimgs Yuzzle Wuzzle Yups Wits Sadie Plant Tune 3 Tabs Winnie The Pooh Halloween Bob The Builder Christmas Autumns Cow Dog Pig Tim Cook’s Birthday Buff Work It Out Wombats Pineview Playtime Chronicles Day Of The Dead The Alpha Baa Baa Twinkle
Froedtert Billing Phone Number
Winston Salem Nc Craigslist
Costco in Hawthorne (14501 Hindry Ave)
What Happened To Father Anthony Mary Ewtn
Sarpian Cat
Worcester On Craigslist
سریال رویای شیرین جوانی قسمت 338
Mills and Main Street Tour
6813472639
Nhl Wikia
Water Days For Modesto Ca
Account Suspended
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Titanic Soap2Day
Busted News Bowie County
Ford F-350 Models Trim Levels and Packages
Sef2 Lewis Structure
What Is The Lineup For Nascar Race Today
Teekay Vop
Walgreens Bunce Rd
Workshops - Canadian Dam Association (CDA-ACB)
Snohomish Hairmasters
As families searched, a Texas medical school cut up their loved ones
27 Fantastic Things to do in Lynchburg, Virginia - Happy To Be Virginia
Stickley Furniture
101 Lewman Way Jeffersonville In
Salemhex ticket show3
Nurtsug
Nextdoor Myvidster
Flaky Fish Meat Rdr2
Nicole Wallace Mother Of Pearl Necklace
1987 Monte Carlo Ss For Sale Craigslist
Glossytightsglamour
Http://N14.Ultipro.com
Obsidian Guard's Skullsplitter
Myql Loan Login
8 Ball Pool Unblocked Cool Math Games
Subdomain Finder
Neil Young - Sugar Mountain (2008) - MusicMeter.nl
Crigslist Tucson
Boyfriends Extra Chapter 6
Stoughton Commuter Rail Schedule
Dolce Luna Italian Restaurant & Pizzeria
Goosetown Communications Guilford Ct
7 Sites to Identify the Owner of a Phone Number
Latest Posts
Article information

Author: Pres. Carey Rath

Last Updated:

Views: 6269

Rating: 4 / 5 (61 voted)

Reviews: 92% of readers found this page helpful

Author information

Name: Pres. Carey Rath

Birthday: 1997-03-06

Address: 14955 Ledner Trail, East Rodrickfort, NE 85127-8369

Phone: +18682428114917

Job: National Technology Representative

Hobby: Sand art, Drama, Web surfing, Cycling, Brazilian jiu-jitsu, Leather crafting, Creative writing

Introduction: My name is Pres. Carey Rath, I am a faithful, funny, vast, joyous, lively, brave, glamorous person who loves writing and wants to share my knowledge and understanding with you.