Installing WordPress on FreeBSD

There are three major phases to installing and launching WordPress on a FreeBSD system – specifically in a jail environment:

  1. Installing FAMP stack – 75%
  2. Installing WordPress – 15%
  3. Configuring WordPress – 10%


Phase 1: Install FAMP

FreeBSD should already be installed. For this project, I am using FreeNAS 11 based off of FreeBSD. From what I’ve tested,  9.10, 9.11, and 11 follow the same steps. To install Apache, SSH (I prefer BitVise) into the FreeNAS box. Before you start, it should be noted everything I do is as root.

Run “jls” to list the existing jails.


Then using jexec, you select the jail using the corresponding number.

#jexec 9

For example, after running the jls command, if the jail you want has the number 9, jexec 9 selects jail #9.


Install the Apache 24 package

pkg install apache24

Autostart Apache when the jail starts.

sysrc apache24_enable=yes

Start the Apache service

service apache24 start

I’d recommend creating a snapshot so that you can easily restore in case something doesn’t work in the next step.


Install the MySQL package

pkg install mysql56-server

Autostart MySQL when the jail starts

sysrc mysql_enable=yes

Start the MySQL service

service mysql-server start

Initiate the MySQL installation process


Since MySQL was just installed, no root password is set, so leave it blank. Set a root user when prompted. Everything else can be left default.

Enter current password for root (enter for none): [RETURN]
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorization.

Set root password? [Y/n] Y
New password: password
Re-enter new password: password
Password updated successfully!

Install PHP

I’ve had issues installing PHP using code/steps from digital ocean – PHP code would only be displayed instead of executed. I finally figured out a repeatable process to install the entire FAMP stack.

Install PHPMyAdmin

pkg install phpmyadmin

Install PHP5.6

 pkg install php56-mysqli php56-json php56-mbstring php56-session  

Copy the config file that PHPMyAdmin made

cp /usr/local/www/phpMyAdmin/ /usr/local/www/phpMyAdmin/  

Link the phpMyAdmin folder to the working directory of Apache

   ln -s /usr/local/www/phpMyAdmin/ /usr/local/www/apache24/data/phpmyadmin

Edit the php.ini to load the following extensions.

 vim /usr/local/etc/php.ini  

Adding these to the very end seemed to work fine.   

Phase 1 is almost done, we just have to tell Apache where to find phpmyadmin and how to handle php files.

Edit the httpd.conf file

vim /usr/local/etc/apache24/httpd.conf

We have to add a handler for php files. At the end of the file (typically shows “”, add the following:

<FilesMatch "\.php$">
       SetHandler application/x-httpd-php
<FilesMatch "\.phps$">
       SetHandler application/x-httpd-php-source

Note: This is where I ran into issues when using Digital Ocean’s Guide; They put it within the directive. Putting it after worked for me.

Add this to the end of the file (directory linking for phpmyadmin)

   Alias /phpmyadmin/ "/usr/local/www/phpMyAdmin/"

    <Directory "/usr/local/www/phpMyAdmin/">
        Options None
        AllowOverride None
        Require all granted

We can restart apache to load all the changes

service apache24 restart   

Navigate to http://IP-Address/phpmyadmin and you should be able to see your phpMyAdmin login page.

Phase 2: Install WordPress

WordPress Foundation

Apparently we didn’t install enough PHP modules, so here are some more to install:

pkg install php56-mysql \
 php56-xml \
 php56-hash \
 php56-gd \
 php56-curl \
 php56-tokenizer \
 php56-zlib \

Log into MySQL

mysql -u root -p

Create a database, it doesn’t have to be “wordpress”, but you do need to know what this is for later.


Create a user for WordPress to use

CREATE USER wordpressuser@localhost IDENTIFIED BY 'password';

Give the user privileges to alter the database

GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost;

Flush to apply


Exit out of MySQL


Install WordPress

Download the WordPress Tar file. The cd ~ is important since we have been navigating all over the place. This brings us back to a fresh place to work.

cd ~


tar xvf latest.tar.gz

Change to the extracted directory.

cd ~/wordpress

Create a copy/rename of the sample php.

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

Edit the config.

vim wp-config.php

We now need to tell WordPress what database/user to use. We need to specify the database name, username, and password.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'password');

Save and exit by typing “:wq”.

Copy the Files to the Apache directory

cp -rp ~/wordpress/* /usr/local/www/apache24/data/

Give permissions to the web user in FreeBSD

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

Phase 3: Configuring WordPress

If we navigate to http://ip-address/, we should be greeted by the language select page.

Follow the prompts, enter whatever information you want.