If you want the easiest and most user-friendly WordPress experience, a managed host like WP Engine that does all the setup and maintenance so you can focus on your content. This is what we use to run our own sister sites.

But if you don’t have the funds or just want to improve your DIY skills, then you can use a Raspberry Pi for your WordPress site.

Below is how to set up Apache, MySQL and PHP on Raspberry Pi and host websites both locally and online.

Why Use WordPress?

If you are looking for a way to host a website with minimal effort, WordPress is not the obvious solution. We’ve already covered how to set up your Raspberry Pi to host a static or dynamic website (that is, one that uses standard, pre-written pages, or one that uses a database to populate pages).

But if you really need to use WordPress, or you’re developing a theme or plugins for a WordPress site, then a Raspberry Pi with a blogging platform installed and ready to use is a great option.

Which Raspberry Pi Should You Use?

Raspberry Pi 3 and Raspberry Pi 3B+

To install WordPress on your Raspberry Pi, you need to set it up as a LAMP server. Once Linux, Apache, MySQL, and PHP are installed, your Pi will be able to run WordPress (and other site software).

Several Raspberry Pi models are available. You may have one, several, or none. But which one is the most suitable for running WordPress?

Luckily, any version of the Raspberry Pi can be used to host a WordPress site. However, for best results, we recommend using a Raspberry Pi 2 or later. Also, make sure you’re using a large SD card — at least 16GB — as storage space is a key requirement for web servers. (Also consider some external storage for the Pi!)

The rest of this guide assumes that the Raspberry Pi is turned on and connected to the local network. You must also have SSH configured for remote command line access.

Step 1: Set up the Apache web server

Start by installing the Apache web server. This is software that allows you to serve any type of web page in any browser. That’s all you need to serve up an HTML page, whether statically or dynamically generated with PHP.

sudo apt install apache2 -y 

Once installed, Apache will place a test HTML file in the web folder on your Pi. You must check this from another computer (or smartphone) on your network. You will need to enter the Pi’s IP address in the address bar of your browser. If you are using SSH, you already know this; otherwise, enter:

 hostname -I 

This displays the IP address of your Raspberry Pi. The page you see should look something like this:

Apache server installed on Raspberry Pi

You can also test the webpage from your Raspberry Pi at http://localhost.

Step 2: Install PHP on Raspberry Pi

Next, it’s time to install PHP. It is a software preprocessor that allows you to serve server-generated web pages rather than static HTML pages. Although the HTML page can be written in its entirety, the PHP page will contain calls to other pages and to the database to populate it with content.

While other server platforms are available (such as ASP), PHP is important here as it is required by WordPress since WordPress itself is written in PHP.

Install with:

 sudo apt install php -y 

Once this is done, you should check that PHP is working. Change directory to /var/www/html/ in the following way:

 cd /var/www/html/ 

Delete file here index.html (the web page you were viewing earlier):

 sudo rm index.html 

Then create a new file named index.php (nano is installed by default):

 sudo nano index.php 

Here, add any (or all) of the following code:


In order, these commands display:

  • Phrase «Hello World»
  • Current date and time
  • PHP information for installation

Save the file, then restart Apache:

 sudo service apache2 restart 

Refresh the page to see the results.

PHP installed and running on Raspberry Pi

PHP and Apache both work. Now it’s time to install the MySQL database software.

Step 3Install MySQL on Raspberry Pi

WordPress (and other dynamically generated website software) requires a database to store content, link to images, and manage user access (among other things). This project uses a fork of MySQL called MariaDB:

 sudo apt install mysql-server php-mysql -y 

Once this is installed, you will again need to restart Apache:

 sudo service apache2 restart 

As noted, other database options are available for this type of project. However, for best results, especially if this is your first time setting up a web server, stick with MySQL.

Step 4Install WordPress on Raspberry Pi

To install WordPress, you first need to install it. However, before that, delete the contents of the directory /html/ :

 cd /var/www/html/ sudo rm * 

Asterisk wildcard removes everything in a directory thanks to the command rm


Download WordPress with wget Next use wget

 sudo wget http://wordpress.org/latest.tar.gz 

to download the latest version of WordPress:

 sudo tar xzf latest.tar.gz 

Once downloaded, extract the contents: The WordPress directory needs to be created, but you want its content in HTML.

 sudo mv wordpress/* . 

While you can move them manually using the desktop UI, it’s easy to do so from the command line:

Don’t forget to include a space and a period at the end, which refer to the current directory! Enter ls,

to confirm that the directory is full of WordPress folders and PHP files:

Move Contents of a WordPress Directory

 sudo rm -rf wordpress latest.tar.gz 

Before proceeding, tidy things up by dropping the downloaded WordPress file and directory:

 sudo chown -R www-data: . 

Then set the Apache user as the owner of the directory:

Step 5: Set up MySQL

 sudo mysql_secure_installation 

To set up the database, you first need to run the setup command: You will soon be prompted to set a root password.

Follow the instructions on the screen, making sure you remember the password as you will need it later.

  • Once it is one, the following prompts will appear:
  • Remove anonymous users
  • Deny root login remotely
  • Delete test database and access to it

Reload grant tables now For each of them click Y, to confirm.

When everything is ready, the message «You’re done!» will appear.

Step 6: Create a WordPress Database To install WordPress, you first need to set up a database. Start by executing the command mysql

 sudo mysql -uroot -p 

by entering the password before. This opens the MariaDB monitor.

 create database wordpress; 

Create a database when prompted: Note that all commands in the MariaDB monitor end with «;». Next, the root user needs database privileges.

 GRANT ALL PRIVILEGES ON wordpress.* TO 'root'@'localhost' IDENTIFIED BY 'PASSWORD'; 

Use your password instead of PASSWORD.


Then reset the previous database privileges: Exit the MariaDB database management tool by clicking


Step 7: Install and Set Up WordPress Installing WordPress is easy;

if you’ve already done this on an existing website, you should know what to do. Open the website in your browser (as described above). You should see the WordPress installation screen.

Select your language, then «Continue» and write down what is required: database name, username, password, host, and table prefix (this is for database tables). If you made it this far, you should have named the database «wordpress» and noted down the password. Username root and host localhost . Table prefix

— wp_. Click « Send» then run the installation and enter a name site as well as Username and password for an administrator account. Click « Install WordPress»

and wait while WordPress is set up (quickly). To enter your WordPress installation, go to http://localhost/wp-admin


Installed WordPress site on Raspberry Pi At this point, you have a website that you can start using. Our guide to getting started with WordPress help here. Don’t forget to choose a theme and some useful plugins.

You will also need a method to access the site from the web.

Accessing your WordPress site from the web In the current situation, you will probably only be able to access the site from your home network.

To change this, you will need a static IP address and port forwarding control from your Raspberry Pi router. However, static IPs are expensive, but you can use a dynamic DNS provider instead. This basically links a custom URL to your Raspberry Pi, although such services are often paid.

Check out our list of the best dynamic DNS providers for full details. If you are facing issues with blank white pages or WordPress 500 Internal Server Error blank white pages

check out our helpful guide.

Host a WordPress Site on Raspberry Pi: Success! You are all set now and your Raspberry Pi is running a WordPress site. As long as the computer remains on, the site will still be available.

Launch the site and access it locally or over the Internet. If all this was a little overwhelming, we don’t blame you. That’s why we recommend using WP Engine to host WordPress sites without the hassle.

They manage all administrative matters so you can focus on your content.

Похожие записи