WordPress is an open-source web software application that you can use to create and maintain a modern website. At the time of writing, more than 30% of all websites run on WordPress, and the number is only expected to increase in the coming years. In simple terms, with WordPress, anyone can build a beautiful website with minimal effort involved and then make it available to the world in no time.
This guide will show how to install WordPress on FreeBSD 12 virtual private server (VPS) using the FEMP stack.
To run WordPress you will need the following software:
- PHP version
- MySQL version
5.6or greater or MariaDB version
10.1or greater. This tutorial will use MySQL.
- Apache (with
mod_rewritemodule) or Nginx. This tutorial will use Nginx. But any server that supports PHP and MySQL will do.
- HTTPS support. Let's Encrypt is a free option for HTTPS.
And, that’s really it.
Before you begin
Before you start, you must have a FEMP (FreeBSD, Nginx, MySQL, and PHP) stack deployed, so carefully follow this guide to deploy components of the FEMP stack.
FEMP is an acronym for FreeBSD, Nginx, MySQL/MariaDB, and PHP/Python/Perl.
Installing PHP extensions for WordPress
Although you already have PHP 7.4 installed, WordPress requires additional PHP modules (extensions) in order to function properly. We will use
pkg to install these required PHP modules.
Install the required PHP extension for WordPress:
sudo pkg install -y php74-curl php74-dom php74-posix php74-filter php74-ftp php74-gd php74-iconv php74-json php74-mbstring php74-openssl php74-simplexml php74-sockets php74-tokenizer php74-xmlreader php74-zlib php74-mysqli php74-pdo_mysql php74-zip
sudo ln -s /usr/local/etc/php.ini-production /usr/local/etc/php.ini
sudo service php-fpm restart
Creating Database for WordPress
WordPress uses a relational database, such as MySQL, to manage and store site and user information. In this step, we will prepare a MySQL database and user for WordPress to use.
Log into MySQL as the root user:
sudo mysql -u root -p # Enter password:
Create a new MySQL database for WordPress and user who has all privileges for accessing and modifying it, and remember the credentials:
CREATE DATABASE dbname; CREATE USER 'username'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password'; GRANT ALL ON *.* TO 'username'@'localhost'; FLUSH PRIVILEGES;
usernamewith appropriate names for your setup. Replace
passwordwith a strong password.
Exit from MySQL:
Navigate to your document root folder:
Download the WordPress CMS package from the wordpress.org website:
sudo wget https://wordpress.org/latest.zip
Unzip WordPress CMS to your desired document root and remove the zip archive:
sudo unzip latest.zip sudo rm latest.zip
Change ownership of the
/usr/local/www/nginx directory to
sudo chown -R www:www /usr/local/www/nginx/wordpress
Open your site URL in a web browser to run the WordPress installation script and follow the instructions on the screen to finish the installation.
Running WordPress Installation Script
The last step is to run the WordPress installation script. The script will ask you a few questions about your WordPress site, then initialize the database.
In your web browser, navigate to your server’s domain name or public IP address. For example, we will use "example.com" here:
The first time you visit your WordPress site, you will be prompted by a Language Select screen. Select your preferred language, and click the Continue button:
Next, you will see the WordPress database page, where you will click "Let's go!".
Before making WordPress accessible via our web server, we must configure it so that it will able to connect to the database that we created earlier. Enter your database credentials here and click "Submit".
Next, you will see the WordPress installation page, where you will choose a Site Title, and set an administrative username and password, among a few other things:
And, that’s it! WordPress should now be installed.