topamax once a day

WordPress on Raspberry Pi

  

This tutorial will demonstrate how to install and host WordPress on Raspberry Pi. This process assumes you have Debian for Raspberry Pi installed on an SD card. If not, see RPi Easy SD card setup.

Install Apache

WordPress runs on the Apache2 web server. To setup Apache, follow the instructions in my previous post, Raspberry Pi and Apache.

Install MySQL and PHP

Begin by installing the required dependencies. From a terminal:

sudo apt-get install mysql-server-5.5 php5 php5-mysql php5-gd

Next run the MySQL init script:

sudo mysql_install_db

Download and Extract WordPress

Download the latest wordpress source files

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

Extract the downloaded archive:

tar -xvzf latest.tar.gz

Create a directory in /var/www for the WordPress install:

sudo mkdir /var/www/wordpress

Copy over the extacted files:

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

Configure Apache

Next, make a backup of the apache config file, then open it in a text editor:

sudo cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.bak
sudo vim.tiny /etc/apache2/apache2.conf

Add this line to the end of the file:

AddType application/x-httpd-php .html

And restart Apache

sudo /etc/init.d/apache2 restart

Configure MySQL

The next step is to configure MySQL for use with WordPress. WordPress needs a database and user, and permissions set correctly for access. Start the mysql config:

mysql -u root -p

Enter the root MySQL password, then arrive at the mysql prompt

mysql>

Create a database for WordPress, create a user for the database, and set password set the permissions:

CREATE DATABASE wordpress;
CREATE USER wordpressuser;
SET PASSWORD FOR wordpressuser= PASSWORD(“1234″);
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser IDENTIFIED BY ’1234′;
FLUSH TABLES;

Then quit the MySQL client:

exit

Now create a new wordpress configuration based on the sample:

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

And open it up for edit in an editor:

sudo vim.tiny /var/www/wordpress/wp-config.php

Change this:

/** The name of the database for WordPress */
define(‘DB_NAME’, ‘database_name_here’);

/** MySQL database username */
define(‘DB_USER’, ‘username_here’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password_here’);

to this (substituting password_here with your own from above):

/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wordpress’);

/** MySQL database username */
define(‘DB_USER’, ‘wordpressuser’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password_here’);

Finalizing the install

The hard part is over! Now open up a browser and head to the site and finalize the install. To do this, navigate from a browser on another machine on your local network, only substitute the local address of the Raspberry Pi. To find the address of the Raspberry Pi, open a terminal and run:

ifconfig

Then navigate to that address with a trailing /wordpress from a browser on the same local network:

http://192.168.1.100/wordpress

 

