25) Configuring WordPress

<-- Previous    Next –>

At this point we should have our Apache web server set up, our WordPress files downloaded and installed, and the database set up with username and password. So now the next stop is to run through the standard instillation of WordPress.

Open the web browser on your Pi and go to http://hostname where hostname is what you have setup previously. You should see a WordPress page asking to pick your language.

Select your language and click Continue.

You will be presented with the WordPress welcome screen.

Click the Let’s go! button.

Now fill out the basic site information as follows:

Database Name: YOUR WORDPRESS DATABASE NAME
User Name: YOUR WORDPRESS DATABASE USERNAME
Password: YOUR PASSWORD
Database Host: localhost
Table Prefix: wp_

Click Submit to proceed.

Click the Run the install button.

Fill out the information: give your site a title, create a username and password, and enter your email address. Click on Install WordPress button, then log in using the account you just created.

Now you’re logged in and have your site set up, you can see the website by visiting your http://hostname/wp-admin.

Correct file permissions

We need to change the file permissions on files and folders for the WordPress site to make sure that the site is secure and also that we can install plugins, themes and to do upgrades.

All files should be 664
All folders should be 775
wp-config.php should be 660

This is what we achieve by setting these permissions:

  • Users may read and modify our files
  • WordPress may create, modify or delete files and folders
  • Other people must not see our database credentials in wp-config.php

Change directory to the root of your web server files then:

sudo find . -type d -exec chmod 0755 {} \;
sudo find . -type f -exec chmod 0644 {} \;
sudo chmod 600 wp-config.php

Friendly permalinks

It’s recommended that you change your permalink settings to make your URLs more friendly.

To do this, log in to WordPress and go to the dashboard.

Go to Settings, then Permalinks.

Select the Post name option and click Save Changes.

You’ll need to enable Apache’s rewrite mod using the following command in the Terminal:

sudo a2enmod rewrite

Then restart the Apache server.

sudo service apache2 restart

You’ll also need to tell the virtual host serving the site to allow requests to be overwritten.

Edit the Apache configuration file for your virtual host:

sudo nano /etc/apache2/sites-available/000-default.conf

Add the following lines after line 1:

<Directory /websites/www/html>
AllowOverride All
</Directory>

The directory /websites/www/html is the USB directory if you are using USB flash storage, otherwise it will be /var/www/html

Ensure it’s within the <VirtualHost *:80> like so:

<VirtualHost *:80>
<Directory /var/www/html>
AllowOverride All
</Directory>

Take care when typing in the above lines as any error will stop the web server running.

Save the file and exit.

Restart Apache using:

sudo service apache2 restart

Why does WordPress ask for ftp details and how to fix it?

You may find that when you install a plugin it returns an error saying that the uploads folder is not writable or it may ask you to enter ftp details. It is doing this probably because WordPress is not running under the correct owner which should be the same owner that Apache is running under.

The easiest way to fix this is to find out what user Apache is running as and change ownership of the WordPress directory to that user. For example, if Apache is running as ‘www-data’, you could use the following commands on your WordPress installation directory:

sudo chown -R www-data: /website/www/html

assuming that the WordPress directory is at /website/www/html

To find out the owner, create a PHP file with the following text:

<?php echo(exec(“whoami”)); ?>

You can create this using nano in the terminal using something like:

sudo nano whiami.php

Display it in your browser and it will show the owner.

Improvements to speed of WordPress

Install a cache plugin such as WP Super Cache.

Security with WordPress

Refer to: http://codex.wordpress.org/Hardening_WordPress

Why are my Pages and Posts prefixed with index.php in the url

This is probably because you have not set the permalinks option. Go to Settings -> Permalinks and select the Post name option.

<-- Previous    Next –>