How to Install WordPress on Raspberry Pi – Build Your LAMP Server
Today in this tutorial, I will show you how you can build a Raspberry Pi LAMP server. We will install WordPress on Raspberry Pi and then see how wonderfully it will turn into an HTTP server hosting device.
Topics covered in this guide:
- What is Raspberry Pi WordPress?
- What is the end product?
- Things you will need for the project
- Getting Raspberry Pi official OS
- Apache setup
- PHP installation
- My SQL installation
- WordPress download
- WordPress setup & Configuration
- Make WordPress live
Raspberry Pi WordPress
WordPress is the most popular and widely used CMS (Content Management System) in the world today. Ever since the first Raspberry Pi got an introduction in 2012, it has the compatibility with the WordPress platform. The performance was not as good as expected though. But, when the highly-featured and advanced Raspberry Pi models like Raspberry Pi 2 and Raspberry Pi 3 appeared in the market, the scenario changed. With the much powerful processor and RAM availability, it has become much easier and comfortable to host WordPress sites on the Pi devices.
What will we have at the end?
Here, you will setup the LAMP (Linux, Apache, My SQL, and PHP) server on Raspberry Pi. This setup will work as a Pi web server on which you will download, install, and use a WordPress website. You will also have permission to use this site from any device in your Pi network.
Things you will need:
- A Raspberry Pi board (Pi 3 recommended)
- Pi compatible micro SD card (32GB will be good)
- An Ethernet cable / USB WiFi adapter
- Raspberry Pi power supply
- Raspberry Pi Display
- Keyboard & Mouse
- Protective case (optional)
How to Install WordPress on Raspberry Pi (Create LAMP Server)
We will first install the Apache server on the Pi through the Linux environment and then will add PHP and My SQL to it for downloading and setting the WordPress database. So, let’s proceed to make Raspberry Pi LAMP server.
Step-1: Get Raspbian
The Raspbian is the official Raspberry Pi Operating System. If you buy a complete Raspberry Pi kit, then you will get a compatible SD card with preloaded NOOBS software on that and sometimes even the onboard Raspbian. The NOOBS will help you to install the Pi OS on your device easily. If you don’t have a Pi starter kit, then get the NOOBS tool and then the Raspbian OS from the official resources.
Step-2: Get Apache Web Server
If you look at the list of the best web server applications, then you will see the Apache at the top of all. We will install the Apache2 web server on the Pi board. For that;
- Open Raspberry Pi command terminal / Putty
- Enter the below command to install Apache2
sudo apt-get install apache2
The Apache2 web server will be downloaded on your system.
Step-3: Setup Apache2
As you know, Apache delivers HTML files over the HTTP in the web folder. You can have access to this file through the Pi or any other device on the network. After downloading the web server, we will test it and then will set the default web page.
- Open Google Chrome (Chromium) internet browser on your Pi
- Enter the URL ‘http://localhost,’ and if you see the default HTML file of Apache, that means the web server is working correctly
- To open this web page from other computers in the network, you will need to enter the IP address of your Pi like ‘http://192.168.0.1’
- Now, you will need to access the location and content of the default HTML file and then change its information according to the requirement.
- Open the command terminal and enter the location of the file
- When you enter the above command, you will see the list of the directory, the parent directory, and the file name as index.html. If you see the username as ‘root’ in that list, then you will need to change the permission with the below command:
sudo leafpad index.html
- Save the changes you have made to the html file and then refresh the web browser to check the changes
Step-4: Install & Test PHP
The PHP is a server-side scripting language which comes into the picture when we send the request to the server for opening a particular web page. When the web server receives such asking, the PHP works on the things that are needed to open the specific location. PHP is the common and famous preprocessor language used worldwide. To install PHP on Raspberry Pi:
1. Open the command terminal and enter the below code
sudo apt-get install php
2. Now, create the index file by entering the command below
sudo leafpad index.php
3. Enter anything you want in that file for testing and then save it
4. As we have created a default PHP file, it’s the time to remove the default HTML file of the Apache web server
sudo rm index.html
5. After doing that, refresh the web browser on Pi, and you should see the contents of the PHP file you have created
Note: if you read ‘raw PHP’ before the file content, restart the Apache server. You can also show the dynamic information like the date & time or phpinfo.
Step-5: Install My SQL Database
Now, this is the time to setup the database for the WordPress website on Raspberry Pi. We will download and install My SQL engine here.
1. Open the command terminal / Putty or if you had not closed the previous terminal window, then enter the code like below
sudo apt-get install
2. Again, restart the Apache web server by entering the following line:
sudo service apache2 restart
Step-6: Get WordPress
Now, the core of the project comes in the picture. We will download and install WordPress from the official website. But before that, we need to delete the files from the directory.
- In the Raspberry Pi terminal, enter the command below
sudo rm *
- Now, get the WordPress from the wordpress.org site, extract the files. After that check the contents of the file and then copy it to the current Apache directory. Enter the code lines as
sudo wget http://wordpress.org/latest.tar.gz
sudo tar xzvf latest.tar.gz
sudo cp –r * /var/www/wordpress
Step-7: WordPress Database Setup & Configuration
After doing all the WordPress installation and authentication, we will create WordPress database and then set it for the use. But before, we will set the My SQL.
- Enter the command below to open My SQL
- Enter the current password, and then set the root password as per the indications on the screen
- After that, you will be asked for several things like removing an anonymous user, deleting the test database, and a few others. Enter Y / N according to your preferences until you see a message showing “All Done!”
Now, we will move on to create WP database.
- Enter the command below to run My SQL
sudo mysql –uroot –p
- You will need to enter the root password that you have set before. To install WordPress, we will create a DB
create database wordpress;
- After the successful command, you will need to provide the permission to the root user (remember to enter your password at the end), and then you can flush the database
GRANT ALL PRIVILEGES ON wordpress.* TO ‘root’@’localhost’ IDENTIFIED BY ‘[email protected]’;
- Exit from the command prompt
So, we have set the WordPress database, and it is now the time for the configurations.
- Open the Raspberry Pi web browser and go to localhost (http://localhost)
- Here, you will see the admin page for configuring the WordPress. Choose your language and click on “Continue” button
- In the welcome screen, read the info and then click on the button showing “Let’s go!”
- Enter all the information as asked on the screen and then click on “Submit” and then “Run the install” button
- Enter the ‘site title’ and ‘username’
- Click on “Install WordPress” button and enter the user credentials
You have entered in the website admin page and now you can setup your site preferences from there. From any other computer in the network, you just need to visit http://localhost/wp-admin or http://YOUR-PI-IP-ADDRESS/wp-admin and then enter the credentials to access the website admin page.
Here, change the permalinks to make your URL more user-friendly by overriding Apache configuration file. Customize the themes, load plugins and make other changes that you need in your site. If you reach at this stage, then you can do many more things with your Raspberry Pi web server now.
Make WordPress Live
Now, it is the time to add content, images, videos, etc. in your site and make them live! Add your favorite theme and useful plugins to get most out of your WordPress site powered by the Raspberry Pi board.
I hope this guide helps you to install WordPress on Raspberry Pi computer easily. You can add as many WP sites as you want as per the available memory and server capacity.
Let me know if I missed anything here. Give your opinion on the guide. Express your thoughts in the comments.
Thanks for being a part of Raspberry Pi community!