How to extend file extensions to be parsed by PHP

sudo vim /etc/php/7.0/fpm/pool.d/www.confsudo vim /etc/php/7.0/fpm/pool.d/www.conf
By default, PHP only parse files with .php extension.
We can extend extensions with security.limit_extensions directive.

sudo vim /etc/php/7.0/fpm/pool.d/www.conf
sudo vim /etc/php/7.0/fpm/pool.d/www.conf
; Limits the extensions of the main script FPM will allow to parse. This can
; prevent configuration mistakes on the web server side. You should only limit
; FPM to .php extensions to prevent malicious users to use other extensions to
; exectute php code.
; Note: set an empty value to allow all extensions.
; Default Value: .php
; You can add any extensions you want to be parsed as php
security.limit_extensions = .php .php3 .php4 .php5 .php7 .ler

sudo service php7.0-fpm restart

Config nginx:

/etc/nginx/nginx.conf
        location ~ \.(php|ler)$ {
            include fastcgi.conf;
            fastcgi_pass   unix:/run/php/php7.0-fpm.sock;
        }

        location ~ \.(php|ler)$ {
            root vhosts/$root_name;
            include fastcgi.conf;
            fastcgi_pass   unix:/run/php/php7.0-fpm.sock;
        }
sudo service php7.0-fpm restart 

sudo service nginx restart

Let's do the test.

cat index.ler<?php
phpinfo();
?>
.ler parsed as .php too, works well.

No comments:

Post a Comment

fixed: embedded-redis: Unable to run on macOS Sonoma

Issue you might see below error while trying to run embedded-redis for your testing on your macOS after you upgrade to Sonoma. java.la...