Home > How To, Raspberry pi, Technology > Turning your Raspberry pi into a wordpress server

Turning your Raspberry pi into a wordpress server

November 4, 2012 Leave a comment Go to comments

How to turn your Raspberry Pi into a wordpress server

1) How to change Raspberry pi default password

2) How to setup a webserver with PHP on Raspberry Pi

3) Adding Mysql to your Raspberry Pi webserver

4) Download and install wordpress software onto the raspberry pi

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

sudo tar xzvf latest.tar.gz

sudo mkdir /var/www/wordpress

sudo cp -r ~/wordpress/* /var/www/wordpress

5) Configure Mysql for wordpress use

mysql -u root -p (leave blank and push enter)

(Enter the root MySQL password you setup in stage 3)

Create a database for wordpress to use ( database,user,password and privileges)

$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5340 to server version: 3.23.54

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON wordpress.* TO 
"wordpress"@"localhost"IDENTIFIED BY "raspi";

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

mysql> EXIT

6) create a new wordpress configuration based on the sample:

sudo cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php

7) Edit the wordpress configuration file with the following command

sudo nano /var/www/wordpress/wp-config.php

You need to change the following entries (example below)

define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'wordpress');
/** MySQL database password */
define('DB_PASSWORD', 'raspi');

8) Change the file permisions on the wp-config file to read only

sudo chmod 444 /var/www/wordpress/wp-config.php

And then run the following command to reboot the raspberry pi

sudo reboot

9) Now open up a browser and head to the wordpress site and finalize the install. To do this, navigate from a browser on another machine on the local network, to the local address of the Raspberry Pi.

http://(Raspberry Pi)/wordpress

10) If all has gone well you will get the follwing screen as shown below

