Tuesday, 11 February 2014

Set up a Wordpress site on the Raspberry PI

Posted by Gary Newell  |  at  23:03 15 comments

Introduction

I have already written articles showing how to set up the Raspberry PI and how to set up a personal web server on the Raspberry PI.

I was recently asked whether I could expand further and show how to install Wordpress onto the web server.

To be able to follow this guide you will need to have set up your Raspberry PI and you will need to have PHP, MySQL, PHPMyAdmin and a web server such as Lighttpd or Apache installed. Follow the guide for setting up the personal web server linked above if you haven't already.


Create the Wordpress database

The first part you can do from any other computer on the same network as the Raspberry PI. Make sure the Raspberry PI is turned on and that you can connect to it as a web server. (Follow the guide about setting up a personal web server if you are unsure how to do this).

To create the Wordpress database open up a browser Window and navigate to PHPMyAdmin on the Raspberry PI. The address will be something like http://192.168.1.xxx/PHPMyAdmin. (Replace xxx with the last three digits that correspond to where your Raspberry PI is located).

Click on the databases tab at the top and where it says "create new database" add a new database with a name that relates to the purpose of your database. (For example "wordpress" or "piblog").

Set the collation sequence to the one that is most relevant for you. If in doubt choose utf8_general_ci.


Now you need to add a user that can interact with the database. Click on the "privileges" tab and click "add user".

For the username enter something like "piwordpress" and then enter your desired password into the password field and confirm that password in the re-type field.

Click "Create user" to add the user.

Click on "privileges" again and edit the user.

Now select "Check all" and save the changes. This gives your user permission to do anything on the database. (Not ideal for real world use by the way. For real world use you would restrict the access to the bare minimum required).

Connect to your Raspberry PI

First of all start up the Raspberry PI.

If you are connected directly to the Raspberry PI and you have booted straight to the Raspbian desktop open up a terminal by clicking on the LXTerminal icon.

If you are connected directly to the Raspberry PI but it boots direct to the terminal you can move on to the next section.

If you are connecting via ssh then open up the application you use to ssh and connect using your username and the local IP address to the PI. My guide showing how to connect to the Raspberry PI from the Google Nexus will help with this and will also show how to VNC onto the Raspberry PI.


Download Wordpress





















From within the terminal on the Raspberry PI run the following command to download Wordpress.

wget https://wordpress.org/latest.zip

Create the wordpress folders

Move the zip file to the /var/www folder by typing the following:

sudo mv latest.zip /var/www/latest.zip

Navigate to the /var/www folder:

cd /var/www

Now unzip the latest.zip file:

sudo unzip latest.zip

This will create a folder called wordpress under /var/www and will contain all the sub folders and files for running Wordpress.

You can now remove the latest.zip file:

sudo rm latest.zip

To gain the appropriate permissions to the wordpress folder you need to change the permissions of the folder as follows:

sudo chown -R pi:users wordpress

Navigate to the wordpress folder by typing the following:

cd wordpress

You now need to create a configuration file. The easiest way to do this is to take a copy of the sample Wordpress config file.

sudo cp wp-config-sample.php wp-config.php

Open the file wp-config in the nano editor:

sudo nano wp-config.php

 
You need to change various parts of the config file as follows:

  1. DB_Name - change to the name of the database you created
  2. DB_User - change to the name of the user you created
  3. DB_Password - change to the password you created for the user
You also need to add the various keys into the file where it says "put your unique key here".

Visit https://api.wordpress.org/secret-key/1.1/salt/

A list of keys will be generated for you and you can copy and paste the keys into the file replacing the keys that are already there.

Press CTRL and O and then CTRL and X to save and exit the file.

Install Wordpress




You can follow the rest of this from your own computer without being connected to the PI. (Although obviously it has to be turned on).

Open a browser and navigate to http://192.168.1.xxx/wordpress/wp-admin/install.php. (replacing xxx with the appropriate value).

Enter a title for your site and then add a username and password for your site. (This can and should be different to your database username and password).

Finally enter and email address and click "Install WordPress".

After the installation is complete you will see the screen above. Enter your username and password to access the Wordpress control panel.


Summary

That is pretty much it. You can add templates and plug ins and do everything you normally would within Wordpress.

If you want to see how your site looks simply open a new browser window and navigate to http://192.168.1.xxx/wordpress

Important:

