When I create a new webapp conf in Nginx I use the following template:
server {
root /var/www/html/${domain};
server_name ${domain} www.${domain};
location ~* \.(jpg|jpeg|png|gif|ico|css|js|ttf|woff|pdf)$ {
expires 365d;
}
location / {
index index.php index.html index.htm fastcgi_index;
try_files $uri $uri =404 $uri/ /index.php?$args;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Note the following
location
block in that template:
location ~ \.php$ {
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
Is there a "safe" way to make it version agnostic (that is, not to target version 7.0 specifically, or any other version, for that matter).
Do you know a way to do that? I'm not sure regex is the best way to go, maybe there's just another way to config this.
## Update
BTW, these 7.0 directives can **also** be a bit painful - you sometimes just want to run a script, without starting to measure versions:
sed -i 's/post_max_size \= .M/post_max_size \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i 's/upload_max_filesize \= .M/upload_max_filesize \= 200M/g' /etc/php/7.0/fpm/php.ini
sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g" /etc/php/7.0/fpm/php.ini
/etc/init.d/php7.0-fpm restart && systemctl restart nginx.service
Asked by Arcticooling
(1 rep)
Dec 31, 2017, 05:03 AM
Last activity: Dec 31, 2017, 06:06 PM
Last activity: Dec 31, 2017, 06:06 PM