Last edit by philipp October 15, 2017 09:52

How to install WordPress on FreeBSD 10 with NGINX

This quick guide describes, how to install WordPress on FreeBSD 10.

Install Packages

root@wordpress:/ # pkg install nano git nginx php71
root@wordpress:/ # pkg install php71-mysqli php71-xml php71-hash php71-gd php71-curl php71-tokenizer php71-zlib php71-zip

Install wordPress

root@wordpress:/ # cd /usr/local/www/
root@wordpress:/usr/local/www # fetch http://wordpress.org/latest.tar.gz
root@wordpress:/usr/local/www # tar xvf latest.tar.gz
root@wordpress:/usr/local/www # chown -R www:www wordpress/
root@wordpress:/usr/local/www # nano /usr/local/etc/php-fpm.d/www.conf

FastCGI Config

...
listen = /var/run/php-fpm.sock
...
listen.owner = www
listen.group = www
listen.mode = 0660
...

Start Services

root@freebsd:/ # service nginx start
root@freebsd:/ # service php-fpm start
root@freebsd:/ # nano /usr/local/etc/nginx/nginx.conf

NGINX Config

user  www;
worker_processes  2;
error_log /var/log/nginx/error.log info;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    access_log /var/log/nginx/access.log;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  www.example.com;
        root /usr/local/www/wordpress;
        index index.php;

        location / {
            try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        error_page      500 502 503 504  /50x.html;
        location = /50x.html {
            root /usr/local/www/nginx-dist;
        }

        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $request_filename;
                include fastcgi_params;
        }
    }
}

Install MariaDB

root@wordpress:/usr/local/www # pkg install mariadb102-client mariadb102-server
root@wordpress:/usr/local/www # sysrc mysql_enable="YES"
root@wordpress:/usr/local/www # service mysql-server start
root@wordpress:/usr/local/www # mysql -u root -p
Enter password: [Enter]

Create Database

MariaDB [(none)]> CREATE DATABASE wordpress;
MariaDB [(none)]> CREATE USER wordpress@localhost IDENTIFIED BY '*********';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON wordpress.* TO wordpress@localhost;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit

WordPress Config

root@wordpress:/usr/local/www/wordpress # cp wp-config-sample.php wp-config.php
root@wordpress:/usr/local/www/wordpress # nano wp-config.php
//...
define('DB_NAME', 'wordpress');

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

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

/** MySQL hostname */
define('DB_HOST', 'localhost');
//...

Open WordPress in Browser


The content on this page is licensed under Creative Commons Attribution 4.0 International license.