Set up a web server on your Pi and install WordPress


Set up a web server on your Pi and install WordPress, a content management system that makes creating websites easier


Apache is a popular web server application you can install on the Raspberry Pi to allow it to serve web pages.

On its own, Apache can serve HTML files over HTTP, and with additional modules can serve dynamic web pages using scripting languages such as PHP.


First install the apache2 package by typing the following command into the terminal:

sudo apt-get install apache2 -y


By default, Apache puts a test HTML file in the web folder. This default web page is served when you browse to http://localhost/ on the Pi itself, or (whatever the Pi’s IP address is) from another computer on the network. To find out the Pi’s IP address, type hostname -I at the command line (or read more about finding your IP address) in our documentation.

Browse to the default web page, either on the Pi or from another computer on the network, and you should see the following:

This means you have Apache working!


This default web page is just an HTML file on the filesystem; it is located at /var/www/index.html. Navigate to this directory in the terminal and have a look at what’s inside:

cd /var/www
ls -al

This will show you:

total 12
drwxr-xr-x  2 root root 4096 Jan  8 01:29 .
drwxr-xr-x 12 root root 4096 Jan  8 01:28 ..
-rw-r--r--  1 root root  177 Jan  8 01:29 index.html

This shows that there is one file in /var/www/ called index.html. The . refers to the directory itself /var/www/, and the .. refers to the parent directory /var/.

The 3rd column shows that, by default the www directory and index.html file are both owned by the root user. In order to edit the file, you must gain root permissions. Either change the owner to your own user before editing (using sudo chown pi: index.html), or edit with sudo (using sudo nano index.html).

Try editing this file and refreshing the browser to see the web page change. Press Ctrl + X and hitEnter to save and exit.


PHP is a preprocessor; it’s code that runs when the server receives a request for a web page. It runs, works out what needs to be shown on the page, then sends that page to the browser. Unlike static HTML, PHP can show different content under different circumstances. Other languages are capable of this, but since WordPress is written in PHP, that’s what we need to use this time. PHP is a very popular language on the web; large projects like Facebook and Wikipedia are written in PHP.

Install the PHP and Apache packages with the following command:

sudo apt-get install php5 libapache2-mod-php5 -y


Create the file index.php:

sudo nano index.php

Put some PHP content in it:

<?php echo "hello world";

Now save the file. Next delete index.html because it takes precendence over index.php:

sudo rm index.html

Refresh your browser. You should see “hello world”. This is not dynamic but it is still served by PHP. Try something dynamic, for example:

<?php echo date('Y-m-d H:i:s');

Or show your PHP info:

<?php phpinfo();


MySQL (pronounced My Sequel or My S-Q-L) is a popular database engine. Like PHP, its overwhelming presence on web servers enhanced its popularity. This is why projects like WordPress use it, and why those projects are so popular.

Install the MySQL Server and PHP-MySQL packages by entering the following command into the terminal:

sudo apt-get install mysql-server php5-mysql -y

When installing MySQL you will be asked for a root password. You’ll need to remember this to allow your website to access the database.


You can download WordPress from using the wget command. Helpfully, a copy of the latest version of WordPress is always available at, so you can grab the latest version without having to look it up on the website. At the time of writing, this is version 4.0.

Navigate to /var/www/, and download WordPress to this location. You’ll need to empty the folder first (be sure to check you’re not deleting files you need before running rm); change the ownership of this folder to the pi user too.

cd /var/www
sudo chown pi: .
sudo rm *

Now extract the tarball, move the contents of the folder it extracted (wordpress) to the current directory and remove the (now empty) folder and the tarball to tidy up:

