Raspberry Pi – Set Up LAMP Stack & WordPress

I recently received a Raspberry Pi 3, and I’m an immediate fan. I’ve had a 2 for a while, but having wireless services built into the board makes things so much easier. Pretty much all of my stuff is still packed, so I was a bit limited in terms of what projects I could use it for, so instead I decided to just mess around with various services and configurations on it. These posts will follow.

A LAMP (Linux, Apache, MySQL, PHP) Stack is a pretty standard solution for running a web service like WordPress. Whatever I use my Pi for, chances are that I’m going to want a pleasant HTML interface. And since I have little experience with WordPress, I decided to start there. To do so, I followed the guide here.

First off, perform the necessary installations. I imagine you could probably install them all at once, on one line, but I did it piece by piece.

apt install apache2
apt install php7.0 libapache2-mod-php7.0
service apache2 restart
apt install mysql-server php7.0-mysql
mysql_secure_installation

Accept defaults ensuring to set a password

service apache2 restart
cd /var/www/html
rm ./*
wget http://wordpress.org/latest.tar.gz
tar xzf latest.tar.gz
mv wordpress/* .
rm -rf wordpress latest.tar.gz
chown -R www-data:www-data /var/www/html

Create wordpress database in mysql

mysql -uroot -p
CREATE DATABASE wordpress;

Create wordpress user in mysql

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

Set up wordpress online

Some final configurations:

a2enmod rewrite
nano /etc/apache2/sites-available/000-default.conf

add after line 1

<Directory “/var/www/html”>
    AllowOverride All
</Directory>
Service apache2 restart

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.