Successful install of wordpress software on the Raspberry pi

 Fill in the boxes with your site name and password scroll to the bottom of the page and click “install wordpress”

  1. November 24, 2012 at 7:50 pm

    Reblogged this on Astronomy and Law.

  2. Rob
    December 2, 2012 at 12:34 am

    lovely set of tutorials…up to step “8) Change the file permisions and restart the php5-fpm

    sudo chown www-data.www-data /srv/www/wordpress/public_html/ -R”

    where i am presented with “chown: cannot access `/srv/www/wordpress/public_html/’: No such file or directory”

    please could you offer any words of advice, what have i done wrong/what have i missed?

    • December 2, 2012 at 8:26 pm

      My mistake on this one I’m afraid “sudo chown www-data.www-data /srv/www/wordpress/public_html/ -R” is from the orignal version of my post. I have updated the post to the correct version and it should now work.
      Many thanks for pointing it out

      • sam
        December 10, 2012 at 1:54 pm

        Hi, thanks for this – I’ve got a problem with step 8: slightly different problem though!
        Step 8: “sudo service php5-fpm restart” returns “php5-fpm: unrecognized service”

        I’m pretty stumped, can you help please?

  3. Rob
    December 22, 2012 at 3:23 pm

    sam :
    Hi, thanks for this – I’ve got a problem with step 8: slightly different problem though!
    Step 8: “sudo service php5-fpm restart” returns “php5-fpm: unrecognized service”
    I’m pretty stumped, can you help please?

    got it all up and running, ran into an FTP problem so did a clean install and now also get the same message above, also “chmod 444 /var/www/wordpress/wp-config.php” returns operation not permitted. bit of a bummer as it all worked before 😦

    • December 23, 2012 at 9:33 am

      Have removed the “sudo service php5-fpm restart” command and added sudo to “chmod 444 /var/www/wordpress/wp-config.php” – Instead of restarting the service reboot the pi which will do the same thing.

  4. Rob
    December 28, 2012 at 3:28 pm

    Thank you for all your excellent help, I have one remaining problem that I have not encounter before (I believe it is because wordpress is not use to being run on a pi) which is whenever I try to upload an image ether to the site e.g. header image or content image I get the following error “Unable to create directory wp-content/uploads. Is its parent directory writable by the server?” I have fixed this before on a standard Linux machine but am unfamiliar with the file structure on the pi do you have any idea for a fix for this?

    Once again thank you for your time, once my site is up and running may I provide a link back to your work? I can think of a few students that would apricot this tutorial.

  5. December 31, 2012 at 11:43 am

    Reblogged this on projectz.

  6. mytra1n1
    January 15, 2013 at 3:35 pm

    Is it possible to create a second site? and how would we do that?

  7. January 18, 2013 at 2:22 pm

    Hello Rob.

    What you can do is the following, first run the following to command to make sure the upload folder is created.

    sudo mkdir /var/www/wordpress/wp-content/uploads

    and then run

    sudo chmod 777 /var/www/wordpress/wp-content/uploads

    which is good for testing but you may want to change the permissions to 755 if placing live on the internet as you do not want the whole world being able to change things in that folder.

  8. Rob
    January 19, 2013 at 12:45 pm

    IT’S ALIVE!!!!!…oh no wait its dead again 😦

    is there a quick fix for making my site display correctly when not on my network, site displays fine when viewed from local ip 192.168.03/wordpress but only displays text when viewed from a system not on my network using full ip address

    • Rob
      January 21, 2013 at 10:18 pm

      edit – problem solved, will post the simple fix sometime tomorow incase anyone else runs into similar trouble

      • January 22, 2013 at 9:32 am

        Fantaisc work Rob,
        If you could also post a link to your active wordpress site I wlll happily post a permanent link on my blog.

  9. Rob
    January 24, 2013 at 12:40 pm

    So here is the fix (if any of you have trouble with it feel free to message me as at the time of writing this I’m not near the Pi and cant SSH into it atm *pesky workplace firewalls :(*

    …anyway to the job in hand.

    To access your pi website from outside your local network you will need to change the ip address from the local host ip to your main ip, there are two ways to do this the first being the easiest.

    open the word press admin page and navigate to the settings, you will be presented with two urls which should read something like 192.168.0.x/wordpress, click in the box and change these to your systems full ip address (to find this open a web browser on a system within your network and do a google search for “whats my ip”) remember to put “/wordpress” at the end. Apply the settings and save. Your website should now be full visible from anywhere in the world (remember to set up port forwarding on your router)

    …now if like me the world hates you and apparently so does word press you will be locked out of the above steps and unable to change the urls. if this is the case start a new SSH session and run the following command,

    sudo nano /var/www/wordpress/wp-config.php

    somewhere near the bottom of the page you will be able to find the location of the site urls again, change these to your full ip address rather than your local ip address, again remember to put “/wordpress” at the end save and close.

    hopefully that will work for you all as it did for me.

    As they say the proof is in the pudding – http://www.rihdeesign.co.uk (site undergoing a redesign)

    Enjoy 🙂

    • Rob
      January 24, 2013 at 9:27 pm
      • Rob
        January 24, 2013 at 9:29 pm

        will also be putting up a stats page for the Pi for everyone to browse later

  10. Kevin
    March 10, 2013 at 3:27 am

    I’m getting “Error establishing a database connection” when loading the website??

    • March 10, 2013 at 3:22 pm

      The message, “Error establishing a database connection”, usually means one of two things:

      1. the MySQL Database is not working


      2. You have wrong information in your wp-config.php–either the DB_HOST, DB_USER, DB_PASSWORD, or DB_NAME is incorrect.

      So first do some basic checks on the Raspberry Pi setup

      1) Check that you have a PHPinfo webpage (you can see the PHP webpage)

      2) Chceck that the mysql is running correclty on your raspberry pi with the following command

      mysqladmin -u root -p ping and your MySQL root password which should result in “mysqld is alive”

      3) Double check Mysql database is setup correctly (point 5)

      4) check the wordpress configuration file (point 7)
      you will need to define the following
      DB_Name (as point 5)
      DB_User (as point 5)
      DB_password (as point 5)
      for example my wordpress server would be
      DB_name = wordpress
      DB_user = wordpress
      DB_password = Mysql password which in my example was raspi

      5) Reboot the Raspberry Pi with the following command “sudo reboot”

  11. The Editor
    April 27, 2013 at 1:16 am

    Thanks for sharing this. I am a Linux beginner almost at zero level but with your instructions I have a web server up and running with WordPress and it must have taken me less than 20 minutes!

  12. alex
    May 14, 2013 at 11:07 am

    Many thanks for main post, and for Rob who solved my second problem. However images are only displaying on my local network. This seems to be as uploaded images are still being given local IP addresses on their path – they work if I edit ip address manually. Is there any way to automatically change the path when uploading? Many thanks.

  13. KS
    June 28, 2013 at 2:11 am

    All goe’s well until I go to view the phpinfo web page it says 503 service not avalible but I can see the lighttpd page, I do hope you can help as i really want to get this working and get a site up and running, as you might be able to tell I am a bit of a linux noob but Iam learning fast

    Kind regards


  14. KS
    June 29, 2013 at 1:37 am

    I have now got the tutorial installed and up and running I dont know what I did wrong the first time, so thanks for a great tutorial and I now have a webpage to design, very easy to follow
    Kind regards

  15. June 29, 2013 at 1:38 am

    Reblogged this on Kevin Simpson .

  1. March 25, 2013 at 4:34 pm
  2. April 27, 2013 at 10:45 am
  3. August 23, 2013 at 3:28 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


The University of Glasgow's Raspberry Pi Project


Your all round solution for tech problems (and some others things...like spelling errors)

Raspberry Pi Kid

A 14-year old's adventures with Raspberry Pi

Naked Security

Computer Security News, Advice and Research

Grumpy IT Girl

I'm not a very good writer

Dustin Software

Because programming is fun!

Pinoy Tekkie



Fun stuff for technics enthusiasts

I Kissed My Date Goodnight

Embarking on motherhood through the miracle of adoption.


Tech, Gadgets, Photography, Social Media and Poor Spelling

Programming My Rasberry Pi

A brave fool's adventures into the unknown!

Chris Ainger's Blog

Where Fishing Meets Computing


Information wants to be free

ITtechExec: Protecting Tech Careers Since 2001

Technical Career Advancement: Transformed. Guaranteed.


Entertainment, Technology, Social Media Updates from in Between the Web…


An Exclusive Web 2.0 Startups Review Blog

The Life of Me

Just another IT blog


The Best Place for Deziners

%d bloggers like this: