Nginx and PHP-FPM with the Fabrication Framework

Nginx (pronounced "engine x") is a free, open-source, high-performance HTTP server. Nginx is known for its stability, rich feature set, simple configuration, and low resource consumption. This tutorial shows how you can install and configure Nginx on a Debian based system. PHP5 support (through PHP-FPM) and MySQL support (LEMP = Linux + Nginx + MySQL + PHP-FPM).

Install the LEMP stack.

sudo apt-get install nginx php5-fpm mysql-server mysql-client

The following nginx server configuration is from the Fabrication Framework project. This allow for each userspace account to have a seperate workspace, nginx, fpm, configuration.

##
# Fabrication Framework nginx configuration.
##
server {
listen  80;

root /home/davro/workspace/project-davro.net/www;

index index.html index.php;
server_name project-davro.net;

location / {
root /home/davro/workspace/project-davro.net/www;
rewrite ^(.+)$ /index.php;  
}

location ~* .(css|js|html)$ {
root /home/davro/workspace/project-davro.net/www;
}

location ~* .(gif|jpg|png)$ {
	expires 30d;
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ .php$ {
fastcgi_index  index.php;
fastcgi_pass   unix://home/davro/php5-fpm.sock;

fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
include	fastcgi_params;
}
}

PHP-FPM configuration taken from a Fabrication Userspace account /etc/php5/fpm/pool.d/davro.conf

[davro]
user = davro
group = davro
listen = /home/davro/php5-fpm.sock
pm = dynamic
pm.max_children = 12
pm.start_servers = 1
pm.min_spare_servers = 1
pm.max_spare_servers = 1
;pm.max_requests = 500
chdir = /

;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com
;php_flag[display_errors] = off
php_admin_value[error_log] = /home/davro/php5-fpm.error_log
;php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = 64M
2017-12-07
YouTube Twitter GitHub