WordPress is the widely used Content Management System. It is easy to use and open source web software. The WordPress uses the PHP as the BackEnd and MySQL for the Database connection. WordPress is the most famous CMS framework in the world that is used for building simple blogs or professional websites.

In this tutorial, we will show you how to set up WordPress with an Apache web server on FreeBSD 10.1. Before you begin this guide, you must have a FAMP (FreeBSD, Apache, MySQL, and PHP) stack server setup.

1. First Step – Install Additional PHP Modules

When you install the FAMP stack, you will get PHP modules installed on your FreeBSD. They are not sufficient for the WordPress. The WordPress requires a lot of PHP modules and we are going to install the most required and essential PHP modules.

Based on the Plugin requirement, you may need to install additional PHP modules. To find the out the required PHP module, you have to look for the documentation of the Plugin.

Here is the command with required PHP modules. Just execute the below command.

How To Install WordPress with Apache on FreeBSD 10.1

Each of these modules allows WordPress to use various functions in order to perform certain tasks. For example, php56-gd provides libraries for image handling, and php56-curl allows WordPress to download files from external servers for tasks such as plugin updates. Also note that if you followed the prerequisite FAMP tutorial, you should have already installed php56-mysql, which allows WordPress to interact with a MySQL database.

2. Second Step – Prepare MySQL Database

WordPress requires the database to work. Here you have to create a Database, for WordPress. After that, you have to create a user for WordPress. Then you have to grant the permission to that user to access the Database. WordPress will use this User and Database for the operations.

First, Log into the FreeBSD MySQL using the Root Password.

How To Install WordPress with Apache on FreeBSD 10.1 2

You will be prompted for the password that you set for the MySQL root account when you first installed MySQL. After providing the password, you will enter the MySQL command prompt.

We will now create the MySQL database that WordPress will use to store its data. You can call this whatever you like, but we will call ours wordpress for our example. At the MySQL prompt, enter this SQL statement to create the database:

How To Install WordPress with Apache on FreeBSD 10.1 3

== The common mistake that everyone doing with MySQL interface is not adding ‘;’ at the end of each query line. Make sure that you add the ‘;’ at the end of the query==

When you face any error in the command execution, first look whether you have added the ‘;’ to the query.

You have created the database. Now, it’s time to create the user who will use this database.

To create a user in the MySQL, use the below command.

How To Install WordPress with Apache on FreeBSD 10.1 4

At this point, you have the MySQL database and user that WordPress will use. However, we must grant the user access to the database. To do this, we will use this SQL statement:

How To Install WordPress with Apache on FreeBSD 10.1 5

Now flush the privileges.

How To Install WordPress with Apache on FreeBSD 10.1 6

After that, just exit from the MySQL prompt.

How To Install WordPress with Apache on FreeBSD 10.1 7

The MySQL database and user are now ready for use with a new WordPress installation. Let’s download WordPress now.

3. Third Step – Download the WordPress

You can download the WordPress latest version from their official web page. For download use commands:

How To Install WordPress with Apache on FreeBSD 10.1 8

The file is archived one. You have to extract the WordPress file using the below command.

How To Install WordPress with Apache on FreeBSD 10.1 9

This extracts the contents of the archive to a directory called wordpress, in your home directory. If you wish, you may delete the WordPress archive now:

How To Install WordPress with Apache on FreeBSD 10.1 10

4. Fourth Step – Configure WordPress

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.

First, change to the wordpress directory:

How To Install WordPress with Apache on FreeBSD 10.1

Here, you have to copy the wp-config-sample.php file into wp-config.php. First copy the wp-config-sample.php

How To Install WordPress with Apache on FreeBSD 10.1 2

Now open the configuration file in an editor. We will use vi for this purpose, but feel free to use your editor of choice:

How To Install WordPress with Apache on FreeBSD 10.1

In that configuration file, find the following fields.

DB_NAME
DB_USER
DB_PASSWORD

Set the Database name, username and password. Then save and exit the configuration file.

How To Install WordPress with Apache on FreeBSD

5. Fifth Step – Configure Apache to Serve the WordPress

Now that your WordPress application is configured to connect to your database, we must copy it to Apache’s DocumentRoot directory, where it can be served to your site’s visitors.

