How to install latest WordPress on FreeBSD 10 : enable web server

In my last post I decide to investigate how to install wordpress on FreeBSD 10 (latest version of FreeBSD at the moment). I use two methods of installation; first using ports and second using pkg. After try it myself I prefer to use pkg for future deployment for following reason :

  1. Fast installation; you don’t have to wait for hours as you did with ports.
  2. More secure; you have binary package. No need for compiler stuff installed in my server.

Of course ports can supply you with so many different options with its dialog but as Michael W Lucas said, he prefer to do other job that pay his bills than watch compile process. Me too 🙂

Ok, back to wordpress. Last install is not complete one as I don’t see web server and database.

pkg info result

# pkg info

ca_root_nss-3.17.1             The root certificate bundle from the Mozilla Project
curl-7.38.0_2                  Non-interactive tool to get files from FTP, GOPHER, HTTP(S) servers
freetype2-2.5.3_2              Free and portable TrueType font rendering engine
jpeg-8_5                       IJG’s jpeg compression utilities
kbproto-1.0.6                  KB extension headers
libICE-1.0.9,1                 Inter Client Exchange library for X11
libSM-1.2.2_2,1                Session Management library for X11
libX11-1.6.2_2,1               X11 library
libXau-1.0.8_2                 Authentication Protocol library for X11
libXaw-1.0.12_2,2              X Athena Widgets library
libXdmcp-1.1.1_2               X Display Manager Control Protocol library
libXext-1.3.2_2,1              X11 Extension library
libXmu-1.1.2_2,1               X Miscellaneous Utilities libraries
libXp-1.0.2_2,1                X print library
libXpm-3.5.11_2                X Pixmap library
libXt-1.1.4_2,1                X Toolkit library
libpthread-stubs-0.3_6         This library provides weak aliases for pthread functions
libxcb-1.10_2                  The X protocol C-language Binding (XCB) library
libxml2-2.9.1_1                XML parser library for GNOME
pcre-8.35_1                    Perl Compatible Regular Expressions library
php5-5.4.33_1                  PHP Scripting Language
php5-curl-5.4.33_1             The curl shared extension for php
php5-gd-5.4.33_1               The gd shared extension for php
php5-mysql-5.4.33_1            The mysql shared extension for php
php5-tokenizer-5.4.33_1        The tokenizer shared extension for php
php5-xml-5.4.33_1              The xml shared extension for php
php5-zip-5.4.33_1              The zip shared extension for php
pkg-1.3.8_3                    Package manager
png-1.5.18                     Library for manipulating PNG images
printproto-1.0.5               Print extension headers
t1lib-5.1.2_4,1                Type 1 font rasterization library for Unix/X11
wordpress-4.0,1                State-of-the-art semantic personal publishing platform
xextproto-7.3.0                XExt extension headers
xproto-7.0.26                  X11 protocol headers

Lets continue :

Install Web Server

I use mod_php5 that will automatically install apache as its dependency.

# pkg install mod_php5-5.4.33_1,1
Updating FreeBSD repository catalogue…
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 9 packages will be affected (of 0 checked):

New packages to be INSTALLED:
mod_php5: 5.4.33_1,1
apache24: 2.4.10_2
expat: 2.1.0_1
perl5: 5.16.3_11
apr: 1.5.1.1.5.4
gdbm: 1.11_2
indexinfo: 0.2
gettext: 0.18.3.1_1
db5: 5.3.28_2

The process will require 134 MB more space.
32 MB to be downloaded.

Proceed with this action? [y/N]: y

If you see from the message above in section : New packages to be INSTALLED you see apache24 will be installed. Press y to continue.

At this stage almost all required component installed. Database is the last one.

Install mysql server

# pkg install mysql56-server
Updating FreeBSD repository catalogue…
FreeBSD repository is up-to-date.
All repositories are up-to-date.
The following 2 packages will be affected (of 0 checked):

New packages to be INSTALLED:
mysql56-server: 5.6.21
mysql56-client: 5.6.21

The process will require 130 MB more space.
10 MB to be downloaded.

Proceed with this action? [y/N]: y

Enable web server and database server

# echo 'apache24_enable=YES' >> /etc/rc.conf

# echo 'mysql_enable=YES' >> /etc/rc.conf

Run the service for first time

# /usr/local/etc/rc.d/apache24 start

# /usr/local/etc/rc.d/mysql-server start

Move wordpress to apache24 data

# mv /usr/local/www/wordpress /usr/local/www/apache24/data/

or create symbolic link to apache24 data

# ln -s /usr/local/www/wordpress /usr/local/www/apache24/data/

Configure php to work with Apache

# ee /usr/local/etc/apache24/httpd.conf

Read the file or use CTRL+Y to find this line : directoryindex

Add index.php as first file to find.

Change

<IfModule dir_module>
DirectoryIndex index.html
</IfModule>

into

<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>

Find for mime_module and add these lines :

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

Under

TypesConfig etc/apache24/mime.types line.

p.s : you can download my httpd.conf here.

Restart Apache

# /usr/local/etc/rc.d/apache24 restart
Performing sanity check on apache24 configuration:
AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1. Set the ‘ServerName’ directive globally to suppress this message
Syntax OK
Stopping apache24.
Waiting for PIDS: 2286.
Performing sanity check on apache24 configuration:
AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1. Set the ‘ServerName’ directive globally to suppress this message
Syntax OK
Starting apache24.
AH00558: httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1. Set the ‘ServerName’ directive globally to suppress this message
root@freebsd-2177:/usr/local/etc/apache24 #

If you see error like this one then you’ll need to configure /etc/host to register server name.

# echo '104.156.227.119    wordpress.rasyid.net' >> /etc/hosts

That command add new line in /etc/hosts with value 104.156.227.119    wordpress.rasyid.net.

Retry restart apache

# /usr/local/etc/rc.d/apache24 restart
Performing sanity check on apache24 configuration:
Syntax OK
Stopping apache24.
Waiting for PIDS: 2312.
Performing sanity check on apache24 configuration:
Syntax OK
Starting apache24.

Great. At this stage everything work well. Ready to continue install wordpress by visiting this address :

http://public_ip/wordpress

In my case, I use vultr then I type :

http://104.156.227.119/wordpress/

Then I get this

install wordpress on freebsd - choose language

Click Continue after choose language.

When you see database information like this one

install wordpress on freebsd - enter database details

To fill database name, user that get access and the password you can create it from command line.

# mysql -uroot -p

Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.21 Source distribution

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on wordpress.* to alam@localhost identified by ‘wp123456’ with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql>

 

Password for root at first time is empty.

After run this command you have this information :

Database name : wordpress

User Name : alam

Password : wp123456

Database host : localhost

Table prefix : wp_

Entering those information on provided screen then you’ll see this

install wordpress on freebsd - run the install

Wait for while to see this screen

install wordpress on freebsd - enter title, username and password

Click Install WordPress to see this screen.

install wordpress on freebsd - wordpress successfully installed

At this stage wordpress is installed. But I need to find other problem that might exist so I try login to wordpress admin by visiting http://104.156.227.119/wordpress/wp-admin

I successfully login but I got this error :

Fatal error: Call to undefined function hash()

To fix that error I install php5-hash and php5-session

# pkg install php5-session php5-hash

and restart Apache

# apachectl restart

Refresh my wordpress and error is gone. Trying add plugin work well. So far the process work well.

Summary

Install wordpress in FreeBSD 10 is not difficult. You can shave the process by install dependency first then wordpress.