Installing a LAMP/WordPress Webserver

System requirements

This short manual assumes you already have a Linux system running with a Debian based distribution like Ubuntu, LinuxMint, Raspbian, etc. It is tested on LInuxMinu17, Ubuntu10.04 Server and on Raspbian 2014-12-24 on a RaspberryPi.

Connect to your system via SSH or work on a local console.

Installing the Apache Webserver

sudo apt-get install apache2

On more recent Ubuntu based Linux distributions, the default www content is located at  /var/www/html. If you want to change that to the more traditional location /var/www, edit the file
/etc/apache2/sites-available/000-default.conf
and change the line
DocumentRoot /var/www/html
to
DocumentRoot /var/www

Restart the Apache Webserver
sudo /etc/init.d/apache2 restart

Installing the MySQL Server

sudo apt-get install mysql-server

Define a new root password for your SQL server when being asked during the installation. This password has nothing to do with your servers root password, and for security reasons you should not use the same password.

Installing PHP

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

sudo apt-get install php5-mysql -y

Preparing the www content folder

Change the ownership of the www content folder (in the example it is /var/www) to your normal user (in the example myusername), so you don’t have to work with root privileges all the time.

cd /var/www
sudo chown myusername

Make sure you don’t have any old stuff in the folder (make a backup of the old stuff first if you still need it).

rm -r *

Installing WordPress

Assuming you are still in /var/www, simply download the latest version of WordPress directly to this directory.

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

Extract the archive into the current directory and clean up the empty folder and archive afterwards.

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

Now we need to create an empty database within the MySQL server for WordPress.
Also I strongly recommend to create a user for WordPress in your MySQL database, so that the webserver does not access your complete MySQL server with root privileges.
In the example we call the database wp_database and the user wp_user. We define a new password for that user, in the example it is my_newly_defined_password.

mysql -u root -p

When being asked, state the MySQL root password that you have defined earlier, during the MySQL installation.

mysql> create database wp_database;

mysql> create user wp_user@localhost;

mysql> set password for wp_user@localhost=password(“my_newly_defined_password”);

mysql> grant all privileges on wp_database.* to wp_user@localhost identified by ‘my_newly_defined_password’;

mysql> flush privileges;

exit

Configuring WordPress

Open a browser (e.g. Firefox) and type in the IP address of your server, or the URL that points to your server, followed by /wp-admin.

<IP-address-of-server>/wp-admin

Then click on “Let’s go!”.

On the next webpage, fill in the parameters that you defined earlier in the process:

  • Database Name: wp_database
  • User Name: wp_user
  • Password: my_newly_defined_password

For the typical installation you may keep the default settings on the other parameters.

  • Database Host: localhostund
  • Table Prefix: wp_

Click on “Submit”.

Copy the complete content of the text field that is shown on the next page and paste it into the WordPress configuration file. On your console type:

nano /var/www/wp-config.php

After pasting the text into the file, press Ctrl-o to save and Ctrl-x to leave the editor.

Go back to your browser and click on “Run to install”.

From now on, you can work completly brower based to define the appearance and the content of you webpage.

Enable uploading of multimedia content (e.g. pictures)

A common source of troubles with WordPress is, that after a standard installation, the upload of multimedia content, like pictures, does not work. Whenever the user tries an upload via the browser, the error message “Unable to create directory /wp-content/uploads//. Is its parent directory writable by the server?” appears.

It is highly adviseable not to follow the frequently posted idea to change permissions of all WordPress directories to 777, as that would allow everyone to edit these files.

The clean way of doing it is to create the upload directory and change its group to to the group of the webserver (typically that is www-data). Then give write permissions for the directory to that group only.

From within /var/www (or whatever your www content folder is), type:

mkdir /wp-contents/uploads
chgrp www-data /wp-contents/uploads
chmod 775 /wp-contents/uploads