Install WordPress with a FAMP Stack on FreeBSD 12

Updated on June 15, 2021
Install WordPress with a FAMP Stack on FreeBSD 12 header image


WordPress is an open-source content management system that powers millions of websites, blogs, and corporate portals. The software is written in PHP and can be installed on a FAMP (FreeBSD, Apache web server, MySQL, and PHP) stack.

WordPress has a friendly dashboard and rich-text editor that doesn't require any HTML knowledge to use. It also has many professional themes and plug-ins that you can use to customize your website. In this tutorial, you'll install, configure and run a WordPress site with a FAMP stack on FreeBSD 12.


Before you begin, make sure you have the following:

1. Install WordPress Dependencies

SSH to your server and make sure your system packages are up to date.

$ sudo freebsd-update fetch install
$ sudo pkg update
$ sudo pkg upgrade -y

Optionally, install the nano text editor. While this guide uses nano for the examples, you're free to use any other text editor.

$ sudo pkg install -y nano

Install the PHP extensions required by WordPress.

$ sudo pkg install -y php73-xml php73-gd php73-curl php73-tokenizer php73-zlib php73-zip php73-intl php73-mbstring php73-json php73-ftp php73-ctype php73-dom php73-posix php73-filter php73-iconv php73-openssl php73-simplexml php73-sockets  php73-xmlreader php73-mysqli php73-pdo_mysql php73-hash

To craft human-readable URLs, WordPress uses the mod_rewrite module. First, open the Apache configuration file using nano to enable it.

$ sudo nano /usr/local/etc/apache24/httpd.conf

Find the line below.

# LoadModule rewrite_module libexec/apache24/

Uncomment the above line by removing the # symbol at the beginning to enable the mod_rewrite module.

LoadModule rewrite_module libexec/apache24/

Save and close the file.

Restart Apache to load the new configuration.

$ sudo service apache24 restart

2. Create the WordPress Database

Log in to your MySQL server as root.

$ sudo mysql -u root -p

Enter your root password and press Enter to proceed.

At the MySQL prompt, enter the commands below to create a wordpress database and a wp_user user. Replace EXAMPLE_PASSWORD with a strong value.

root@localhost [(none)]> CREATE DATABASE wordpress;
                         CREATE USER 'wp_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'EXAMPLE_PASSWORD';
                         GRANT ALL PRIVILEGES ON wordpress.* TO 'wp_user'@'localhost';
                         FLUSH PRIVILEGES;

Exit from the MySQL command-line interface.

root@localhost [(none)]> QUIT;

3. Configure the Virtual Host File

Apache will serve the WordPress site from the /usr/local/www/apache24/data/ directory. Create a child wordpress directory in this location.

$ sudo mkdir -p /usr/local/www/apache24/data/wordpress

Change the ownership of the new directory to your username to avoid permission issues when working on the directory. Replace example with your username.

$ sudo chown -R example:example /usr/local/www/apache24/data/wordpress

Create a new virtual host file and instruct Apache to load your WordPress site from the directory you've just created.

$ sudo nano /usr/local/etc/apache24/Includes/wordpress.conf

Enter the information below into the file. Replace and with your values.

<VirtualHost *:80>
    DocumentRoot /usr/local/www/apache24/data/wordpress

    <Directory /usr/local/www/apache24/data/wordpress>
       AllowOverride All
       Require all granted


Save and exit the file.

Restart Apache to load the new changes.

$ sudo service apache24 restart

4. Download and Install WordPress

Navigate to the tmp directory.

$ cd /tmp

Download the latest version of WordPress.

$ curl -O

Unpack the WordPress tarball.

$ tar xzvf latest.tar.gz

Copy the files to the WordPress site directory that you created earlier.

$ sudo rsync -rtv /tmp/wordpress/ /usr/local/www/apache24/data/wordpress

Navigate to the /usr/local/www/apache24/data/wordpress directory.

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

Copy the sample configuration file to wp-config.php.

$ sudo cp wp-config-sample.php wp-config.php

Create an upgrade directory under the wp-content directory.

$ sudo mkdir wp-content/upgrade

Change the ownership of the /usr/local/www/apache24/data/wordpress directory to the Apache user www.

$ sudo chown -R www:www /usr/local/www/apache24/data/wordpress

Set the appropriate permissions for the WordPress files and directories.

$ sudo find /usr/local/www/apache24/data/wordpress -type d -exec chmod 750 {} \;
$ sudo find /usr/local/www/apache24/data/wordpress -type f -exec chmod 640 {} \;

5. Configure WordPress

The WordPress software relies on some salts and keys for security purposes. Grab some unique values from the WordPress API endpoint using the curl command.

$ curl -s

Copy the values to your clipboard.

Edit the WordPress configuration file.

$ sudo nano /usr/local/www/apache24/data/wordpress/wp-config.php

Locate the keys and salts below and replace them with the values you retrieved from the WordPress API.

define( 'AUTH_KEY',         'put your unique phrase here' );
define( 'SECURE_AUTH_KEY',  'put your unique phrase here' );
define( 'LOGGED_IN_KEY',    'put your unique phrase here' );
define( 'NONCE_KEY',        'put your unique phrase here' );
define( 'AUTH_SALT',        'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT',   'put your unique phrase here' );
define( 'NONCE_SALT',       'put your unique phrase here' );

Locate the database settings below.

define( 'DB_NAME', 'database_name_here' );

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

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

Match the values to the database name, user account, and password that you created earlier. Your completed settings should look similar to the content below. Replace EXAMPLE_PASSWORD with the correct password that you assigned to the wp_user.

define( 'DB_NAME', 'wordpress' );

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

/** MySQL database password */

Save and close the file.

6. Finalize WordPress Installation

Visit your server's URL in a web browser. Replace with the domain name or public IP address of your webserver.

Select a language and click Continue.

Enter your site information and click Install WordPress to proceed.

Log in to your new WordPress site.

More Information