It is meant to function as a staging or testing server where you can do compatibility test latest wordpress version on your existing sites, or try themes, plugins,widgets or practice your coding skills in css & php before deploying into your production, then using rpi is a good option.
Components used and tested working:
Raspberry Pi Model B , installed with Raspbian GNU/Linux 8 Jessie (Kernel armv6l Linux 4.9.35+)
nginx(1.6.2-5+deb8u5) (Web Server)
php5 (php5 5.6.33)
mysql 5.5 (ver.5.5.59-0+deb8u1) (Database Server)
wordpress
Before start the actual installation, update rpi packages
pi@raspberrypi:~ $ sudo apt-get update; sudo apt-get upgrade
Sample output:
pi@raspberrypi:~ $ sudo apt-get update; sudo apt-get upgrade
Get:1 http://mirrordirector.raspbian.org jessie InRelease [14.9 kB]
Get:2 http://mirrordirector.raspbian.org jessie/main armhf Packages [9,536 kB]
Get:3 http://archive.raspberrypi.org jessie InRelease [22.9 kB]
Fetched 9,874 kB in 46s (210 kB/s)
Reading package lists… Done
Reading package lists… Done
Building dependency tree
Reading state information… Done
Calculating upgrade… Done
176 upgraded, 0 newly installed, 0 to remove and 12 not upgraded.
Need to get 94.4 MB/97.3 MB of archives.
After this operation, 3,064 kB of additional disk space will be used.
Do you want to continue? [Y/n]
Fetched 94.4 MB in 2min 47s (564 kB/s)
Reading changelogs… Done
Running hooks in /etc/ca-certificates/update.d….done.
1. Install Nginx
pi@raspberrypi:~ $ sudo apt-get install nginx
Test if everything ok by running:
pi@raspberrypi:~ $ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
Start nginx and check status if running:
pi@raspberrypi:~ $ sudo service nginx start
pi@raspberrypi:~ $ sudo service nginx status
Open your favorite web browser and test it by going to Pi’s localhost or actual IP, e.g. http://localhost , http://192.168.1.200 . If working, you will be able to see the default page which is the index.html under /var/www/html , and see message something like:
If any changes done, reload the config
pi@raspberrypi:~ $ sudo systemctl reload nginx
2. Install PHP
As WordPress is written in PHP, we need to install PHP as the scripting language . PHP is a server-side programming language that can serve dynamic pages and it is processed via its php module
a. Install using the following command:
pi@raspberrypi:~ $ sudo apt-get install php5 php-fpm php5-mysql
b. Configure the nginx configuration file for php module to work. Modify the default file under /etc/nginx/sites-available directory, make sure to uncomment or add the following lines:
pi@raspberrypi:~ $ sudo vi /etc/nginx/sites-available/default
server_name 192.168.1.200;
index index.php index.html index.htm;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
include fastcgi.conf;
}
location ~ /\.ht {
deny all;
}
}
Test by doing the following steps:
a. Create index.php under the default root directory (/var/www/html) with the contents below:
pi@raspberrypi:~ $ sudo vi /var/www/html/index.php
<?php
phpinfo();
?>
b. Access http://localhost or http://192.168.1.200, if you see something like this as per below image, then php was sucessfully installed.
3. Install MySQL server
pi@raspberrypi:~ $ sudo apt-get install mysql-server
root password will be asked during installation , this will use to access the MySQL engine.
Login to mysql as root with the password provided during installation. Create a database name “wordpress” and wordpress user and grant all privileges for that database e.g. (db name: wordpress username: wpadmin pass: freelinux)
mysql> CREATE USER wpadmin@localhost IDENTIFIED BY ‘freelinux’;
mysql> CREATE DATABASE wordpress;
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO wpadmin@localhost IDENTIFIED BY ‘freelinux’;
mysql> FLUSH PRIVILEGES;
mysql> quit;
Query OK, 1 row affected (0.00 sec)
4. Install WordPress
Download, install, extract and change file ownership
pi@raspberrypi:~ $ cd /var/www/html
pi@raspberrypi:~ $ sudo wget http://wordpress.org/latest.tar.gz
pi@raspberrypi:~ $ sudo tar zxvf latest.tar.gz
pi@raspberrypi:~ $ sudo rm latest.tar.gz
pi@raspberrypi:~ $ sudo chown -R www-data /var/www/html/wordpress
Navigate using your browser http://192.168.1.200 and will be presented with WordPress welcome page
-Click “Let’s go” to proceed the setup
-Will be presented by the following, fill out accordingly (in case need to change, can modify the wp-config.php later on):
Database Name: wordpress
User Name: wpadmin
Password: freelinux
Database Host: localhost
Table Prefix: wp_
-Click Submit
-Click “Run the install”
-Next fill out necessary information such as Site Title, username, password and email address. Then click the “Install WordPress” button
Once done, login using the username and password provided earlier, URL is http://192.168.1.200/wp-admin
Enjoy customizing your wordpress by changing themes, installing plugins and widgets , or can edit the stylesheet css if necessary.
Now you’re ready to start adding your first ever post. Happy blogging!
Sample screencap:
Additional Tips or optional tasks:
1. If you have existing database and want to restore from backup database, here’s the command to restore
pi@raspberrypi:~ $ mysql -u wpadmin -p wordpress < freelinux-backup.sql
2. If migrating WordPress from Apache to Nginx, permalinks may not work even after re-saving changes (Settings > Permalinks > Save Changes). Try to change the “try_files from $uri $uri/ =404 to $uri $uri/ /index.php?$args
before: try_files $uri $uri/ =404;
after: try_files $uri $uri/ /index.php?$args;
3. Can create virtualhost if have multiple instances of wordpress