48 Comments

  1. Nice writeup! I’ve gone through this process recently myself. How does the server hold up to more than minimal traffic? I’ve been thinking about setting up an image with WordPress, nginx, and Sqlite as a low-memory alternative.

    • I haven’t tried with nginx or sqlite myself, but I suspect it will be an improvement over the full fledged apache/mysql install!

  2. Thanks for the explanation. Followed your guide and got WordPress working, although it does seem to ‘lock-up’ easily, needing a restart of the RasPi. How stable do you think it is?

    • Hi James,
      I was experiencing the lock-up issue as well. I’m looking into some options with the memory split, or caching to improve the stability!

  3. Thank you. I can confirm that it works on my Pi with a Sandisk Class 10 Ultra SD (16GB). Serves pages fine. Install only possible remotely. Having issues with ‘lockup’ when using backend to edit content.

    • Hi Brad, thanks for the feedback. My experience with backend editing also sometimes seems to ‘lockup’. I’m going to try with nginx and see if it fares better than apache.

  4. when I tried to copy extracted files(sudo cp -r ~/wordpress/* /var/www/wordpress) it keeps giving me error….or asking me to go to –help…for cp command…what am I doing wrong? Need help please.

    • Hi Rafael, the most likely cause is the wordpress archive is not in the assumed location. The command assumes you have downloaded and extracted the archive to the home directory of the pi user, if you have extracted it somewhere else, you will need to adjust accordingly. Try the cp command with fully qualified paths (update to match your location):

      sudo cp -r /home/pi/wordpress/* /var/www/wordpress
  5. you know what….that did it beautifully….thanks a million…

  6. I find that the mysql user creation section above doesn’t work – after doing it attempting to log in as wordpressuser gives and access denied.

    Instead of the three lines (CREATE USER, SET PASSWORD and GRANT ALL), I found the following single line worked:

    GRANT ALL on wordpress.* TO wordpressuser@localhost IDENTIFIED BY ‘password’;

    • Laurent Mahé

      Thanks Jon

      I had the “error establishing a database connection” error message.

      Your suggestion solved my problem beautifully :)

      • I had same problem using 2012-10-28-wheezy-raspbian.zip image
        I had also done a
        sudo apt-get update
        sudo apt-get upgrade
        this was 7 November 2012

        your use of @localhost in the user ID fixed the problem

        mysql -u root -p
        GRANT ALL on wordpress.* TO wordpressuser@localhost IDENTIFIED BY ‘password’;
        flush tables;
        exit

        then connected to web page and all worked!

        ===
        Michael, great tutorial/recipe thank you!

        • This too was my most troublesome section. I found manually typing the commands instead of cut/paste helped here.

          CREATE DATABASE chimps;

          mysql> use chimps

          mysql> create user newuser

          mysql> set password for newuser=password(“xxxxx”);

          mysql> grant all privileges on chimps.* to newuser;

          mysql> flush tables;

          Otherwise great writeup. I usually use XAMPP but it doesn’t work on ARM processors I read.

    • I too had the “error establishing a database connection” error. The above provided by Jon solves it. Cheers mate.

    • Paul Barrett

      This also work for me

  7. Hey this is great! I’m a big Raspberry Pi fan myself. WordPress would be a fun project to put on the Raspi, and it also helps those of use who are just looking to install something like MySQL and PHP.

  8. Cool but for me, I can’t install MySQL and PHP. It say:
    “Some packages could not be installed. This may mean that you have an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or ben moved out of Incoming.
    The following information may help to resolve the situation:

    The following packages have unmet dependencies
    mysql-server-5.1 : Depends: mysql-client-5.1 (>= 5.1.62-1) but it is not going to be installed
    Depends: libmysqlclient16 (>= 5.1.50-1) but it is not going to be installed
    PreDepends: mysql-common (>= 5.1.62-1) but it is not going to be installed
    php5-mysql : Depends: libmysqlclient18 (>= 5.5.24+dfsg-1) but it is not going to be installed
    E: Unable to correct problems, you have held broken packages.”

    I have the last RaspBian image with the last firmware. I made some apt-get update and upgrade but it didn’t change anything.

    • Looks like the newest version of Raspbian has updated the mysql-server-package. Instead of:
      sudo apt-get install mysql-server-5.1 php5 php5-mysql php5-gd
      Use this instead:
      sudo apt-get install mysql-server-5.5 php5 php5-mysql php5-gd
      Thanks for pointing this out… I have updated the article as well!

      • Just use mysql-server without the version number and it will get the latest one.

  9. Hi Michael,

    i have a problem, when I follow your tutorial everything went well except when I try to open the website (the apache page works fine). I get a HTTP-500 error. Can you help me with this?

    • You need to go into your site from your localhost and edit the site URL under settings -> general. Once you update that you will be able to see all your content externally.

  10. Lunatic4ever

    No lockups and using apache with php-apc and apc backend plugin! Works very well!!

  11. I have an interesting problem. If I connect to the server from the localhost I get a correctly formatted webpage. If I connect to it from anyone inside or outside of my network I don’t get graphics. and If I try to login via the login page it gets redirected to 127.0.0.1/wp-login.php which fails. any ideas?

    • hostname lookup problem

      • i have this problem too, would you mind giving a little more advice towards a soloution?

        • i have now fixed this problem, open wordpress admin panel navigate to settings and change the site url and other url from your local ip 192.168.x.x/wordpress to your full ip/wordpress (to find this google search whats my ip) if like me for some reason you can not change the two urls, start a session on the pi terminal, sudo nano var/www/wordpress/wp-config.php

          locate the two ip addresses in their and change as appropriate, save and close.

          job done. enjoy :)

  12. Good write up!
    I had several things that needed to be worked out.
    I could not add or delete to the “FTP” in wordpress, it was a permissions issue.
    sudo chown -R www-data:www-data*

    To log into the FTP I had to use.
    Domain:wordpress
    FTPuser:’SQLuser’@localhost
    FTPpass:’SQLuser’ password’

    Also I developed the site on one RasPi and put it up on another. WordPress really did not like this as it was using the internal IP as it location. When I moved it over I lost the site until I installed phpMyAdmin so I could edit the database and get it back. The settings for the site URL had to be right or it was really slow or not accessible at all. I was using dyndns.

    WordPress Address :your.dyndns.tv/wordpress
    Site Address :your.dyndns.tv

    I hope this helps others get their RasPii up on wordpress!

  13. Hi,
    I’m getting an error : “Error establishing a database connection”
    Any suggestion ?

  14. Yeah i get the same problem and i really want to sort it!

  15. Great blog, thanks for sharing it with us. Now following you, you maybe also interest in looking at my WordPress blog also.

  16. :( followed to a T but get the same “Error establishing a database connection”

    • GRANT ALL PRIVILEGES ON wordpress.* TO “user”@”localhost”IDENTIFIED BY “password”;
      solved the “Error establishing a database connection” for me!

  17. It got a little confusing with the code sections of the posts in italics — I missed some spaces in the syntax and I’m a Linux n00b. Had the database connection problem too, so I just jumped in PHPMyAdmin (I’d previously installed) and set the user and permissions in the GUI. MUCH easier. Thanks for the post! My pi is serving up WP!

  18. Christopher

    Hello, I got a problem when I’m traying to setup a wordpress on my raspberry pi.
    I get this message:

    mysql> SET PASSWORD FOR wordpressuser2= PASSWORD(“1234″);
    ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘“1234″)’ at line 1

    • Hi There. I have had exact same problem occurred me. You simply use single quote (‘) rather than using double (“) will fix a problem.
      GRANT ALL PRIVILEGES ON wordpress.* TO ‘wordpressuser’@’localhost’ IDENTIFIED BY ’1234′;

  19. If i want to open: “http://ipoftheraspberrypi/wordpress” it sais an error: “Error establishing a database connection”

    pls help

  20. Benny Widing

    Same here, Error establishing a database connection”.
    Should i use internal IP-adress on “localhost”
    or raspberrypi..or just leave it as it is?

  21. Gordon

    Great tutorial, thank you!! My first attempt, I was getting the “database connection error”. I had to improve my Linux text editing skills (I used Nano) to learn how to ‘save’ my changes (CTRL and O) in the wp-config.php file. Once WP knew what to look for and the password, I was in business.

    Thanks again. I would have NEVER figured all this out on my own.

  22. Pi in the sky

    Reading the thread and the issues by those trying got me going so far but I’m having the FTP issue. The database issue was difficult , it was easier opening it in leaf pad and saving a copy – vim.tiny is hard for amateurs and almost impossible if you ssh in from a terminal on an iPhone ! Could anyone clear up the FTP issue for ” Failed to connect to FTP server WordPress:21 ” ? I think that maybe my last hurdle for this WordPress on a pi tia

    • Pi in the sky

      Aha ! My problem was the ownership of /var/www/—-incorrect — something like
      “sudo chown www-data.www-data /var/www/my install place

  23. Gene Shiau

    Thank you! This was an easy-to-follow instruction, especially because I didn’t want to have to install phpmyadmin (which other tutorials often use). After the installation I ran into an error when browsing to my Raspberry Pi:

    “Neither /etc/wordpress/config-192.168.1.101.php nor /etc/wordpress/config-168.1.101.php could be found.”

    I imagine that I wasn’t the only person experiencing this issue. To address this, I would suggest a change to the “create a new wordpress configuration based on the sample” procedure (after quitting the MySQL client):

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

    Then use the following command to to edit this config file:

    sudo vim.tiny /var/www/wordpress/config-default.php

    • I after I did everything, I went to my other computer and used the local ip with /wordpress attached at the end only to get a big white page with “Error establishing a database connection”.

      Help please :)

  24. How can I use this with my domain (not on example.com/wordpress but just on example.com? How do I set up the DNS and which port do I need to fordward?

Trackbacks/Pingbacks

  1. Zerbitzari banatu txertatuak | txertatuak - [...] montatzea izan daiteke. Nik neuk Raspberry Pi baten gainean wordpress blog bat muntatu dut (gida hau erabilita), blog honen …
  2. Wordpress for Raspberry Pi using Nginx and MySQL | CNXSoft – Embedded Software Development - [...] been wondering how the Raspberry Pi would handle WordPress. I’ve found some instructions using Apache 2, but this may …
  3. Raspberry Pi ลง WordPress, Nginx, FastCGI, MySQL | Raspberry Pi Thailand - [...] ที่มา http://www.cnx-software.com/2012/08/03/wordpress-for-raspberry-pi-using-nginx-and-mysql/ http://mitchtech.net/wordpress-on-raspberry-pi/ [...]
  4. WordPress on Raspberry Pi « Logbook - [...] Blog: http://mitchtech.net/wordpress-on-raspberry-pi/ [...]
  5. Random Links of the week | Raspberry PI Community Projects - [...] WordPress on Raspberry Pi | MitchTech [...]
  6. Finally, Putting the Raspberry Pi [RPi] to some use! | The Second Try - [...] working, hence it was back to Google and browsing pages, after a while I found one that suited me, …
  7. Getting Started With The Raspberry Pi Is Not As Easy As Pie | TechCrunch - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  8. NerdSites.com – Getting Started With The Raspberry Pi Is Not As Easy As Pie - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  9. Houston Outsource: Get Tech News Now! Getting Started With The Raspberry Pi Is Not As Easy As Pie | Houston Outsource: Get Tech News Now! - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  10. Getting Started With The Raspberry Pi Is Not As Easy As Pie | Easy Nulled Script - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  11. Getting Started With The Raspberry Pi Is Not As Easy As Pie | Crowdfunding News - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  12. Getting Started With The Raspberry Pi Is Not As Easy As Pie | Krantenkoppen Tech - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  13. Getting Started With The Raspberry Pi Is Not As Easy As Pie | DailyBusinessNews.comDailyBusinessNews.com - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  14. Getting Started With The Raspberry Pi Is Not As Easy As Pie | Hosting In - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  15. Getting Started With The Raspberry Pi Is Not As Easy As Pie « Mr Gee - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  16. GIASTAR – Storie di ordinaria tecnologia » Blog Archive » Getting Started With The Raspberry Pi Is Not As Easy As Pie - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  17. Getting Started With The Raspberry Pi Is Not As Easy As Pie | blog seo tips and tricks - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  18. Getting Started With The Raspberry Pi Is Not As Easy As Pie | download free music to mp3download free music to mp3 - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  19. Getting Started With The Raspberry Pi Is Not As Easy As Pie : Blog - [...] was means to implement PHP. You can run a web server or a media server from a Raspberry Pi. …
  20. Getting Started With The Raspberry Pi Is Not As Easy As Pie | Tech Is Geeky - [...] was able to install PHP. You can run a web server or a media server from the Raspberry Pi. …
  21. Install WordPress on Cubieboard(with APM) | Dev. - [...] 설치 참고 : http://mitchtech.net/wordpress-on-raspberry-pi/ [...]
  22. Wordpress on the Raspberry Pi | PYoung.net - [...] Well, sort of.  Still playing around with the DNS settings at my domain name host as the url isn’t …
  23. Bringing up the webserver on a Raspberry Pi | Greenhouse News - [...] then searched for ‘raspberry pi install wordpress’ and looked at the top hit. That worked, but note there is …
  24. The Boghallpi | Boghallpi.com/dads - [...] like this is what we used for these [...]
  25. Na endlich!! | blög - [...] jetzt hab ichs endlich geschafft: wordpress läuft aufm pi. wesentlich geholfen hat http://www.forum-raspberrypi.de/Thread-tutorial-raspberry-pi-als-webserver-apache-2-installation und besonders: http://mitchtech.net/wordpress-on-raspberry-pi/ [...]
  26. blög – Verbinden der Datenbank mit Wordpress - […] via WordPress on Raspberry Pi | MitchTech. […]
  27. Install WordPress on Raspberry Pi | JohnyLuky - […] Make sure to visit his post here ! […]
  28. T-E-M-T – I didn’t name it…. | George's Portfolio - […] DB didn’t have a tutorial up at that point (Noooo…) So I followed this one from MitchTech. I did, …
  29. Install WordPress Blog on Raspberry Pi | Mi Block de Notas - […] http://mitchtech.net/wordpress-on-raspberry-pi/ […]
  30. Host your own wordpress site! | Garys blog - […] Does not have to be a Raspberry Pi ! – http://mitchtech.net/wordpress-on-raspberry-pi/ […]
  31. WordPress for Raspberry Pi using Nginx and MySQL | vienergie - […] been wondering how the Raspberry Pi would handle WordPress. I’ve found some instructions using Apache 2, but this may …
  32. Trying to install a theme with WordPress (FTP Failing) | Zimmerly Answers - […] After that, we total WordPress onto a small server controlling this tutorial: http://mitchtech.net/wordpress-on-raspberry-pi/ […]

Leave a Reply