In this guide, I show you how to install LAMP stack on Raspberry Pi 3 or Raspberry Pi 0.  We do this for the purpose of creating a web server with WordPress-hosting capabilities!

Difficulty Level:  Beginner to Intermediate

Time to Complete:  45 mins to 1 hour

What you need:  Raspberry Pi 3 or Raspberry Pi 0 ($37 on Amazon) with Internet access




Your location is: Ashburn VA

Your current IP address is: 2001:4455:2f7:b700:f880:7bad:b46b:1768

You can stream and download anonymously through your PC, Mac, Android, and iPhone through IP Vanish.

Get 3-Months Free, 30-Day Money Back Guarantee

Get max air flow with an open case to cool Raspberry Pi 3 Overheating

Get a Raspberry Pi 3 to and install LAMP stack on it so you can use RPi as a WordPress server!

Google trackers are lurking on 75% of websites. Cover your tracks to protect yourself.

What is a LAMP Stack?

Since a LAMP stack is essentially just the components of a powerful web server, we can host a WordPress site (or any other website) right from our Raspberry Pi.

Cool, huh?

I think so – especially because it means I can use a Raspberry Pi as a dedicated WordPress site development area (or “WordPress sandbox“).

What is This “Sandbox Web Server” Business All About Anyway?

In this tutorial, I use the free “Raspbian with PIXEL” operating system to quickly and easily set up a robust (WordPress-capable!) web server.  This means you can create a WordPress site and host it right on your Raspberry Pi.

Can I Use This to Host a LIVE Website That’s Open to the World?

Hosting the site on your Raspberry Pi for the world isn’t very realistic.  It’s definitely possible – just not very practical for most people.

But what is realistic is the fact that you can use the LAMP stack on Raspberry Pi as a WordPress “sandbox”.

What is a WordPress Sandbox?

Basically a WordPress sandbox is a “dummy” WordPress site in which you can tinker and play around with WordPress, or use as what web designers call a “development site”, or “dev site”.

Notice: Hackers create fake WiFi hotspots to steal your passwords when you log in to public WiFi. Secure your data.

Or if you’re serious (like me), you can build an entire WordPress site on your Raspberry Pi – then export it using a free WordPress “Clone” Plugin to easily “migrate” the WordPress site to a live, public web host.

How to Install LAMP Stack on Raspberry Pi (Raspbian)

  1. Install Raspbian using NOOBS and boot up the Raspberry Pi 3 into Raspbian.
  2. Open a Terminal window (Press Ctrl+Alt+T on your USB keyboard)
  3. Enter “sudo apt-get update -y“.  Then wait until it’s done.  This step fetches the list of software updates available for Raspbian on Raspberry Pi 3.
  4. Now enter “sudo apt-get upgrade -y“.  Wait until it’s all done.  In this step, Raspbian actually upgrades all the programs on your Raspbian operating system.  This process takes my Raspberry Pi 3 around 30 minutes, so you need to be patient and let it finish.
  5. Then, we install Apache by entering this command: “sudo apt-get install apache2 -y“.  Wait for Apache web server Raspberry Pi edition to install.
  6. When Apache is done installing, launch the web browser on your Raspberry Pi.  Installing Apache in Raspbian took my RPi 3 about three minutes.
  7. Then enter http://localhost/ into the web browser’s address bar.  This should display a page called “Apache2 Debian Default Page”.

    Apache web server Raspberry Pi install

    Apache web server Raspberry Pi successfully installed

  8. Now go back to the Terminal window (or re-open it using Ctrl+Alt+T).
  9. From the Terminal, install PHP on Raspberry Pi quickly by entering “sudo apt-get install php5 libapache2-mod-php5 -y” into the Terminal window.  Wait for PHP to install – it took my RPi 3 about two minutes.
  10. Now in the Terminal, enter “cd /var/www/html“.  This command takes us into the folder where our website lives.  Any files you put in this folder will be “public” and served by your web server.
  11. Then in the Terminal, enter “sudo idle index.php“.  This opens the “IDLE” GUI-based text editor app and creates a file which we use (“index.php”) in the next step to test the PHP installation we just installed.
  12. After IDLE launches, enter this:  “<?php echo ‘hello world’; ?>“.  Then Save the File and Close the IDLE text editor.  You should now be back at the Terminal.
  13. In the Terminal, finally enter “sudo rm index.html” to make sure the PHP test file you created shows up, instead of the default (HTML) file.
  14. Now launch your browser and enter http://localhost/ into the address bar.  You should see “hello world”!  If you do, this means PHP is installed properly, you’re doing great, and you’re almost done installing LAMP stack on Raspberry Pi!
  15. Go back to the Terminal.  It’s time to install MySQL.  Enter “sudo apt-get install mysql-server php5-mysql -y” to install MySQL on Raspberry Pi.  As MySQL installs, it will bring up a (blue) screen that asks for a “root” password.  Enter a password that you’re sure you can remember and hit Enter.  Or just use the default Raspberry Pi password, which is “raspberry” (as long as you don’t plan to make this a public-facing web server).  The MySQL installer will then ask you to re-enter your newly-chosen MySQL password.  Then MySQL will continue installing.  It took about 5 minutes after asking for my root password to finish the installation.
  16. After MySQL is installed, restart Apache web server by entering “sudo service apache2 restart” into the Terminal.  You’re done with the install LAMP stack on Raspberry Pi process!  Keep reading to install WordPress on your new LAMP stack web server.