This guide has been written as a proof of concept and because I was asked if I could write a guide for this.

I wouldn't recommend using this guide to set up your Raspberry PI as a production Wordpress server. Whilst the basics are correct, the setup of the database and the database user is lacking on the security front.

If you are a developer who creates Wordpress plugins and templates, you can now use your Raspberry PI to test out your creations.

I hope you find this guide useful and if you have any questions or the guide doesn't quite work for you let me know in the comments below and I will edit this article accordingly.

Thankyou for reading.

About the Author

Gary Newell started the Everyday Linux User blog in 2010 and has written reviews on dozens of different Linux based operating systems. He has also written a number of tutorials.

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post

Related posts

15 comments:

  1. Don't take this the wrong way but this looks very much like a standard Wordpress on Debian install. I'm not seeing any tweaking or adjusting to accommodate the memory constraints of the Pi or maximising it's capabilities given the Pi's weak processor.

    ReplyDelete
    Replies
    1. You are right. This is a bog standard installation. The whole thing is a proof of concept as to whether it will work or not. I added a caviat to say that you shouldn't use these instructions for production use but they could be useful to a developer wanting to test out templates and add-ons

      Delete
  2. I tryed this some time ago, it works, but it is slow, wery slow. As far I can see, its the PHP that slows it down.

    ReplyDelete
    Replies
    1. Change the graphical memory split to be less graphical thereby giving more resources to your server. Use lighttpd instead of Apache. You can also try the options for overclocking.

      Delete
  3. I found your blog quite interesting and the concern in the blog is really impressive. I always prefer to read the quality content and this thing I found in your post. Thanks for sharing.

    dj wallpapers

    ReplyDelete
  4. I cannot thank you enough. I've tried to install Wordpress under various tutorials and come across so many issues. This is the first one that actually worked. Thank you so much.

    ReplyDelete
    Replies
    1. Glad to hear it. Thanks for letting me know

      Delete
  5. Hey Gary
    This was a really fun post. The Raspberry Pi knows no limits :) Anyway, I thought this would be of value to our blog readers, so I included it in my roundup of the month's best Magento, WordPress, and ExpressionEngine content. http://blog.nexcess.net/2014/03/04/februarys-best-expressionengine-wordpress-magento-content/ Thanks for the nice work.

    Ben

    ReplyDelete
  6. First available with WordPress Edition 2.8, this design tag profits the information of a tag. A tag ID can be approved as a parameter, but if no tag ID is approved, the information present queried tag will be came back.Because WordPress connections with this data source by itself, you as an end customer, shouldn't have to fear much about its framework.

    ReplyDelete
  7. This is a great tutorial however I had hoped to see steps in setting up the FTP so that you can install/update plugins form the Wordpress control panel. any chances to adding a tutorial for that?

    ReplyDelete
    Replies
    1. I got it to work with this command

      sudo chown -R www-data.www-data /var/www/MY_DIR

      Delete
    2. I was about to say yes I will write a tutorial for that but then it seems you have already achieved your aim.

      Delete
    3. Can you talk me through how I would set up the FTP settings so I could edit the site through Dreamweaver for example? Thanks

      Delete
    4. Hi, I will see what I can do and will get back to you in the near future.

      Delete
  8. hi, thanks for the tutorial,
    when i get to ; Open a browser and navigate to http://192.168.1.xxx/wordpress/wp-admin/install.php. i got a 404 - not found.
    I can't find out what i did wrong, any idea?

    ReplyDelete

Feel free to comment on any of the blog posts. Please try to be constructive.

Offensive messages will be removed as will blatant adverts for misleading products and sites.

Thanks for visiting my blog

    Popular Posts

    Total Pageviews

    Subscribe

    Enter your email address:

    Delivered by FeedBurner

    Popular This Month

    What are other people buying?

    Ubuntu Buy
    Linux Mint Buy
    Puppy Buy
    Netrunner Buy
    Zorin OS Buy
    Debian Buy
    Robolinux Buy
    CentOS Buy
    Linux Lite Buy
    Manjaro Buy
    Bodhi Buy
    Kali Buy
    Simplicity Buy
    PCLinuxOS Buy
    Tails Buy
    Rocks Cluster Buy
    openSUSE Buy
    Lubuntu Buy
    Fedora Buy

    Followers

    Feedburner Followers

Blogger templates. Proudly Powered by Blogger.
back to top Google