Webserver installation on FreeBSD 10.1 (Nginx / PHP / MySQL).

1. Introduction

Webserver installation on FreeBSD 10.1 (Nginx / PHP / MySQL).

2. Installation

3. Automatic start

To enable automatic start of services, we edit the rc.conf :


4. MySQL service configuration

For a safe install, use the build-in script :

service mysql-server restart

5. PHP configuration

As a first step, we will configure php-fpm service :

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

Creation of the php.ini by using the production example :

vi php.ini

To change this variable :

vi /usr/local/etc/nginx/nginx.conf

Here is my configuration :

sysctl hw.ncpu

Create the directories and files for the logs:

mkdir vhosts

In this folder, we’ll create one file for each vhost :

server {
	listen  80;
        server_name  mydomain.com foo.mydomain.com;
        location / {
	    root   /usr/local/www/mydomain.com/www/;
            index  index.php index.html index.htm;
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/local/www/nginx-dist;
        location ~ /\.ht {
            deny  all;

We can start Nginx :

Performing sanity check on nginx configuration:
nginx: the configuration file /usr/local/etc/nginx/nginx.conf syntax is ok
nginx: configuration file /usr/local/etc/nginx/nginx.conf test is successful
Starting nginx.

One thought on “Webserver installation on FreeBSD 10.1 (Nginx / PHP / MySQL).”

Leave a Reply

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