Manage your Raspberry Pi website with the WordPress CMS

PHP

The next step is to install PHP and the Apache PHP module:

$ sudo apt-get install php5 \
  libapache2-mod-php5

Before you continue with MySQL, run a quick PHP test. In the directory /var/www/html (or/var/www for a wheezy system), create a file called index.php and enter this line:

<?php echo "Hello, World!";

Save the file and open it in the web browser. Move or delete the file index.html before you do so. As you can see this is static content, so it doesn't change. To try something more dynamic, replace the line above with this:

<?php phpinfo();

Reload the site, and you will get a dynamically created page that shows a lot of information about your own PHP installation, including the version number, the build date, the location of the configuration files, and more (Figure 4).

Figure 4: This is the output that the function phpinfo() generated on the test machine.

Database Installation

To set up the MySQL database engine on your Raspberry Pi, install the server and the PHP MySQL packages:

sudo apt-get install mysql-server php5-mysql

The configuration routine of the MySQL server package will ask you to define a root password (Figure 5). You need this password later to allow WordPress to access the database. Restart Apache by typing

sudo systemctl restart apache2.service

so it knows about PHP and MySQL; otherwise, you will see an error message later when you set up WordPress.

Figure 5: Define a root password for the MySQL database.

Now you need to set up a database for WordPress. You can use the mysql command on the shell to do so and provide your login credentials:

mysql -uroot -ppassword

Replace password with the password you configured during the MySQL server setup (Figure 5). Note that there is no space between -p and the password.

The shell prompt changes to mysql>, which means you've successfully connected to the server. Next, create the database for your WordPress installation:

mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)
mysql>

Use Ctrl+D to exit the MySQL monitor.

Buy this article as PDF

Express-Checkout as PDF

Pages: 5

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content