tar xzf latest.tar.gz
mv wordpress/* .
rm -rf wordpress latest.tar.gz

Running the ls or (tree -L 1) command here will show you the contents of a WordPress project:

├── index.php
├── license.txt
├── readme.html
├── wp-activate.php
├── wp-admin
├── wp-blog-header.php
├── wp-comments-post.php
├── wp-config-sample.php
├── wp-content
├── wp-cron.php
├── wp-includes
├── wp-links-opml.php
├── wp-load.php
├── wp-login.php
├── wp-mail.php
├── wp-settings.php
├── wp-signup.php
├── wp-trackback.php
└── xmlrpc.php

This is the source of a default WordPress installation. The files you edit to customise your installation belong in the wp-content folder.


To get your WordPress site set up, you need a database. Run the mysql command in the terminal and provide your login credentials (e.g. username root, password password):

mysql -uroot -ppassword

Here I have provided my password (the word password) on the command line; there is no space between -p and your password.

Alternatively you can simply supply an empty -p flag and wait to be asked for a password:

mysql -uroot -p

Now you will be prompted to enter the root user password you created earlier.

Once you’re connected to MySQL, you can create the database your WordPress installation will use:

mysql> create database wordpress;

Note the semi-colon ending the statement. On success you should see the following message:

Query OK, 1 row affected (0.00 sec)

Exit out of the MySQL prompt with Ctrl + D.


You need to find out your Pi’s IP address to access it in the browser, so in a terminal type the command hostname -I.

Navigate to http://YOUR-IP-ADDRESS e.g. in the web browser on your Pi.

You should see a WordPress error page; this is good! Click the big button marked Create a Configuration File followed by the Let's go! button on the next page.

Now fill out the basic site information as follows:

Database Name:      wordpress
User Name:          root
Password:           <YOUR PASSWORD>
Database Host:      localhost
Table Prefix:       wp_

Upon successful database connection, you will be given the contents of your wp-config.php file:

Copy this text, return to the terminal on the Pi and edit the file with nano wp-config.php. Paste the text into this file, and save and exit with Ctrl + X, then Y for yes and Enter.

Now hit the Run the install button.


Now you’re getting close.

Fill out the information: give your site a title, create a username and password, put in your email address and untick the search engines box. Hit the 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 IP address in the browser on the Pi or another computer on the network. To log in again (or on another computer), go to http://YOUR-IP-ADDRESS/wp-admin.


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 thePost name option and click Save Changes. After saving, you will be prompted to update your.htaccess file. You probably don’t have one yet, so add one in /var/www/ by typing nano .htaccess; note this is a hidden file, so it starts with a dot. Then paste in the contents provided:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Save the file and return to the website homepage. Click on the post title or the sample page link and you’ll probably see a Not Found error page. This is because the rewrite module has not been enabled in Apache. To do this, enter sudo a2enmod rewrite.

You’ll also need to tell the virtual host serving the site to allow requests to be overwritten. Do this by editing the virtual host file (with root permissions): sudo nano /etc/apache2/sites-available/default; also, change the AllowOverride setting on line 11 (inside the <Directory /var/www/> block) from None to All. Save the file and then restart Apache with sudo service apache2 restart. Once it’s restarted, refresh the page and it should load successfully. Now posts have URLs like /hello-world/ instead of /?p=123, and pages have URLs like /sample-page/instead of /?page_id=2.


WordPress is very customisable. By clicking your site name in the WordPress banner along the top of the page (when logged in), you’ll be taken to the Dashboard. From here you can change the theme, add pages and posts, edit the menu, add plugins and lots more. This is just a taster for getting something interesting set up on the Raspberry Pi’s web server.

Posted in apache, html, http, mysql, php, Raspberry PI, Raspian, server, setup, web, Wordpress, www | Leave a comment

Recovering from GRUB rescue prompt – Dual boot problems – Linux Mint/Ubuntu

I’ve found out that you can get this grub rescue prompt error from dual booting from a single drive containing two or more Operating Systems or having two or more hard drives each containing a separate OS and using a selector switch to select between them.

The easiest way to solve dual boot problems is to use Boot-Repair (IMHO).

What is Boot-Repair?

Boot-Repair is a simple tool to repair frequent boot issues you may encounter in Linux Mint/Ubuntu like when you can’t boot Linux Mint/Ubuntu after installing Windows or another Linux distribution, or when you can’t boot Windows after installing Linux Mint/Ubuntu, or when GRUB is not displayed anymore, some upgrade breaks GRUB, etc.

Installation and use:

  • Boot into Ubuntu or Linux Mint Live CD or USB

  • Open terminal and run following commands:

    sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
    sudo apt-get install -y boot-repair && boot-repair
  • Once done Boot-Repair will open with two options choose the first option (Recommended repair).

    enter image description here

  • When repair is finished, Save the URL that appeared, Then reboot.

    enter image description here

  • If the repair didn’t succeed, Share the URL on askubuntu, Linux Mint forum or any other help forum for more help.

Posted in Boot-Repair, Dual boot, grub, linux, Linux Mint, Ubuntu | Leave a comment

How to prevent the GRUB menu from showing up in the beginning of boot?

You need to edit the file at /etc/default/grub to prevent showing the grub menu.

By default, the entries in that files look like this.

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
  • Remove the # mark from second line, and

After changes, the required portion of the file will look like this

GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
  • Then run sudo update-grub command in the terminal, and reboot to see the result.
Posted in boot, grub, linux, Linux Mint, Ubuntu | Leave a comment

How to make Ubuntu and Linux Mint ready to play encrypted Blu-Ray’s on VLC and XBMC

This tutorial guide is applicable for Ubuntu, Linux Mint and also applies to any Debian based distro.
For other Linux distros please substitute apt-get for your package manager.

Install Instructions:
bash 5249

During the installation you have the option to install the latest version of VLC media player. To complete the installation you have to reboot your machine. When you have completed the installation process you are able to play Blu-Ray’s but not to trans-code them. Using the VLC media player you can run encrypted Blu-Ray’s by choosing BluRay as “Disc Selection” (check box “No disc menus”) and by selecting the related disk drive.

Posted in Blu-Ray, linux, Linux Mint, Ubuntu, VLC, XBMC | Leave a comment

Automount drive(s) in Linux Mint and Ubuntu

This is a typical display of etc/fstab showing an automount of one drive


Here’s how to automount a drive:

1) First, open up terminal, and determine what type of drive format it is:
Code Sample:

  1. sudo blkid

With a second hard drive, it’ll most likely be /dev/sdb1 or something around there.  If you’ve labeled your drive, chances are it’ll say LABEL=”your label”.  Note the TYPE=”xxxx”, which will determine which of the following you’ll use.  In my example for my secondary hard drive:

/dev/sdb1: LABEL="Storage" UUID="92DEADA8DEAD8557" TYPE="ntfs"

2) Now you’ll make your directory for your new mount.  I like to keep the name of the folder the same as the drive label, but you can name it whatever you want.

Code Sample:

  1. sudo mkdir /media/Storage

3) Now open up your fstab…

Code Sample:

  1. sudo gedit /etc/fstab

4) And depending on your drive type, follow only the appropriate one:

*NOTE* It doesn’t show up correctly here, but there is a tab where every space is.  This is important!  Copy-paste from here won’t give you exactly what you need, so simply delete each space and TAB once.

/deb/drive     /media/location     type     defaults     0     0

Also, make sure you replace “/dev/sdxx” with your drive (such as “/dev/sdb1″) and the “/media/xxxxx” with your same directory name you did above (such as “/media/Storage”). Where xxxxx is, you can name it anything you want to identify the drive with.

Code Sample:

  1. /dev/sdxx /media/xxxxx ntfs defaults,umask=007,gid=46 0 0

Code Sample:

  1. /dev/sdxx /media/xxxxx vfat umask=0000,uid=1000,gid=1000,auto,rw,users 0 0

Code Sample:

  1. /dev/sdxx /media/xxxxx ext3 defaults,noatime 0 2

Here is an example of  etc/fstab displaying two automount drives





Posted in automount, drives, linux, Linux Mint, Ubuntu | Leave a comment

Why use apt-get upgrade versus apt-get dist-upgrade?

Typically I upgrade my machines with:

sudo apt-get update && time sudo apt-get dist-upgrade

Below is an excerpt from man apt-getUsing upgrade keeps to the rule: under no circumstances are currently installed packages removed, or packages not already installed retrieved and installed. If that’s important to you, use apt-get upgrade. If you want things to “just work”, you probably want apt-get dist-upgrade to ensure dependencies are resolved.

To expand on why you’d want upgrade instead of dist-upgrade, if you are a systems administrator, you need predictability. You might be using advanced features like apt pinning or pulling from a collection ofPPAs (perhaps you have an in-house PPA), with various automations in place to inspect your system and available upgrades instead of always eagerly upgrading all available packages. You would get very frustrated when apt performs unscripted behavior, particularly if this leads to downtime of a production service.

    upgrade is used to install the newest versions of all packages
    currently installed on the system from the sources enumerated in
    /etc/apt/sources.list. Packages currently installed with new
    versions available are retrieved and upgraded; under no
    circumstances are currently installed packages removed, or packages
    not already installed retrieved and installed. New versions of
    currently installed packages that cannot be upgraded without
    changing the install status of another package will be left at
    their current version. An update must be performed first so that
    apt-get knows that new versions of packages are available.

    dist-upgrade in addition to performing the function of upgrade,
    also intelligently handles changing dependencies with new versions
    of packages; apt-get has a "smart" conflict resolution system, and
    it will attempt to upgrade the most important packages at the
    expense of less important ones if necessary. So, dist-upgrade
    command may remove some packages. The /etc/apt/sources.list file
    contains a list of locations from which to retrieve desired package
    files. See also apt_preferences(5) for a mechanism for overriding
    the general settings for individual packages.


The upgrade option only installs new version of the packages that are already installed on the system (and yes, kernel updates belong to them).

However, sometimes the updates change dependencies: for example, a new version of a package will no longer depend on a library that you have installed, or will require installation of additional libraries. Theupgrade option will never remove installed packages that you no longer actually need.

However, the dist-upgrade option can “intelligently” handle changes in the dependencies system. This includes removing packages that are no longer necessary or resolve conflicts between packages that arose because of changes in the dependencies.

Posted in linux, Linux Mint, Ubuntu, update, upgrade | Leave a comment

Repair Linux Mate Desktop

You go to start Linux Mint and you get a black screen with a terminal session. You may also find that X server won’t start and when you try to choose Mate from the desktop session you notice it’s missing. This could mean that that your Mate desktop is damaged.

I installed mate-core and rebooted and my desktop returned.

Install MATE packages

Choose one of these:

  • Install base packages only

    Run in Terminal:

    sudo apt-get install mate-core

This may work also

  • Install more (complete) packages

    Run in Terminal:

    sudo apt-get install mate-desktop-environment
Posted in desktop, linux, Linux Mint, Mate, repair, Ubuntu | Leave a comment

Speed up Linux Mint and Ubuntu

A tutorial to speedup/boost/optimize Linux Mint/Ubuntu by using some optimizations and enhancements.

1. To edit /etc/sysctl.conf in your fav Text Editor (in root mode) and update the line (or add)

Save the file.

2. Install the app: preload by using the following in terminal

sudo apt-get install preload

3. (For power users) Switch /tmp directory to RAM instead of disk.
Edit /etc/fstab in your favourite text editor (in root mode). Add the following line at the end.

none /tmp tmpfs defaults,size=512m 0 0

4. Disable superfluous GUI animations in Mate/Gnome etc. using the configuration editor which would be compatible with your desktop environment. Some examples are dconf-editor for MATE, gconf-editor for GNome etc.

Posted in boost, linux, Linux Mint, speed up, Ubuntu | Leave a comment

Boost your internet connection in Linux and Ubuntu

IPV6 is an Internet protocol. Currently most applications use IPV4 and this can cause conflicts which slow down your system.
Complete the following to disable it.

sudo gedit /etc/modprobe.d/bad_list

and type this in:

alias net-pf-10 off

Then save the file.

Speed up Broadband Internet by editing the appropriate configuration file and adding the following information. – Or, you can use a tool called PowerTweak from

sudo gedit /etc/sysctl.conf

The first four line deal with window size and you need to enter numbers that are best for you (because these ones may be too high). Here is what I mean by this:
Computers communicate by sending packets of data back and forth. When they connect with each other to send these packets they use the TCP (Transmission Control Protocol).

Your computer could begin the connection with a small package size, then the other computer might respond with a larger one. In turn your computer will reduce (scale down) the size of the package (to a bit more that your original package size). The other computer again responds with a larger packet size. This cycle continues until your computer or the responding computer meets their maximum package size.

If you choose a windows packet size that is too big, you will notice slower broadband performance (524288 works for me). If you notice a slow down, then reduce your window size.
The largest size you can use is 65536, however these are the three settings that seem to work best:

Which are all multiples of 1024 (or 1K).
Now add the following to the end of the file:

net.core.rmem_default = 524288
net.core.rmem_max = 524288
net.core.wmem_default = 524288
net.core.wmem_max = 524288
net.ipv4.tcp_wmem = 4096 87380 524288
net.ipv4.tcp_rmem = 4096 87380 524288
net.ipv4.tcp_mem = 524288 524288 524288
net.ipv4.tcp_rfc1337 = 1
net.ipv4.ip_no_pmtu_disc = 0
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_ecn = 0
net.ipv4.route.flush = 1

After adding these line you do not need to reboot, instead just reset the file by issuing this command:

sudo sysctl -p

After completing this, you should notice improved web surfing speed. If not, remember to go back and adjust your TCP window size and try again.

Posted in boost, interenet, linux, Linux Mint, speed, Ubuntu | Leave a comment

How to install LAMP: A WAMP-like package for Ubuntu/Linux Mint


This should get you set up straight away.

sudo apt-get install lamp-server^

What does caret (^) in an apt-get command mean?

Testing Apache

Open a web browser and enter the address http://localhost. You should see a webpage displaying the text “It Works!”

Apache - It Works

Testing PHP

To test our PHP installation we need to create file called info.php in /var/www. Open Terminal and enter:

sudo gedit /var/www/info.php

Enter the line below, save the file, and exit the text editor.



Restart apache

sudo /etc/init.d/apache2 restart

Now, open your browser and enter http://localhost/info.php. You should see a bunch of information about your version of PHP.

PHP info



This step is optional. To easy access MySQL databases use phpMyAdmin.

Under Terminal enter this command to install phpMyAdmin

sudo apt-get install phpmyadmin

If prompted, use the spacebar to mark apache2 and then hit Enter.

phpMyAdmin - select apache2

You will also be asked if you want to configure phpMyAdmin with a new database called dbconfig-common. Select Yes and press Enter.

phpMyAdmin - dbconfig-common

Next you’ll be prompted for the password for MySQL’s administrator. Enter the MySQL root password that you created earlier in the installation. Select Yes and press Enter.

Next you’ll be prompted to create an application password for phpMyAdmin to talk to MySQL. If you leave it blank, a random password will be generated for you.

After configuring the password, the installation should complete.

Testing MySQL (phpMyAdmin)

Open a web browser and enter the address http://localhost/phpmyadmin.You should see this page:

phpMyAdmin - login

Login using the username root and the root password, that you created earlier.

phpMyAdmin - admin

The LAMP server is successfully installed.

***NOTE: Should you get a 404 “Not Found” error when you point your browser to the location of phpMyAdmin (such as: http://localhost/phpmyadmin) this is likely caused by not checking the ‘Apache 2’ selection during installation. To redo the installation run the following:

 sudo dpkg-reconfigure -plow phpmyadmin

Then select Apache 2 for the webserver you wish to configure.

If this does not work, then you can do the following to include the phpMyadmin-shipped Apache configuration into Apache:

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
sudo /etc/init.d/apache2 reload
Posted in LAMP, linux, Linux Mint, Ubuntu, WAMP | Leave a comment