Uploaded March 2015 | Updated September 2026, 2 weeks ago
How to install a web stack on FreeBSD: nginx, mysql/mariadb, and php/php-fpm. Co-host Christian explains the details of the nginx configuration file that we're using, so this is a great video if you've been wondering about what you're copy-pasting into nginx.conf for most tutorials on the Web. Instructions/Reference:
digitalocean.com/community/tutorials/how-to-install-an-nginx-mysql-and-php-femp-stack-on-freebsd-10-1 (we are following this with some modifications -- the process is almost identical no matter how you approach it)
pkg install nginx mysql56-server php56 php56-mysql
rehash
/etc/rc.conf
mysql_enable="YES"
nginx_enable="YES"
php_fpm_enable="YES"
cd /usr/local/etc
vi php-fpm.conf # sudo
listen = /var/run/php-fpm.sock
listen.owner = www
listen.group = www
listen.mode = 0660
cp php.ini-production php.ini # sudo
vi php.ini # sudo
cgi.fix_pathinfo=0
service php-fpm start # sudo
service mysql-server start # sudo
mysql_secure_installation # sudo
service mysql-server restart # sudo
service nginx start # sudo
vi nginx.conf # sudo
user www;
worker_processes 8;
error_log /var/log/nginx/error.log info;
access_log /var/log/nginx/access.log;
(configure server block)
root /usr/local/www/nginx;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
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;
}
mkdir -p /var/log/nginx # sudo
touch /var/log/nginx/access.log # sudo
touch /var/log/nginx/error.log # sudo
rm /usr/local/www/nginx # sudo
mkdir /usr/local/www/nginx # sudo
cp /usr/local/www/nginx-dist/index.html /usr/local/www/nginx # sudo
vi /usr/local/www/nginx/info.php # sudo
nginx -t # sudo
service nginx restart # sudo
TEST via HTTP
rm /usr/local/www/nginx/info.php # sudo
How to install a web stack on FreeBSD: nginx, mysql/mariadb, and php/php-fpm. Co-host Christian explains the details of the nginx configuration file that we're using, so this is a great video if you've been wondering about what you're copy-pasting into nginx.conf for most tutorials on the Web. Instructions/Reference:
digitalocean.com/community/tutorials/how-to-install-an-nginx-mysql-and-php-femp-stack-on-freebsd-10-1 (we are following this with some modifications -- the process is almost identical no matter how you approach it)
pkg install nginx mysql56-server php56 php56-mysql
rehash
/etc/rc.conf
mysql_enable="YES"
nginx_enable="YES"
php_fpm_enable="YES"
cd /usr/local/etc
vi php-fpm.conf # sudo
listen = /var/run/php-fpm.sock
listen.owner = www
listen.group = www
listen.mode = 0660
cp php.ini-production php.ini # sudo
vi php.ini # sudo
cgi.fix_pathinfo=0
service php-fpm start # sudo
service mysql-server start # sudo
mysql_secure_installation # sudo
service mysql-server restart # sudo
service nginx start # sudo
vi nginx.conf # sudo
user www;
worker_processes 8;
error_log /var/log/nginx/error.log info;
access_log /var/log/nginx/access.log;
(configure server block)
root /usr/local/www/nginx;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
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;
}
mkdir -p /var/log/nginx # sudo
touch /var/log/nginx/access.log # sudo
touch /var/log/nginx/error.log # sudo
rm /usr/local/www/nginx # sudo
mkdir /usr/local/www/nginx # sudo
cp /usr/local/www/nginx-dist/index.html /usr/local/www/nginx # sudo
vi /usr/local/www/nginx/info.php # sudo
nginx -t # sudo
service nginx restart # sudo
TEST via HTTP
rm /usr/local/www/nginx/info.php # sudo