After you follow the steps above to install LAMP stack on Raspberry Pi, use the steps below to install WordPress on your new, full-fledged, mighty little Raspberry Pi web server!

How to Install WordPress after you install LAMP Stack on Raspberry Pi

  1. From the Terminal, enter “cd /var/www/html/“.  Then enter “sudo rm *“.  These two commands take us into the “public-facing” folder in our webserver and deletes all files in that location.
  2. Now enter “sudo wget“.  This command downloads WordPress!
  3. In the Terminal, enter this command to extract the WordPress “zip” file you just downloaded: “sudo tar xzf latest.tar.gz”
  4. Then enter this command to move the extracted folder into the right place: “sudo mv wordpress/* .
  5. Finally, enter “sudo rm -rf wordpress latest.tar.gz” to remove the zip file (now that we’re done with it).
  6. To test the WordPress installation, launch your browser and enter “http://localhost” in the address bar.  You should now see the “Welcome to WordPress” screen.
  7. Now enter the two commands “sudo chown -R www-data:www-data /var/www/html/” and “sudo chmod -R 755 /var/www/html/” to give WordPress proper access to the files it needs.  Without this step, you won’t be able to install WordPress Plugins!
  8. Then, from the Terminal enter “mysql -u root -p“.  Then enter your password.  The default password for Raspbian is “raspberry”.
  9. Now that you’re in the “MySQL shell”, enter “CREATE DATABASE wp_myblog;“.  Then enter “GRANT ALL PRIVILEGES ON wp_myblog.* TO ‘myusername‘@’localhost’ IDENTIFIED BY ‘mypassword‘;“.  Finally, enter “FLUSH PRIVILEGES;” and then “EXIT;”.
  10. Now that you’re back at the Terminal, enter “sudo mv wp-config-sample.php wp-config.php“.
  11. Then enter “sudo idle wp-config.php“.  This opens the Text Editor.
  12. Using the text editor, change the “password_here”, “username_here”, and “database_name_here” fields to “mypassword“, “myusername“, and “wp_myblog” (respectively).  Then Save the File and exit the IDLE text editor.
  13. Now launch your web browser and enter “http://localhost/” into the browser address bar.
  14. The Wordrpess website setup screen appears!  Enter a site title, enter a username and a password and email address, and click Install WordPress.
  15. After WordPress finishes installing, you will see the word “Success!” on your screen.  Then click “Log In” to log in to your new WordPress site!
  16. Finally, enter the username and password you chose at the WordPress setup screen and click “Log In” to reach the WordPress dashboard.

Apache Web Server Raspberry Pi Notes

  • The LAMP stack runs 67% of the entire world’s web servers.  So, LAMP is the most popular web server platform in the world.  Why?  It has a combination of performance and scalability that is matched by no other webserver platform.
  • There is a big difference between and
    • is a site that severely restricts your capabilities as a WordPress administrator.  In exchange, they host your WordPress site for you on their servers (so you don’t have to buy your own web hosting account).
    • On the other hand, a website is a website that uses the Content Management System.  This system is way better than the Content Management System (or “CMS”).  Why?  Because does not limit your WordPress administrator capabilities at all.  You can do anything: install plugins, install WordPress themes, etc.
  • Use this command to Restart Apache Web server on Raspberry Pi: “sudo service apache2 restart”
  • To see info about the PHP version you have installed, put this into the “index.php” file we created in the steps at the top of this page: “<?php phpinfo(); ?>
  • For a full install LAMP on Ubuntu 16.04 guide, check out this awesome tutorial.
  • Adafruit has a great tutorial on how to autostart Raspbian VNC server on Raspberry Pi boot-up, so you can remote control your Pi from just about any other device with a VNC viewer!