Installing Wordpress on OpenBSD is a fairly straightforward process, especially since it does not need any extra binaries or libraries to exist inside the /var/www chroot environment. Initially I used the tar.gz file available from (version 2.6, as of this writing), but when I went through the install on a test machine in order to detail the installation process, I realized that there is also a package available in the package tree (version 2.3.3 for OpenBSD 4.3-release, 2.5 for -current). For the purposes of these instructions I installed the package available in the OpenBSD packages tree, but I will also detail how to install the latest version from

By far the easiest way to install Wordpress is to use the package ‘wordpress-2.3.3’:

# pkg_info wordpress-2.3.3
Information for

standard compliant weblog

WordPress calls itself  "a state-of-the-art, semantic personal
publishing platform with a focus on aesthetics, Web standards,
and usability."  It is a web-based blogging package based
on PHP and MySQL.

Maintainer: Kevin Lo


The ‘wordpress-2.3.3’ package will install most of the dependencies needed by the application. It does not install the MySQL Server package, though.

If you decide to use the latest package from Wordpress' site instead of the package, download the tar.gz file, untar it to the /var/www directory, and install the requisite dependencies:

# tar xvfz latest.tar.gz -C /var/www/
# pkg_add -i mysql-client php5-core php5-mysql

Otherwise, install the wordpress package from the package tree:

# pkg_add wordpress-2.3.3
mysql-client-5.0.51a: complete
php5-core-5.2.5p2:libiconv-1.9.2p5: complete
php5-core-5.2.5p2:gettext-0.16.1: complete
php5-core-5.2.5p2:libxml-2.6.30: complete
php5-core-5.2.5p2: complete
php5-mysql-5.2.5: complete
wordpress-2.3.3: complete
--- php5-core-5.2.5p2 -------------------
To enable the php5 module please create a symbolic
link from /var/www/conf/modules.sample/php5.conf
to /var/www/conf/modules/php5.conf.
ln -s /var/www/conf/modules.sample/php5.conf \
The recommended php configuration has been installed
to /var/www/conf/php.ini.
Don't forget that the default OpenBSD httpd is chrooted
into /var/www by default, so you may need to create support
directories such as /var/www/tmp for PHP to work correctly.
--- php5-mysql-5.2.5 -------------------
You can enable this module by creating a symbolic
link from /var/www/conf/php5.sample/mysql.ini to
ln -fs /var/www/conf/php5.sample/mysql.ini \
--- wordpress-2.3.3 -------------------
The WordPress has been installed into
You should point this to the DocumentRoot of your web-server:
# ln -s ../wordpress /var/www/htdocs/wordpress
(make sure you use a relative symlink since Apache is chrooted)
and proceed to complete the installation by reading:
You can ensure you have a working install by accessing:

As you can see, we now have the following packages (and their dependencies) installed:

  • mysql-client-5.0.51a - the MySQL client utilities
  • php5-core-5.2.5p2 - PHP5
  • php5-mysql - the PHP5 module to connect to a MySQL server
  • wordpress-2.3.3 - Obviously if you grabbed the latest source from this package will not exist on your system.

There were some instructions about symlinks that need to get created after everything was installed. Create those:

# ln -s /var/www/conf/modules.sample/php5.conf /var/www/conf/modules
# ln -fs /var/www/conf/php5.sample/mysql.ini /var/www/conf/php5/mysql.ini

The next command symlinks /var/www/wordpress to /var/www/htdocs/wordpress. If you want to use a different path–say, instead of, change the ‘../wordpress’ to ‘../blog’:

# ln -s ../wordpress /var/www/htdocs/wordpress

This should be done whether you got Wordpress from the package tree or from

Next, install MySQL Server (assuming that the same machine will host the database and the website–usually not the best idea for a serious production environment):

# pkg_add -i mysql-server
p5-Net-Daemon-0.43: complete
p5-PlRPC-0.2018p0: complete
p5-DBI-1.59: complete
p5-DBD-mysql-4.005: complete
mysql-server-5.0.51a: complete
--- mysql-server-5.0.51a -------------------
You can find detailed instructions on how to install a database
in /usr/local/share/doc/mysql/README.OpenBSD.

Reading the README tells us to run the ‘mysql_install_db’ command to create the initial system databases, etc.:

# mysql_install_db
Installing MySQL system tables...
Filling help tables...
To do so, start the server, then issue the following commands:
/usr/local/bin/mysqladmin -u root password 'new-password'
/usr/local/bin/mysqladmin -u root -h password 'new-password'
Alternatively you can run:
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/local/bin/mysqlbug script!
The latest information about MySQL is available on the web at
Support MySQL by buying support/licenses at

Now, start the server (we’ll add the relevant block of code to /etc/rc.local to make this happen on boot later):

# mysqld_safe &
[1] 29
 # Starting mysqld daemon with databases from /var/mysql

Now that mysqld is running, we can set the MySQL root password (and lock down the server a bit) by running the above-mentioned command. You need to tweak your answers to suit your environment:

# mysql_secure_installation
In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
Cleaning up...
All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!

Now that MySQL is running and configured, we need to create a database and a database user for Wordpress. This can be performed using the ‘mysql’ command. Replace ‘wordpress’, ‘wordpress_user’, and ‘wordpress_pass’ with values that fit your environment:

# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 5.0.51a-log OpenBSD port: mysql-server-5.0.51a
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)
mysql> GRANT ALL ON wordpress.* TO wpress_user IDENTIFIED BY 'wpress_pass';
Query OK, 0 rows affected (0.04 sec)
mysql> quit

As long as we’re still setting up MySQL, go ahead and edit the file /etc/rc.local to start MySQL on boot:

if [ -x /usr/local/bin/mysqld_safe ] ; then
su -c mysql root -c '/usr/local/bin/mysqld_safe >/dev/null 2>&1 &'
    echo -n ' mysql'

At this point you should be able to start up your browser and navigate to the page The rest of this post details step 5 of the “Famous 5-minute install” section. In the /var/www/wordpress directory, copy the file ‘wp-config-sample.php’ to ‘wp-config.php’:

# cp /var/www/wordpress/wp-config-sample.php /var/www/wordpress/wp-config.php

Edit the following lines in ‘wp-config.php’ to add your database connection information:

define('DB_NAME', 'wordpress');
define('DB_USER', 'wpress_user');
define('DB_PASSWORD', 'wpress_pass');
define('DB_HOST', 'localhost:3306');

I changed the DB_HOST line to ‘localhost:3306’ so that wordpress would connect to MySQL using its TCP port instead of its Unix socket–which, since httpd is chrooted, can’t be opened (it resides at /var/run/mysql/mysql.sock). I have seen mention of creating a hard link from /var/run/mysql/mysql.sock to /var/www/var/run/mysql/mysql.sock so that Wordpress (or any other web application) could connect to the socket, but I ran into two problems with this: first, every time MySQL was restarted, the mysql.sock file would have to be relinked; and second, since I created a partition for /var/www, I wasn’t able to create the hard link (you can’t create hard links across file systems). Therefore, my solution was to just use MySQL’s TCP port.

At this point you should be able to navigate to your Wordpress installation in your browser and go through its quick setup routine. Once that’s done, you should have a working Wordpress install on OpenBSD.