Use the Raspberry Pi 3 with Ubuntu Mate as a sandbox for testing WordPress
There are several sources of information about the subject of installing wordpress on the raspberry pi. Here are just some that I had found the most useful.
The fundamentals always start with LAMP. This is short for Linux, Apache, MySQL, and PHP. Since we are using Ubuntu Mate, the linux portion is taken care of. Now onto the remainder of the list.
You will need to be local on the Raspberry Pi Mate system, or remote into it with a remote desktop client or SSH.
Once a local terminal window is running, issue this command.
sudo apt-get install apache2 -y
The Apache web services should install. When they finish, you should be able to open the default web page to verify all is working.
Next up, install PHP. This is done issuing this command at the terminal windows.
sudo apt-get install php libapache2-mod-php -y
Now, we’ll want to make a backup of our default Apache home page, it is located here, /var/www/html. Enter in these command at the terminal.
sudo cp index.html index.old sudo rm index.html
Next open up NANO with this command.
sudo nano index.php
Once open, paste in the following text to create our new PHP home page.
<?php echo "hello world"; ?>
we are ready to test PHP, open up a browser and to your Pi’s web
You can edit your index.php file and replace all the text with this.
<?php phpinfo(); ?>
Be cautious, this shows the world more than it needs to know about your setup. This is more like it here.
<?php echo date('Y-m-d H:i:s'); ?>
Anyway, PHP should be running. Now to install MySQL, this is the database backend that WordPress places and retrieves its data.
Issue this command to install MySQL.
sudo apt-get install mysql-server php-mysql -y
It will install and prompt for the root password that MySQL will use. Enter in something logical that you’ll want safe. You don’t need your sandbox crapped in.
Now you’ll want your change ownership of the contents of your web root so that user “pi” has ownership of everything. If you are like me, the user pi has been replaced by someone else, do the same command for your user.
sudo chown <YourUser>: .
You’ll also want to purge the web root folder of all its files. Back them up if you like forming good habits. Do the following commands.’
cd .. mkdir htlm_bak sudo mv /opt/bitnami/apps/wordpress/htdocs/* /var/www/html_bak/ sudo rm -rfv /opt/bitnami/apps/wordpress/htdocs/* cd /opt/bitnami/apps/wordpress/htdocs/ ls
Once you see no contents in your web root, next is the download of latest release of WordPress. This is done using the following command from inside the path of /opt/bitnami/apps/wordpress/htdocs/. Your web root may differ.
wget http://wordpress.org/latest.tar.gz tar zsf latest.tar.gz cd wordpress mv wordpress/* .
With WordPress staged and ready, we’ll need to create the database for it. Open up a MySQL session and issue in the commands following the login.
Mysql -uroot -p<YourMySQLPassword> create database wordpress;
Press CTRL + D to close out of MySQL.
To get the wordpress site to respond, restart apache with this command.
sudo /etc/init.d/apache2 restart
With that done, start your web browser and open up the main page of your Raspberry Pi. Here you will see a welcome page for your wordpress setup.
Enter in the database name, user name, password, database host, and table prefix. Press submit to continue on. Next, you may get a message that the “wp-config.php” file could not be writen to. The code for the file should appear if that occurs. Copy that code and edit the “wp-config.php” file found in the web root directory.
sudo nano wp-config.php
With the file created, contiue on with the wordpress setup by pressing the continue with install.
You should get a welcome page asking for Site Title, Username, Password, email, and privacy information. With that filled out, press install wordpress to finish up the setup.
WordPress is running on the Raspberry Pi. One thing that could be an issue is installing plugins and themes. To do this you’ll need to run this command in the terminal window on you raspberry pi under the web root.
sudo chown -R www-data:www-data /var/www/html
Themes and plugins should install now without any fuse.
As an added feature I would like to get PHPMyAdmin setup. I used the steps outlined in this video.
First, issue this command from the terminal window.
sudo apt-get install phpmyadmin
During the install, you should get a web server reconfigure notice, select apache2 from the list. Next, configure the database for phpmyadmin. Select yes from the options. Enter in the database password, this is what you used during the MySQL install. Now enter in the password used by phpMyAdmin for its login window. That should wrap up the phpMyAdmin install.
Next is editing the apache config.
Issue this command from the terminal window.
sudo nano /etc/apache2/apache2.conf
Scroll to the end of the file and enter in this line.
I finished all the steps and ended up with a blank page when I tried to access the page, http://ip_of_raspberry_pi/phpmyadmin
There were a series of things I did following the suggestions of various posts online. If I don’t give credit to those that help, please understand it took several attempts to get it right. By the time I figured it out, my bread crumbs leading me out of the forest had been eaten by the birds.
First, I changed the permissions for these following directories.
sudo chown -R www-data:www-data /usr/share/phpmyadmin sudo chown -R www-data:www-data /var/lib/phpmyadmin sudo chown -R www-data:www-data /etc/phpmyadmin
Next, I installed a php-gettext component.
sudo apt install php-gettext
Then, I edited the php.ini file located here /etc/php/7.0/apache2 using this command.
sudo nano php.ini
I then modified these lines so I could import large SQL datasets.
upload_max_filesize = 200M post_max_size = 200M
Next, I edited the hosts file located in /etc/. I removed all of the IPv6 entries and entered in my assigned IP for localhost and <raspberry_pi> name.
Finally, I restarte apache using this command.
sudo /etc/init.d/apache2 restart
There, I was able to access PHPMyAdmin on the Rasbperry Pi and upload my modified backup of my live WordPress site.