Raspberry Pi WordPress Tutorial

To install WordPress on a Raspberry Pi, you’ll need to install Apache, MySQL, PHP, and WordPress. 

Raspberry Pi WordPress Server: Install Apache

First, you’ll need to install Apache, an incredibly popular web server program. In a terminal, run:

sudo apt-get install apache2 -y

This installs Apache. Once installation completes, you can test if it worked properly. Open a web browser and navigate to http://localhost. Doing so should display an Apache2 landing page. 

Next, you can change the default web page, which is found at /var/www/html/index.html. In a command line, enter:

cd /var/www/html
ls -al

You’ll see an output similar to:

total 20
drwxr-xr-x 2 root root 4096 Aug 23 09:55 .
drwxr-xr-x 3 root root 4096 Aug 23 09:48 ..
-rw-r--r-- 1 root root 10701 Aug 23 09:55 index.html

Edit this file by entering the following into a terminal window:

sudo leafpad index.html

Raspberry Pi WordPress Hosting: Install PHP

Now, install PHP, or code which runs when a server gets a request for a page via a web browser. To install PHP, enter:

sudo apt-get install php -y

Then, make an index.php file:

sudo leafpad index.php

Add some basic PHP to yourindex.php file:

 <?php echo "hello world"; ?>

When that’s finished, save your file and delete the index.html file. You’ll use the index.php file instead:

sudo rm index.html

In your browser, navigate to localhost and you should see “hello world,” or whatever text you added. If all you’re viewing is raw PHP, restart the Apache service:

sudo service apache2 restart

Then, edit your index.php file and add dynamic content like:

<?php echo date('Y-m-d H:i:s'); ?>

With this finished, PHP should be installed. Now it’s time to install MySQL, an excellent database engine. Run: 

sudo apt-get install mysql-server php-mysql -y

After that, restart Apache with:

sudo service apache2 restart

Install WordPress on Raspberry Pi: MySQL Installation

Once you’ve installed Apache, PHP, and MySQL, it’s time to install WordPress on the Raspberry Pi. Navigate to /var/www/html/ and delete all files within it:

cd /var/www/html/
sudo rm *

Next, download the latest version of WordPress:

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

Extract the tarball with:

sudo tar xzf latest.tar.gz

And move the contents of your WordPress folder to the current directory you’re in:

sudo mv wordpress/* .

Since you’re done using your tarball, delete it:

sudo rm -rf wordpress latest.tar.gz

To view the contents of your WordPress folder, enter:


Finally, make sure that the Apache user is the default owner of that directory:

sudo chown -R www-data: .

Raspberry Pi WordPress Tutorial: Installing WordPress

Ok, so Apache, PHP, MySQL, and WordPress are all (hopefully) properly installed. You’ll have to set up your WordPress database. Run the MySQL secure installation with:

sudo mysql_secure_installation

You’re prompted to enter the password for the root user. If there’s none, simply hit enter. 

Type y and hit enter to set a root password, then type in a new password. 

Hit y to remove anonymous users, y to disallow root login remotely, y to remove test database and access to it, and y to reload privilege tables. Then, you’ll see a message saying “Thanks for using MariaDB!” 

In a terminal, run MySQL with:

sudo mysql -uroot -p

Enter the password you created earlier. Make a database for your Raspberry Pi WordPress install using:

create database wordpress;

If this worked, you should see a message such as:

Query OK, 1 row affected (0.00 sec)

Give database privileges to the root user by running:


For these to manifest, enter:


Exit MariaDB with CTRL + D.

Begin configuring WordPress. In a browser, enter http://localhost and you should see the WordPress set up page. Select your preferred language from the list and click continue. 

You’ll see a welcome to WordPress page. Review this information, and click let’s go. 

Load the site information:

Database Name: wordpress
User Name: root
Password: <PASSWORD>
Database Host: localhost
Table Prefix: wp_

The info you enter here may vary. Hit submit to continue, then select run the install. Give your site a title, then make a username and password. Upon filling out this basic info, click install WordPress. You can log in with the username and password you just created. 

Additionally, you may login at http://localhost/wp-admin

Raspberry Pi as a WordPress Server: Final Thoughts

That’s it! Your Raspberry Pi WordPress web server should be up and running. I found installing WordPress on the Raspberry Pi a little easier than a Raspberry Pi Drupal install, though that’s not terribly difficult either. Ultimately, if you’re looking for inexpensive web hosting, a self-hosted WordPress site on Raspberry Pi is a solid choice.

Deja un comentario