Feed on
Posts
Comments

Update: As Ubuntu is quite similar to Debian, this howto can also be used for Ubuntu systems. I’ve tested this guide with Ubuntu Server 10.04 LTS and Ubuntu Server 10.10 and I expect this to work on Debian 6 (Squeeze), too.

In Lenny, WordPress is already part of the apt repository. The downsite is that its a quite old version. So this little howto describes how to install the latest WordPress version (currently its 3.0.5) from its tarball by still retaining Debian’s file locations. You need a running LAMP configuration and root permissions to perform the next steps. I’ll use “YOUR.DOMAIN” as a placeholder for your blog domain. Please replace it with your real domain, which is something like “www.kaisblog.de”.

Before we start we need to check WordPress’ dependencies. Just type

# apt-get install wordpress

and select “n” to not install WordPress. If you see more packages than just “wordpress” you might want to install them now using “apt-get install”.

We want to install WordPress in /usr/share, so cd into it:

# cd /usr/share

Now we need to get and unpack the latest WordPress version:

# wget http://wordpress.org/latest.zip
# unzip -e latest.zip

This creates the wordpress directory. You can also download the .tar.gz version but for most plugins / themes you need unzip anyway. As Debian handles webapps like normal apps, we should create a config directory in /etc and copy the sample config into it:

# cd wordpress
# mkdir /etc/wordpress
# cp wp-config-sample.php /etc/wordpress/wp-YOUR.DOMAIN-config.php

Again, please replace “YOUR.DOMAIN” with your blog domain. In my case its “wp-www.kaisblog.de-config.php”.

Now create a config file in /usr/share/wordpress/ that reads our config file in/etc/wordpress:

# nano wp-config.php

Paste the following code into it:

<?php
include("/etc/wordpress/wp-YOUR.DOMAIN-config.php");
define('ABSPATH',dirname(__FILE__).'/');
require_once(ABSPATH.'wp-settings.php');
?>

Press CTRL+X to save the file and quit nano.

mySQL

Now its time to create a mysql database where WordPress stores its data in:

# mysql -uroot -p

Enter your mysql root password and you’ll see the mysql prompt. We’ll create a user and a database called wordpress:

# GRANT ALL PRIVILEGES ON wordpress.* TO wordpress IDENTIFIED BY "S3cr3t!";
# FLUSH PRIVILEGES;
# quit

Please replace “S3cr3t!” with your own password :)

Now edit /etc/wordpress/wp-YOUR.DOMAIN-config.php and enter your mysql settings:

# nano /etc/wordpress/wp-YOUR.DOMAIN-config.php
define('DB_NAME', 'wordpress');
/** MySQL database username */
define('DB_USER', 'wordpress');
/** MySQL database password */
define('DB_PASSWORD', 'S3cr3t!');
/** MySQL hostname */
define('DB_HOST', 'localhost');

At the bottom of this config file you’ll find this line:

/* That's all, stop editing! Happy blogging. */

Please delete everything under this line as its already included in /usr/share/wordpress/wp-config.php

Apache

Debian handles apache sites in two different directories: /etc/apache2/sites-available and /etc/apache2/sites-enabled. We create a WordPress site config in /etc/apache2/sites-available and enable it with a2ensite when we are ready to do so.

# nano /etc/apache2/sites-available/YOUR.DOMAIN

Paste the following code into it:
<VirtualHost *:80>
ServerName YOUR.DOMAIN
ServerAdmin webmaster@YOUR.DOMAIN
DocumentRoot /var/www/YOUR.DOMAIN/
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
LogLevel warn
</VirtualHost>

Again, press CTRL+X to save and exit nano.

As you can see, our root directory is /var/www/YOUR.DOMAIN. Thats where Debian (and most other distributions) stores it’s websites. As our WordPress installation is in /usr/share/wordpress, we need to create a symlink:

# ln -s /usr/share/wordpress /var/www/YOUR.DOMAIN

Now we change some filesystem permissions to be able to upload content:

# chown -R www-data:www-data ./wp-content

If you want to change the look of your permalinks you need an writeable .htaccess file in your root directory and mod_rewrite to be enabled:

# touch .htaccess
# chown www-data:root .htaccess
# a2enmod rewrite

For this to work make sure you have “AllowOverride All” set for your document root. Our apache site config already has it included. After changing the permalinks (this can be done later) you can make it read-only again:

# chmod 440 .htaccess

To enable your blog enter:

# a2ensite YOUR.DOMAIN
# apache2ctl restart

You should now be able to open http://YOUR.DOMAIN/wp-admin/install.php in your browser and finalize your blog setup. Enjoy.