If you followed the prerequisite FAMP tutorial, Apache’s document root will be located at /usr/local/www/apache24/data—if your document root is located somewhere else, be sure to update the highlighted path in the commands in this section.

Let’s copy the WordPress files to Apache’s document root with the cp command:

How To Install WordPress with Apache on FreeBSD 10.1 5

Here the /usr/local/www/apache24/data is the web root document. If you have changed the root location while installing, you should change the path in the above command also.

Change group ownership to the www group. The www group is the apache user which runs the Apache process.

How To Install WordPress with Apache on FreeBSD 10.1 6

That’s all. Now all your backend configuration for the WordPress is finished. Hereafter, you have to complete the installation process through the web interface.

6. Step Six – Run WordPress Installation Script

The next 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:

How To Install WordPress with Apache on FreeBSD 10.1 7

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:

How To Install WordPress with Apache on FreeBSD 10.1 8

Select the language and click on continue. After that, it will ask you for the Site Title, Username and password. You can use the generated password or set your own.

How To Install WordPress with Apache on FreeBSD 10.1 9

Fill out the site information. Once you are finished, click the Install WordPress button. WordPress will confirm the installation, and then ask you to log in with the account you just created:

How To Install WordPress with Apache on FreeBSD 10.1 10

Click the Log In button at the bottom of the screen, then enter your login (the one that you just created):

How To Install WordPress with Apache on FreeBSD 10.1 11

Now, the WordPress Dashboard will be displayed and you can customise it as per your expectation.

How To Install WordPress with Apache on FreeBSD 10.1 12

Step 7 (Optional) — Configure Permalinks

When you create a new post in WordPress, it will create a URL based on the post id. Most of the people don’t think this as a user-friendly URL. For example, if you create a 3rd post in the WordPress, it will show like

How To Install WordPress with Apache on FreeBSD 10.1 8

WordPress has the option to create a custom URL. This is called Permalink. Using that, you can create a custom URL which can be very relevant to the title.

How To Install WordPress with Apache on FreeBSD 10.1

To change your permalink settings, we must reconfigure Apache then our WordPress settings.

Configure Apache to Allow URL Rewrites

First, we need to enable the Apache rewrite module. Open the Apache configuration file for editing. We are assuming that this file is located at /usr/local/etc/apache24/httpd.conf:

How To Install WordPress with Apache on FreeBSD 10.1 1

Find and uncomment the #LoadModule rewrite_module … line, by deleting the #, so it look like this:

How To Install WordPress with Apache on FreeBSD 10.1 2

After that, We have to allow the Apache to rewrite the .htaccess file.

First open the file <Directory “/usr/local/www/apache24/data”> and look for the AllowOverride. Set the Line like below.

How To Install WordPress with Apache on FreeBSD 10.1 4

Now, save the file and exit.

You have to restart the apache to make the changes to take effect. Execute the FreeBSD restart apache configuration.

How To Install WordPress with Apache on FreeBSD 10.1 5

Now Apache is configured to allow URL rewrites but we must create an .htaccess file that WordPress will use to reconfigure the permalink settings.

Create an .htaccess File

Now that Apache is configured to allow rewrites through .htaccess files, we need to create the actual file that WordPress will write its permalink rules to.

Change to your document root path. Assuming that your document root is located at /usr/local/www/apache24/data, use this command:

Now, create the .htaccess file using the below command.

Now change the ownership of the file to the www user and group, so WordPress will have permission to write to the file:

After that, the permalink settings can be reconfigured through the WordPress dashboard.

You can access the permalink settings in the WordPress by going through settings->permalinks. This is accessible via the /wp-admin link, for example:

On the left-hand side, under the Settings menu, click the Permalinks link:

You can choose any of the premade permalink settings, or you can create your own:

When you have made your selection, click the Save Changes button at the bottom of the page. This will generate the rewrite rules, and write them to the .htaccess file that you created earlier.

You should see a message like this:

Your new permalink settings should be working now. Test it out by visiting one of your posts, and observing the URL.

FreeBSD is a lot new to many people. The commands differ a lot with Linux operating systems. In our next article, we will see about FreeBSD WordPress Nginx.

Leave a Reply

Your email address will not be published. Required fields are marked *