In this post we will see how to install the latest version of WordPress (at the point of writing this 4.9.1) in FreeBSD 11.1.

Before we begin

The first thing  you need to do, of course, is to install the FreeBSD system: if you haven’t done so already you can check this post on how to install FreeBSD 11 in your machine.

Then you need to get FAMP up and running:  you need to install and configure the combination of Apache server, MySQL, and PHP. You can learn how to install the FAMP stack in this post.

Installing WordPress

From the repositories

The first, and easiest way to install WordPress in your FreeBSD System is to install the package from the FreeBSD repository:

pkg install wordpress

Notice that even if you use the package manager to install WordPress you will still have to do almost all of the configuration and the set up process manually. Unlike some Linux distros, like Debian, that have a more automated process, the package manager will do little more than downloading and unzipping the required WordPress files.

Things you still need to do manually after installing the WordPress package:

  • Create a wordpress database, and a user to access it.
  • Copy the wp-config.php file, and configure it with the required information so that WordPress can access the database
  • Run the WordPress configuration script.

Manual install

If we use the FreeBSD repository package we are going to wind up with a slightly older WordPress version. Notice also that the package has a dependency on the 5.6 version of PHP while I would like to use the more recent 7.1 version.

Therefore if we we want to run the current version of WordPress we have to download it from the site and manually install it.

Install additional PHP modules

WordPress requires the use of some additional PHP modules. If we had used the WordPress package, the FreeBSD package manager would have automatically taken care to install them in the system. But since we are not, we need to install those packages ourselves:

pkg install php71-xml php71-hash php71-gd php71-curl php71-tokenizer php71-zlib php71-zip

Download latest WordPress version

I want to use wget to download the latest WordPress installation file, but since wget does not come installed by default in the system I first need to install it:

pkg install wget

Now I download WordPres from the official site:


Create WordPress Database

Log into MySQL, and create a database for WordPress:

mysql -u root -p
create database wordpress

We are also going to create a MySQL user that WordPress will use to access its database:

CREATE USER worduser@localhost IDENTIFIED BY 'mypasswd';
GRANT ALL PRIVILEGES ON wordpress.* TO worduser@localhost;

Configure WordPress

Unzip the file that we downloaded before: we will obtain a wordpress folder containing all the files that are part of the WordPress installation.


Copy the wordpress folder to the apache directory:

cp -r wordpress /usr/local/www/apache24/data

Go to the WordPress directory:

cd /usr/local/www/apache24/data/wordpress

Make a copy of the configuration file wp-config-sample.php and call it wp-config.php:

cp wp-config-sample.php wp-config.php

Edit wp-config.php file to configure the database that WordPress is going to use, and the user and password it’s going to use to access the WordPress database.

vi wp-config.php

We need to find in the wp-config.php file the variables DB_NAME, DB_USER, and DB_PASSWORD and set them to the correct values (the dabase name, user, and password we defined when creating, and configuring the MySQL WordPress database):

define('DB_NAME', 'wordpress');
define('DB_USER', 'worduser');
define('DB_PASSWORD', 'mypasswd');

Lastly we need to change ownership of the wordpress folder so that the apache server can access it:

chown -R www:www /usr/local/www/apache24/data/wordpress/*

Run WordPress configuration script

Write in the url bar of your browser the url of your WordPress site to go to WordPress configuration script:

Choose your language:

choose WordPress language

You will need to introduce a name for your WordPress site and the user/password used to log in:

Choose a user/password for you WordPress site

The script will proceed to configure your WordPress site using the information you just provided, and it will inform you once WordPress had been correctly installed:

Installation finished

If you now click in the “Log In” button, you will be directed to the the Log In page of your newly installed WordPress site;  to access the site you will introduce the user/password you configured a few steps ago in the configuration form:

Log In to you WordPress site

The installation is now finished, yet you may want to do some extra fine-tunning like configuring WordPress permalinks.