23) Installing WordPress onto Raspberry Pi

<-- Previous    Next –>

Installing WordPress should be straight forward and should follow the normal method now that you have PHP, Apache and MySQL setup.

Downloading The latest version of WordPress

You can download WordPress from wordpress.org using the wget command.

The latest version of WordPress is always available at wordpress.org/latest.tar.gz, so you can grab the latest version without having to look it up on the website.

If you are using the USB stick as described in a previous section, the web site will be located at /websites/www/html/ other wise it will be located at /var/www/html/

Change directory to /websites/www/html/ and delete all the files in that directory:

cd /websites/www/html/
sudo rm *

Download WordPress using wget.

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

Extract the WordPress tarball to get at the WordPress files.

sudo tar xzf latest.tar.gz

Move the contents of the extracted wordpress directory to the current directory.

sudo mv wordpress/* .

Tidy up by removing the tarball and the now empty wordpress directory.

sudo rm -rf wordpress latest.tar.gz

Running the ls or tree -L 1 command now will show you the contents of a WordPress project.

These files and folder make up your WordPress installation.

You should now change the ownership of all these files to the Apache user:

sudo chown -R www-data: .

Now if we go to a browser and enter http://hostname where hostname is the name you have given to the web server, you should be presented with the installation screen of WordPress. We cannot go any further at this stage because we have not created the database for WordPress. If you do not see the WordPress installation screen, it may be because you have not changed the Apache settings as described in one of the previous pages.

<-- Previous    Next –>

 

 

 

17) Install phpMyAdmin

<-- Previous    Next –>

So far we have PHP, MySQL and Apache 2 installed on the Raspberry Pi Web Server, now we can install phpMyAdmin which is a web application to administer MySQL.

The easiest way to install phpMyAdmin is through apt-get:

sudo apt-get install phpmyadmin

During the installation, phpMyAdmin will walk you through a basic configuration. Once the process starts up, follow these steps:

  • Select Apache2 for the server by pressing the space bar.
  • Choose YES when asked about whether to Configure the database for phpMyAdmin with dbconfig-common
  • Enter your MySQL password when prompted
  • Enter the password that you want to use to log into phpMyAdmin web interface
  • After the installation has completed, add phpMyAdmin to the Apache configuration.
sudo nano /etc/apache2/apache2.conf

Add the following line to the file:

include /etc/phpmyadmin/apache.conf

This can be placed at the end of the file.

Restart Apache using:

sudo service apache2 restart

You can then access phpMyAdmin by going to http://youripaddress/phpmyadmin or http://hostname/phpmyadmin

Log into phpMyAdmin

Go to http://youripaddress/phpmyadmin or http://hostname/phpmyadmin and try logging in with the username of: root and the password which you entered in the previous step.

Security of phpMyAdmin

To add an extra level of security it is recommended to use the htaccess / htpasswd system to stop anyone accessing the web pages.

Set Up the .htaccess File

To set this up, start off by allowing the .htaccess file to work within the phpMyAdmin directory.

sudo nano /etc/phpmyadmin/apache.conf

Under the directory section, add the line “AllowOverride All” under “Directory Index”, so the section will look like this:

<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
[…]

Save and exit the file.

Configure the .htaccess file

With the .htaccess file allowed, we can proceed to set up a login to access the phpmyadmin web page.

Start by creating the .htaccess page in the phpMyAdmin directory:

sudo nano /usr/share/phpmyadmin/.htaccess

Then enter the following:

AuthType Basic
AuthName “Restricted Files”
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

Save and exit the file.

Below you’ll see a quick explanation of each line:

AuthType: This refers to the type of authentication that will be used to the check the passwords. The passwords are checked via HTTP and the keyword Basic should not be changed.
AuthName: This is text that will be displayed at the password prompt. You can put anything here.
AuthUserFile: This line designates the server path to the password file (which we will create in the next step.)
Require valid-user: This line tells the .htaccess file that only users defined in the password file can access the phpMyAdmin login screen.

Create the htpasswd file

Now we will go ahead and create the valid user / password information.

Start by creating a htpasswd file. Use the htpasswd command, and place the file in a directory of your choice as long as it is not accessible from a browser. Although you can name the password file whatever you prefer, the convention is to name it .htpasswd.

sudo htpasswd -c /etc/phpmyadmin/.htpasswd username

Where username is the username of your choice.

A prompt will ask you to provide and confirm your password.

Once the username and passwords pair are saved you can see that the password is encrypted in the file.

Now restart Apache:

sudo service apache2 restart

Accessing phpMyAdmin

Now when you go to the web page http://servername/phpmyadmin a login box will be displayed.

Fill it in with the username and password that you generated. After you login you can access phpmyadmin with the MySQL username and password as before.

<-- Previous    Next –>