Gentoo Wiki


This article is part of the HOWTO series.
Installation Kernel & Hardware Networks Portage Software System X Server Gaming Non-x86 Emulators Misc

Apache2 Series



Addons & Tunnels






This page explains how to install WordPress on Gentoo with Apache, MySQL, and PHP.

USE Flags

First, make sure that you have php, mysql, libwww, xml and apache2 in your use flags.

File: make.conf
USE="php mysql apache2 libwww xml"

Add xml use flag to /etc/portage/package.use to make the dashboard work properly.

echo 'dev-lang/php xml' >> /etc/portage/package.use

Optionaly add ctype use flag to /etc/portage/package.use to make some plugins work properly.

echo 'dev-lang/php xml ctype' >> /etc/portage/package.use

Updating Portage Tree

Before we do any installing, you should update your portage tree:

 emerge --sync

Installing Apache, PHP, etc.

To be able to use wordpress you need to install apache, php, and mysql, which is why we edited the use flags as we did. Now, we can get to some great emerging action (as root, of course):

 emerge -va apache  mysql php

Configuring MySQL

Now, we must configure mysql:

 emerge --config =mysql-<version>

and follow the on-screen instructions.
NB: replace <version> with your mysql version.

Enable mod_php

To enable mod_php edit the /etc/conf.d/apache2 and add -D PHP5

File: /etc/conf.d/apache2

Installing Wordpress

Wordpress is in portage, so you can install it using emerge:

 emerge -va wordpress

Starting Web Services

If you haven't already, you should start up apache and mysql.

 /etc/init.d/apache2 start
/etc/init.d/mysql start

NB: If you want apache and mysql to start on boot, we need to do some rc-updating (new verb?)

 rc-update add apache2 default
rc-update add mysql default

Creating a WordPress Database

Fire-up the mysql client:

 mysql -u root -p

When prompted for the password, use the password you typed in when you configured mysql.
Now, we must create the database:

 mysql> CREATE DATABASE wordpress;

and create a user:

 mysql> GRANT ALL PRIVILEGES ON wordpress.* TO wpuser@localhost IDENTIFIED BY 'password';

And of course, you must replace password with a real password (unless you really want password to be your password, which is not suggested.) Finally, we must flush the privileges:



For the initial installation, I would suggest doing a chmod 777 /var/www/localhost/htdocs/wordpress to make sure wordpress can write its configuration file. Afterwards you will want to change them back to 444 or -r--r--r-- for files and 555 or dr-xr-xr-x for directories for security reasons.

Setup Wordpress

Now you should be able to connect to your server and run the wordpress configuration. Edit the file wordpress/wp-config.php and insert the user 'wpuser' and the password you defined.

Then head over to http://server/wordpress/wp-admin/install.php.

Very Important Note

Make sure that whenever you setup your website that you ACCESS IT FROM THE URL THAT PEOPLE ON THE WEB WILL ACCESS IT FROM. Otherwise, your page will load properly for you, but not anyone else, because it will think that is needs to get the css, etc files from eg. http://localhost, when in fact it is going to need them from

Embedded Gallery2


Retrieved from ""

Last modified: Mon, 23 Apr 2007 01:52:00 +0000 Hits: 18,244