As we mentioned is an earlier chapter, linking modules into a multi-threaded HTTP server requires that the code in the module be thread safe. Nginx works around this by utilizing the fastcgi
protocol to interact with interpreters rather than linking them directly into the process. This does not have quite the performance of the more native approach, but you can limit what content runs through the processor.
Configuring on Ubuntu 14.04:
Install the PHP FastCGI wrapper:
sudo apt-get install php5-fpm
Modify php's configuration file to disable
cgi.fix_pathinfo
, this setting opens the door to security vulnerabilities by allowing PHP to guess at what your request was intending to request:sed 's/.*cgi.fix_pathinfo=.*/cgi.fix_pathinfo=0/g' /etc/php5/fpm/php.ini service php5-fpm restart
Configure
nginx
to talk to the php5-fpm daemon (default is/etc/nginx/sites-available/default
) within the relevant server definitions:location ~ \.php$ { try_files...