Raspberry Pi is mostly ready for use after the basic configuration completed in my previous posts:
- Raspberry Pi 2 Model B Basic Configuration Part 2
- Raspberry Pi 2 Model B Basic Configuration Part 1
- Remote Access Raspberry Pi from Anywhere
The next cool thing to do is to install wordpress on it. This post is just used to record all steps I have followed online instruction installed an instance of a WordPress site to run on Raspberry Pi using the Apache Web Server. There are a lots of more things you may like to know regarding Apache, PHP, Mysql. It is best to search other online resources or take a look those listing at the Reference section to find out more.
1. Check system update
sudo apt-get update && sudo apt-get upgrade
|
Choose Y if there is any update.
2. Install Apache2
sudo apt-get install apache2 -y
|
hostname -I
|
Get the ip address your Raspberry Pi
Open http://<IP> to confirm apache is working. It shows the /var/www/index.html in your browser.
3. Install php5
sudo apt-get install php5 libapache2-mod-php5 -y
|
create a test index.php file
cd /var/www
sudo echo “<?php phpinfo(); ?>” | sudo tee index.php |
verify php has been installed properly by using curl command.
pi@raspberrypi /var/www $ curl http://127.0.0.1/index.php
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “DTD/xhtml1-transitional.dtd”> <html xmlns=”http://www.w3.org/1999/xhtml”><head> <style type=”text/css”> body {background-color: #ffffff; color: #000000;} body, td, th, h1, h2 {font-family: sans-serif;} pre {margin: 0px; font-family: monospace;} a:link {color: #000099; text-decoration: none; background-color: #ffffff;} a:hover {text-decoration: underline;} table {border-collapse: collapse;} .center {text-align: center;} .center table { margin-left: auto; margin-right: auto; text-align: left;} .center th { text-align: center !important; } td, th { border: 1px solid #000000; font-size: 75%; vertical-align: baseline;} h1 {font-size: 150%;} h2 {font-size: 125%;} .p {text-align: left;} .e {background-color: #ccccff; font-weight: bold; color: #000000;} .h {background-color: #9999cc; font-weight: bold; color: #000000;} .v {background-color: #cccccc; color: #000000;} .vr {background-color: #cccccc; text-align: right; color: #000000;} img {float: right; border: 0px;} hr {width: 600px; background-color: #cccccc; border: 0px; height: 1px; color: #000000;} </style> <title>phpinfo()</title><meta name=”ROBOTS” content=”NOINDEX,NOFOLLOW,NOARCHIVE” /></head> <body><div class=”center”> <table border=”0″ cellpadding=”3″ width=”600″> <tr class=”h”><td> <a href=”http://www.php.net/”><img border=”0″ src=”/index.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42″ alt=”PHP Logo” /></a><h1 class=”p”>PHP Version 5.4.45-0+deb7u2</h1> </td></tr> …… |
4. Install mysql database server.
sudo apt-get install mysql-server
|
During installation of mysql, you will be asked to provide root password.
5. Download wordpress and install it under /var/www/wordpress folder
cd /var/www
sudo chown pi: . sudo rm * wget http://wordpress.org/latest.tar.gz tar xzf latest.tar.gz |
6. Create wordpress database from mysql command line
mysql -uroot -ppassword
mysql> create database wordpress; Query OK, 1 row affected (0.00 sec) |
7. Open URL “http://<IP>/wordpress” in the browser to start configure WordPress
Database Name: wordpress
User Name: root
Password: <YOUR PASSWORD>
Database Host: localhost
Table Prefix: wp_
During configuration WordPress site, there is a problem to write wp-config.php file. To resolve this issue, you will have to manually create it with the contents showing above in the browser.
cd /var/www/wordpress
nano wp-config.php |
Paste the copied text from browser into this file, and save and exit with Ctrl + X, then Y for yes and Enter.
Hit Run the install button to continue the installation. The last step is to enter your WordPress site information.
After installation done, the browser will jump to http://<ip>/wordpress/wp-admin. You will need to provide wordpress site username and password to log into Dashboard to manage your new created site.
There is one tip for a problem which is when you are trying to install new plug-in in your WordPress site, it will prompt a page to ask you ftp username, password and site address. It is because of wordpress folder’s permission problem.
The easiest and fastest fix is :
cd /var/www
sudo chown -hR http:http wordpress |
You can replace http user with pi user.
8. Test it from Internet
Once you have your dynamic DNS client installed and configured properly based on my previous post:
Remote Access Raspberry Pi from Anywhere and Dynamic DNS Update with Dynu.com
You will need to configure your WordPress to use your registered Dynamic DNS name as following screenshot:
Now your Raspberry Pi WordPress site http://51sec.dynu.com/wordpress can be accessed from Internet:
9. Redirect Homepage to Specific URL
pi@raspberrypi /var/www $ sudo vi index.html
<html>
<head>
<META HTTP-EQUIV="Refresh" Content="3; URL=http://51sec.dynu.com/wordpress">
</head>
<body>
This page will forward to http://51sec.dynu.com/wordpress in three seconds.
<p>
Please update your links.
</body>
</html>
Notes: Install Others Services on Raspberry Pi
Reference:
- BUILD A LAMP WEB SERVER WITH WORDPRESS
- How to Install WordPress on a Raspberry Pi
- Tutorial: Hosting a WordPress Blog with Amazon Linux
- Tutorial: Installing a LAMP Web Server on Amazon Linux