WordPress running on RaspberryPi

This is my first post in my fresh wordpress installation. Just now i’ve finished installing wordpress and i’m going to collect all steps. I’ve selected install Debian as operating system, then i use nginx, php-fpm and mysql daemons for running wordpress. This are all steps:

    • I had installed berryboot in SD card, and then i installed debian as a operative system. More info in this link
    • You must run “apt-get update” to update the repository source and i’ve installed my favourite editor.
    • I’ve installed all daemons needed:
$sudo apt-get install nginx php5-fpm php5-cgi php5-cli php5-common php5-curl php5-gd php5-mcrypt php5-mysql mysql-server
  • Set php-fpm to work with nginx daemons, for that we will use a socket unix file to communicate to nginx daemons, and then we can configure nginx virtual host and set a specific global variable from php.

File: /etc/nginx/sites-available/marc.cortinasval.cat

server {
        listen   80; ## listen for ipv4; this line is default and implied
        root /usr/share/nginx/www;
        index index.php;
        server_name marc.cortinasval.cat;
        location / {
                rewrite  ^/?$  /blog/  redirect;
                try_files $uri $uri/ /index.php;
        }
        location /blog/ {
                try_files $uri $uri/ /blog/index.php?$args;
        }
        location ~ \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
        location = /favicon.ico {
                log_not_found off;
                access_log off;
        }
        location = /robots.txt {
                allow all;
                log_not_found off;
                access_log off;
        }
        location ~ /\.ht {
                deny all;
        }
        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }
}

We must check the php5-fpm is listening in the properly unix file

$ grep listen /etc/php5/fpm/pool.d/www.conf
listen = /var/run/php5-fpm.sock

Finally, we modify the cgi.fix_pathinfo to 0 in the file /etc/php5/fpm/php.ini

$grep cgi.fix_pathinfo /etc/php5/fpm/php.ini
cgi.fix_pathinfo=0
  • Firstly install the php files, then prepare the mysql database and finally set database credentials.

Download wordpress installation files and unzip.

$ cd /usr/share/nginx/www/
$ wget http://wordpress.org/latest.zip
$ unzip latest.zip
$ mv wordpress blog
$ rm latest.zip

We prepare mysql database:

mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (6.58 sec)
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO "wordpress"@"localhost"IDENTIFIED BY "wordpress";
Query OK, 0 rows affected (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)
mysql> exit;
Bye

Set database credentials in wordpress application

cp wp-config-sample.php wp-config.php
vim wp-config.php

File /usr/share/nginx/www/blog/wp-config.php

/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'wordpress');
/** MySQL database password */
define('DB_PASSWORD', 'wordpress');
/** MySQL hostname */
define('DB_HOST', 'localhost');

Fix permissions in files and restart all daemons

$sudo chown -R www-data.www-data /usr/share/nginx/www/
$sudo service nginx restart 
$sudo service php5-fpm restart

Open any browser and you can do the first http request, then you can see the installation wizard is triggered.
Set admin blog credentials and the wizard creates mysql data structure.

I recommend you use url friendlies, it can increase the user experience, for example this url: https://marc.cortinasval.cat/index.php/2013/03/wordpress-en-raspberry-pi
For that, we add this lines in nginx virtual host configuration.
File: /etc/nginx/sites-available/marc.cortinasval.cat

...
        location /blog/ {
                try_files $uri $uri/ /blog/index.php?$args;
        }
...
  • Finally, add and set the wordpress pluggins, i’ve listed the plugging i like it.

SyntaxHighlighter Evolved
WP to Twitter
NextScripts: Social Networks Auto-Poster
Author Spotlight (Widget)
ExtraWatch Live Stats and Visitor Counter FREE
Google Analytics
Google Analytics for WordPress
Social Login for wordpress
User Photo

  • Create categories and define menu tabs
  • Select, download and install any theme and add the menu

I write this first post and my blog is ready to collect my technical experiences!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

Secured By miniOrange