How to Set Up a Raspberry Pi Web Server (2024)

One of the most popular uses of the Raspberry Pi is as a web server that lives on your local network. Whether you need an Intranet for your office or a small server for doing web development, the Pi is a great choice. In fact, at Tom’s Hardware, we have a local Pi web server that we use to deliver the content for our laptop battery test, which involves continuous surfing over Wi-Fi.

To get your web server working, you’ll need a Raspberry Pi that’s connected to your local network and running a fairly-recent version of the Raspbian operating system. These instructions will work on just about any model, including the powerful Raspberry Pi 4 and diminutive Raspberry Pi Zero W. If you need to install Raspbian, see our tutorial on how to set up a Raspberry Pi or, better yet, how to do a headless install (no keyboard or screen required).

1.Navigate to the command prompt / terminal. You can get there by hitting CTRL+ALT+T from the Raspbian desktop or connecting remotely via SSH if you have that configured. Some users also configure the Raspberry Pi to boot directly to the command prompt.

2.Update your packages by typing

sudo apt-get update

This will make sure that you get the latest versions of every file you download after this.

3.Install apache2 with the command:

Stay On the Cutting Edge: Get the Tom's Hardware Newsletter

Get Tom's Hardware's best news and in-depth reviews, straight to your inbox.

sudo apt-get install apache2 -y

4. Install php for your sever by typing:

sudo apt-get install php libapache2-mod-php -y

5. Install mariadb so you can use a mysql database with your website. You start by typing:

sudo apt-get install mariadb-server

Then, after the download is finished. You must do the formal install by typing:

sudo mysql_secure_installation

You will be asked for a root password. You can leave it blank.

6. Install the php-mysql connector so php pages can access the DB.

sudo apt install php-mysql

7. Restart apache2 so all of the changes are running.

sudo service apache2 restart

8. Test your server. On the Raspberry Pi itself, you should be able to go to http://localhost and see a test page. From another computer on the same network, you should be able to get there by visiting http://raspberrypi.local or http://raspberrypi, provided that your Raspberry Pi's hostname is raspberrypi.

How to Set Up a Raspberry Pi Web Server (1)

9. Build your website by putting html or PHP files in the /var/www/html directory.

Changing Your Server's Host Name

By default, your Raspberry Pi's host name is "raspberrypi." But that's not only a boring address for a website, but it's problematic if you have more than one Pi on your network. Fortunately, it's each to change the host name to something else.

1. Enter the Raspberry Pi Configuration tool by typing this in the terminal.

sudo raspi-config

Alternatively, you can launch the windowed version by navigating to Preferences->Raspberry Pi Configuration from the start menu, but why like doing it via the command line utility instead.

2. Select Network Options

How to Set Up a Raspberry Pi Web Server (2)


3. Select Hostname

How to Set Up a Raspberry Pi Web Server (3)

4. Tap Ok
to get past a warning about not using characters other than letters, numbers or a hyphen (but only if the hyphen is in the middle of the name).

5. Enter your hostname and hit Ok.

How to Set Up a Raspberry Pi Web Server (4)


6. Select Finish.

How to Set Up a Raspberry Pi Web Server (5)

7. Select Yes when prompted to reboot.

How to Set Up a Raspberry Pi Web Server (6)

After you reboot, your Raspberry Pi will have its new name.

How to Set Up FTP on Your Pi Web Server

You won't have much of a web server if you don't put some web pages and media files in the /var/www/html folder. And while you could do all of your web development on the Pi, most people will probably want to write the code on their primary PCs and then copy it over. And one of the best ways to do that is via FTP. Here's how.

1. Enable SSH on your Raspberry Pi if you haven't already. You can do that by navigating to the Interfacing Options->SSH menu from rasp-config. Or, if you're on the desktop, you can go to Preferences->Raspberry Pi Configuration and click on the interfaces tab.

How to Set Up a Raspberry Pi Web Server (7)

2. Change the permissions for the /var/www/ folder (and all folders under it) so you can write files to it. To do this, you must enter the following commands.

sudo chown pi /var/www/html

3. Use an FTP client on your PC and make sure to set it to use SFTP protocol, not just plain FTP. If you're using Windows, we recommend Filezilla, which is the leading free FTP app.

How to Set Up a Raspberry Pi Web Server (8)


The default username and password are "pi" and "raspberry" as they are for SSH.

How to Set Up a Raspberry Pi Web Server (2024)
Top Articles
How Many Bags Of Postcrete Do I Need Per Fence Post?
25,000 Chase Ultimate Rewards Points: Value in 2024
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Energy Healing Conference Utah
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Movies - EPIC Theatres
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Nfsd Web Portal
Selly Medaline
Latest Posts
Article information

Author: Kimberely Baumbach CPA

Last Updated:

Views: 6501

Rating: 4 / 5 (61 voted)

Reviews: 84% of readers found this page helpful

Author information

Name: Kimberely Baumbach CPA

Birthday: 1996-01-14

Address: 8381 Boyce Course, Imeldachester, ND 74681

Phone: +3571286597580

Job: Product Banking Analyst

Hobby: Cosplaying, Inline skating, Amateur radio, Baton twirling, Mountaineering, Flying, Archery

Introduction: My name is Kimberely Baumbach CPA, I am a gorgeous, bright, charming, encouraging, zealous, lively, good person who loves writing and wants to share my knowledge and understanding with you.