Last edit by philipp October 15, 2017 09:52

How to install Symfony 3 on FreeBSD 10 with NGINX

This quick guide describes how to install Symfony 3 on FreeBSD 10 with NGINX.

root@freebsd:/ # pkg install nano git nginx php71
root@freebsd:/ # pkg install php71-sqlite3 php71-xml php71-opcache php71-phar php71-json php71-mbstring php71-openssl php71-filter php71-pdo_sqlite php71-dom php71-ctype php71-iconv php71-session php71-simplexml php71-tokenizer php71-zip

Register Services

root@freebsd:/ # sysrc nginx_enable="YES"
root@freebsd:/ # sysrc php_fpm_enable="YES"
root@freebsd:/ # 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  example.com www.example.com;
        root /usr/local/www/nginx;
        index index.php index.html index.htm;

        location / {
            try_files $uri $uri/ =404;
        }

        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;
        }
    }
}

Further Information


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