WordPress is a free and open source content management system written on PHP and MySQL which powers most of the websites running in the web now a days. WordPress powers more than 26.4% of the top 10 million websites as of April 2016, supporting more than 60 million websites on the web. It is developed and maintained by the WordPress Foundation and is released under GNU GPLv2 or later. Running websites and blogs on WordPress is very easy task which doesn't require expertise in programming. FreeBSD is a free and open source Unix-like operating system derived from Research Unix via the Berkeley Software Distribution (BSD). It is similar to Linux but with two major differences in scope and licensing ie FreeBSD develops and maintains a complete operating system ie from kernel, device drivers to the userland utilities and is released under a permissive BSD license which opposes the copyleft GPL used by Linux. It is widely used across desktop, workstation, server and embedded systems. The latest stable release of FreeBSD 11 was released yesterday. Here, we'll install WordPress on the latest FreeBSD 11 with a complete FAMP Stack ie FreeBSD with Apache as web server, MySQL for database system and PHP modules.
1) Installing Apache Web Server
To install Apache web server on FreeBSD, we can use its default package manager ie pkg which allows us to install the Apache web server from the official FreeBSD package repository. To install apache using pkg, we'll need to run the following command.
% sudo pkg install apache24
2) Installing MySQL
Once Apache Web Server is installed, we'll go further on installing MySQL database server so that we can use it for managing data for our wordpress instance. To install MySQL server, we'll need to run the following command in the console which will install mysql server version 5.6.
% sudo pkg install mysql56-server
3) Enabling Apache and MySQL services
To enable Apache and MySQL services, we'll run the following sysrc command. Enabling the services will run the daemons automatically on every system boot.
% sudo sysrc apache24_enable=yes mysql_enable=yes
Once done, we'll start the daemons by running the following command.
% sudo service apache24 start
% sudo service mysql-server start
4) Configuring MySQL
Now, as we haven’t assigned a root password for our MySQL server, we’ll gonna configure a root password for it. To do so, we'll need to run the following command.
% sudo mysql_secure_installation
It will ask us to enter the root password for our MySQL server but as we haven’t set any password before and its our first time we’ve installed mysql, we’ll simply hit enter button from keyboard and move ahead. Then, we’ll be asked to set password for our MySQL root user, here we’ll hit Y and enter it. Then, we’ll simply strike enter button on keyboard to set the default values for the further settings.
5) Creating Database for WordPress
As our MySQL server has been configured successfully, we'll now create a new database for our WordPress installation. To do so, we'll first need to login to the root user of the mysql server by running the following command.
% sudo mysql -u root -p
Then, we'll be asked to enter the password which we had set just above. Once login is success, we'll be welcomed into the MySQL console environment. Here, we'll need to run the following commands to create database and set a user and password for it.
> CREATE DATABASE wordpressdb;
> CREATE USER wordpressuser@localhost IDENTIFIED BY 'Pa$$word123';
> GRANT ALL PRIVILEGES ON wordpressdb.* TO 'wordpressuser'@'localhost';
> FLUSH PRIVILEGES;
Here, in this tutorial, we are creating a new database, user and password as wordpressdb, wordpressuser and Pa$$word123 respectively.
6) Installing PHP 7.0 Modules
Next, we'll install all the required PHP 7.0 modules so that our wordpress which is written in PHP can execute. So, in order to install the required PHP modules, we'll need to run the following command.
% sudo pkg install mod_php70 php70-mysqli php70-xml php70-hash php70-gd php70-curl php70-tokenizer php70-zlib php70-zip
We'll then copy the production php configuration ie /usr/local/etc/php.ini-production to /usr/local/etc/php.ini by executing the following command.
% sudo cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini
Then, we'll need to run rehash command in order to regenerate the system's cache information about our installed executable files.
7) Configuring Apache
Once PHP is installed on our FreeBSD 11, we'll now need to configure Apache so that it can handle and execute PHP files. To do so, we'll need to edit /usr/local/etc/apache24/Includes/php.conf using a text editor.
% sudo vi /usr/local/etc/apache24/Includes/php.conf
Once the text editor open the file, we'll need to make changes to the file as shown below.
<IfModule dir_module> DirectoryIndex index.php index.html <FilesMatch "\.php$"> SetHandler application/x-httpd-php </FilesMatch> <FilesMatch "\.phps$"> SetHandler application/x-httpd-php-source </FilesMatch> </IfModule>
Once done, we'll save and exit it. Then we'll need to restart the apache web server in order to apply the above changes.
% sudo service apache24 restart
8) Downloading and Extracting WordPress
Once our FAMP stack is up and ready, we'll now move ahead towards the installation of WordPress on our machine running FreeBSD 11. Here, we'll download the latest release of WordPress inside a /tmp/ directory, to do so, we'll need to execute the following command on the console.
% cd /tmp/
% fetch http://wordpress.org/latest.tar.gz
Once the latest release of wordpress tarball is downloaded, we'll then extract the file inside the /tmp/ directory.
% tar xvf latest.tar.gz
Then, we'll copy the extracted files to the webroot of Apache Web server ie /usr/local/www/apache24/data/ . To do so, we'll use the cp command as shown below.
% cd /tmp/wordpress/
% sudo rm -rf /usr/local/www/apache24/data/index.html
% sudo cp -pr /tmp/wordpress/* /usr/local/www/apache24/data/
Next, we'll need to recursively apply the files and directories ownership as www:www using chown so that Apache will have full read and write access over the directory.
% sudo chown -R www:www /usr/local/www/apache24/data/
9) Installing WordPress
Now, as we have done everything as expected above, we'll now should be able to access the WordPress web based installation page by pointing our browser to http://ip-address/ or http://mydomain.com as per the system's configuration. Here, we'll see the following page in which we'll be asked to choose the language for our WordPress installation. Once we have choosed our language, we should click Continue button to move ahead.
Then, the below welcome page will appear as we haven't configure our wordpress configuration file, here we'll need to click on Let's Go to move ahead.
Next, we'll enter the database name, username and password that we had setup above while creating the new database for wordpress. Once done, we'll get a notification that our wordpress is connected with the database then we'll click on Run the Install to move ahead.
Then we'll need to enter the wordpress site information like admin username, password, email, etc, once done we'll click on install WordPress.
Once done, a success page will display. Then we can finally browse our WordPress site and login to the dashboard using the above setup login.
WordPress can be easily installed into our machine running FreeBSD by following this tutorial as above. WordPress is widely used Content Management System which is best known for its easy and rapid website and blogs development and its varieties of thousands of plugins and tools available on the internet. Moreover, WordPress on top of Apache, MySQL and PHP 7.0 running in very stable Unix-like operating system FreeBSD 11 makes it fast, secure and stable. This setup combination is very well known for the speed, stability, security and reliability. We can even make the use of Nginx as reverse proxy for enhancing the speed and efficiency of the site and system. So, if you have any questions, suggestions, feedback please write them in the comment box below. Thank you ! Enjoy :-)