Introduction
WordPress is the dominant content management system on the internet. It powers everything from blogs to complex websites with dynamic content. This tutorial will discuss getting WordPress up and running on OpenBSD 6.2.
Before we begin, there are some small housekeeping items that need to be taken care of in order for WordPress to function correctly. Please do not skip these steps, because if you do, you will get some very generic errors that are next to impossible to decipher. Remember that OpenBSD's internal httpd
server runs in a chroot
environment and these housekeeping steps account for this.
Housekeeping
Create the directory /var/www/etc
and keep the default permissions.
Create a new file called hosts
and add the following entries. This will allow WordPress to download updates, themes, and plugins.
127.0.0.1 localhost
66.155.40.202 api.wordpress.org
66.155.40.186 downloads.wordpress.org
66.155.40.187 downloads.wordpress.org
66.155.40.188 downloads.wordpress.org
Install some prerequisite packages.
pkg_install php-5.6 php-fastcgi php-curl php-mysql php-zip mariadb-server mariadb-client
pkg_install wget unzip
Copy the sample ini
files from /etc/php-5.6.sample
to /etc/php-5.6/
.
Create an /etc/httpd.conf
file similar to the one below. You can optionally replace the server name "default"
with the actual name in DNS, but that is not strictly necessary.
types { include "/usr/share/misc/mime.types" }
server "default" {
listen on egress port 80
root "/wordpress"
directory index index.php
location "*.php*" {
fastcgi socket "/run/php-fpm.sock"
}
}
Now it is time to enable the necessary daemons so they launch at system startup.
rcctl enable php56_fpm
rcctl enable httpd
rcctl enable mysqld
Installation
Download WordPress, then move it into /var/www
and set the correct permissions.
cd /tmp
wget https://wordpress.org/latest.zip
unzip latest.zip
mv wordpress /var/www/.
chown -R www:www /var/www/wordpress/
Setup MariaDB to provide the database for WordPress. Running mysql_secure_installation
is recommended because it can remove anonymous users and the test database. Furthermore, a root password for MariaDB is set.
mysql_install_db
rcctl start mysqld
mysql_secure_installation
Create the WordPress database. Make certain to replace Password
with the password that you intend to use.
mysql -u root -p <password goes here>
CREATE DATABASE wordpress;
CREATE USER 'wordpress'@'localhost' identified by 'Password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY 'Password';
FLUSH PRIVILEGES;
EXIT;
Now that you have created the WordPress database, it is time to start the web server and the fastcgi
daemon.
rcctl start httpd
rcctl start php56_fpm
From here, open up a web browser and browse to your website, e.g. www.example.org
. You will see the WordPress Installation Wizard. On the next screen, you will be prompted for the database name, database username, database password, server, and the table prefix.
The database name defaults to "wordpress
". Make certain to set the database user to "wordpress
" and use the same password as when you created the database previously. Finally, change the server to 127.0.0.1
and leave the table prefix as-is.
The wizard should properly populate the database and then prompt you to create an "admin
" user. Once this is completed, you are ready to download themes and plugins and begin your website design. On a closing note, be sure to keep an eye on new versions and keep your WordPress install up to date. The further you get away from the current version, the harder upgrades tend to be.