User Tools

Site Tools


Installation on Debian

Install the package

If it is not already installed on the machine, install the MySQL server. Alternatively you can connect to a MySQL instance on a different machine

apt-get install mysql-server

Now install Wordpress.

apt-get install wordpress

Setup the MySQL database

Connect to your MySQL server as root

mysql -u root -p

Create the naked database and the Wordpress database user.

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER ON wordpress.* TO wordpress@localhost IDENTIFIED BY '<the wordpress database password here>';
FLUSH privileges;

Prepare the upload directory

If you do not like the default installation of the upload directory /var/lib/wordpress/wp-content/uploads/ then you need to prepare a different directory.

Skip this step if the standard is okay for you.

Create a directory for the uploads. The example below is assuming you have a /data directory where your uploaded data resides. I always do this for all my setups because then I have one central directory that I need to backup if I want to backup all user content.

mkdir -p /data/wordpress/upload
chown -R www-data:www-data /data/wordpress/

Configure Apache

In your Apache config you have to add the wordpress root directory and the upload directory. I wont go into details on how to setup Apache here.

  Alias /wordpress /usr/share/wordpress
  <Directory /usr/share/wordpress>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All 
    Order allow,deny
    allow from all
  Alias /wp-uploads /data/wordpress/upload
  <Directory /data/wordpress/upload>
    AllowOverride  All
    Order allow,deny
    allow from all

Activate the necessary rewirte rules for pretty links in /etc/wordpress/htaccess by uncommenting them.

Note that you might have to adapt the RewirteBase option depending on your installation!

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

Tell Wordpress how to access the database

Create a configuration file that provides Wordpress with the database credentials under /etc/wordpress/config_<domain>.php:

define('DB_NAME', 'wordpress');
define('DB_USER', 'wordpress');
define('DB_PASSWORD', 'the wordpress database password here');
define('DB_HOST', 'localhost');
define('SECRET_KEY', 'a-very-very-long-key-that-you-create-randomly');
#This will disable the update notification.
define('WP_CORE_UPDATE', false);
$table_prefix  = 'wp_';
$server = DB_HOST;
$loginsql = DB_USER;
$passsql = DB_PASSWORD;
$base = DB_NAME;
$upload_path = "/data/wordpress/upload";
$upload_url_path = "";

Adding plugins - Debian style

Stephen Paul Weber of provides auto-built Debian packages of wordpress plug-ins. Installing those debianized plug-ins is a much better approach than doing it manually.

echo 'deb singpolyma wordpress-plugins' > /etc/apt/sources.list.d/singpolyma.list
wget -O - | sudo apt-key add -
sudo apt-get update

Find the original instructions here:

Don't forget to activate a plug-in after you installed it!

Recommended Plugins

  • akismet — Spam protection (subscription!)
  • easy-captcha — Chase away simple spam bots
  • page-list — automatically list subpages including content preview
  • easy-table — quick way to produce simple tables

The akismet plug-in comes with the default Debian installation. The rest can be installed like this:

apt-get install wordpress-easy-captcha wordpress-page-list wordpress-easy-table

And a bunch of other useful plug-ins:

apt-get install wordpress-crop-thumbnails wordpress-enable-media-replace wordpress-manage-upload-types \
wordpress-media-categories-2 wordpress-media-rename wordpress-simple-301-redirects \
wordpress-simple-image-sizes wordpress-tablepress wordpress-lightbox-plus

If you want to learn more about who is visiting your blog use the “WP Statistics” plug-in:

apt-get install wordpress-wp-statistics

Moving an existing wordpress installation to a new domain

Note that changing the Apache configuration files is not enough. You also need to make adaptions in the database.

Search the table wp_options for all occurences of the old domain name and replace it by the new name.

Update at least the entries where the option_name is:

  1. siteurl
  2. home
  3. upload_url_path

Update the posts:

CREATE TABLE wp_posts_backup LIKE wp_posts;
INSERT INTO wp_posts_backup SELECT * FROM wp_posts;
UPDATE wp_posts SET post_content = REPLACE(post_content, 'your-old-domain', 'your-new-domain');

Trouble shooting

Debian upgrade removes theme "twentyeleven"

A Debian update removed the standard theme twentyeleven. That led to a blank page being displayed.

The following SQL command on the Wordpress database switched to twentythirteen.

UPDATE wp_options SET option_value='twentythirteen' WHERE option_name='stylesheet' OR option_name='template';

Installing a theme manually under Debian

Download and install the theme:

cd /tmp
unzip /tmp/ 
mv twentyeleven /var/lib/wordpress/wp-content/themes/

Make sure the files and directories belong to root:root.

And add a symlink if you get an unformatted page:

ln -s /var/lib/wordpress/wp-content/themes/twentyeleven /usr/share/wordpress/wp-content/themes/

Moving wordpress to another server

Create a database dump on the origin server:

mysqldump -u root -p --databases wordpress > /tmp/wordpress_database_dump.sql

Move the dump to the destination server:

scp /tmp/wordpress_database_dump.sql <destination host>:/tmp

On the destination server restore the database from the dump:

mysql -u root -p < /tmp/wordpress_database_dump.sql 

Set database user permissions as described above for a new installation.

Copy the uploaded media from the origin server to the destination server:

scp -rp /data/wordpress/upload/* <destination host>:/data/wordpress/upload
wordpress.txt · Last modified: 2015/09/27 18:24 by sebastian