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
What Happens If You Fly A Drone Above 400 Feet? - Pilot Institute
Crypto vs. Cash: Is Crypto Real Money?
Maxtrack Live
Dannys U Pull - Self-Service Automotive Recycling
Using GPT for translation: How to get the best outcomes
EY – все про компанію - Happy Monday
Cumberland Maryland Craigslist
Is Csl Plasma Open On 4Th Of July
Notary Ups Hours
Optum Medicare Support
Overzicht reviews voor 2Cheap.nl
270 West Michigan residents receive expert driver’s license restoration advice at last major Road to Restoration Clinic of the year
Hardly Antonyms
Bernie Platt, former Cherry Hill mayor and funeral home magnate, has died at 90
Ladyva Is She Married
The Connecticut Daily Lottery Hub
Echo & the Bunnymen - Lips Like Sugar Lyrics
Samsung Galaxy S24 Ultra Negru dual-sim, 256 GB, 12 GB RAM - Telefon mobil la pret avantajos - Abonament - In rate | Digi Romania S.A.
Most McDonald's by Country 2024
Interactive Maps: States where guns are sold online most
Munich residents spend the most online for food
Gdlauncher Downloading Game Files Loop
Craigslist Free Stuff Merced Ca
Concordia Apartment 34 Tarkov
Hctc Speed Test
Gillette Craigslist
Lilpeachbutt69 Stephanie Chavez
Sacramento Craigslist Cars And Trucks - By Owner
Marlene2295
Nurofen 400mg Tabletten (24 stuks) | De Online Drogist
Davita Salary
Haunted Mansion Showtimes Near Cinemark Tinseltown Usa And Imax
Rust Belt Revival Auctions
Haley Gifts :: Stardew Valley
2012 Street Glide Blue Book Value
Skip The Games Ventura
Samsung 9C8
Chuze Fitness La Verne Reviews
Spectrum Outage in Genoa City, Wisconsin
Vocabulary Workshop Level B Unit 13 Choosing The Right Word
Newsweek Wordle
Discover Things To Do In Lubbock
Pain Out Maxx Kratom
Europa Universalis 4: Army Composition Guide
Arch Aplin Iii Felony
Ihop Deliver
Guy Ritchie's The Covenant Showtimes Near Look Cinemas Redlands
French Linen krijtverf van Annie Sloan
Ingersoll Greenwood Funeral Home Obituaries
683 Job Calls
Used Curio Cabinets For Sale Near Me
Duffield Regional Jail Mugshots 2023
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.