14 Responses to “Install WordPress on Debian 5 (Lenny)”

  1. Alice Forum…

    Hier im Alice forum auf der alice-community helfen Dir Alice-Kunden! Einfach anmelden und Deine Frage oder Problem beschreiben. Ob du nun fragen zu Preisen hast oder ein technische Problem mit deinem Alice Anschluß – Hier wird Dir geholfen!……

  2. Wie installiert man WordPress unter Debian?…

    Im Netz habe ich eine wunderbare Anleitung zum installieren und einrichten von WordPress unter Debian (Lenny) gefunden. Auf Kaisblog.de findet man so einige tolle Tutorials und Anleitungen, die einem Admin das Leben erleichtern können. ……

  3. [...] WordPress setup. You can use my how-to. [...]

  4. Anthony Doan says:

    I’ve copied and added your instructions to my wiki.anthonydoan.com webpage.

    Is that ok? I’ll delete it if you want it to be taken down.

    I also modify your mysql instruction because:
    wordpress user should be wordpress@localhost user.

  5. Kai says:

    Hi Anthony,

    thats ok. Please add a reference to my site.

  6. [...] (currently its 2.9.1) from its tarball by still retaining Debian’s file locations. Read more here You need a running LAMP configuration and root permissions to perform the next steps. I’ll use [...]

  7. Softy says:

    Danke für die Anleitung. Thanks for the guide

  8. What theme is that??

  9. Kai says:

    Hi, thats MistyLook for WordPress 3.

  10. The config file name should be -config.php. For example if the hostname is “myhost” then it should be myhost-config.php.

    Also you forgot one step before granting users privileges:
    create database wordpress;

  11. Kai, I’m learning to use WordPress currently. I’m virtualizing Debian right now in a VM session… Changed my local hosts file to resolve presstest.com & to http://www.presstest.com to test this all locally well to an IP on my LAN, either way, you get the point.

    I’m playing with URL rewriting BEFORE wordpress is interested using httpd.conf, I’ve always wanted to rewrite my URLs using any Blog/CMS engine or any site to have a “www.” prefix. I was able to finally figure out how to get this to work! However, capturing all the HTTP headers, I see that I’m getting a 302 Not Found which couldn’t be good for business on a search engine, could be wrong as I’m not a web developer whatsoever. But the use of and future of web applications seem to be a growing trend and cloud services will probably stick around. Back to what I was really talking about and going to ask….

    I captured your HTTP headers by putting kaisblog.de in the location bar and watched them rewrite and said 301 Moved Permanently which from what I understand is best for SEO and rankings. Am I writing this all wrong? Or what do I add to this, is there another method for doing so, is the way I have it written intended for a different use? Please do explain if you’d be so kind or at least if you would give me an example I could study and figure out, had a bit of a hard time googling exactly what I wanted rewriting with www prefix so I just had to read up a bit on how apache works, still very new, as in posted about 5 pages temporarily for trying out a few CRM/ERP webapps and dabbled with openAtrium (Drupal distribution I guess you could call it). Anyway, my httpd.conf contents below:

    RewriteEngine On
    RewriteCond %{HTTP_HOST} presstest\.com [NC]
    RewriteCond %{HTTP_HOST} !^$
    RewriteRule ^/(.*) http://www.presstest.com/$1 [L,R]

    http://presstest.com/

    GET / HTTP/1.1

    Host: presstest.com

    User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101026 SUSE/3.6.12-1.2 Firefox/3.6.12

    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

    Accept-Language: en-us,en;q=0.5

    Accept-Encoding: gzip,deflate

    Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7

    Keep-Alive: 115

    Connection: keep-alive

    HTTP/1.1 302 Found

    Date: Tue, 30 Nov 2010 18:35:04 GMT

    Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny9 with Suhosin-Patch mod_python/3.3.1 Python/2.5.2 mod_perl/2.0.4 Perl/v5.10.0

    Location: http://www.presstest.com/

    Vary: Accept-Encoding

    Content-Encoding: gzip

    Content-Length: 299

    Keep-Alive: timeout=15, max=100

    Connection: Keep-Alive

    Content-Type: text/html; charset=iso-8859-1

    What do I do in order to get a 301 Moved Permanently?

    I hope I was clear enough to follow!
    Thanks,

    –Jamie

  12. Well even screwed up a bold tag…Impressive =)

  13. [...] little tribute too …. this wordpres installation was done usingthe detailled instaructions of Kai’s Blog This entry was posted in Uncategorized and tagged WordPress Debian. Bookmark the [...]

  14. speeding says:

    Would you mind enabling rss feeds, because this page is difficult to read on my phone. Don’t mean to be a complainer, but I figure if it would help me it would probably help others as well. Thanks :)

Leave a Reply