The try_files directive is used to check if a file exists and serve it, or fallback to the next option. In this case, the try_files $uri $uri/ /index.php?$args; directive is checking if the requested URI exists as a file or directory, and if not, it is serving the index.php file with any query string parameters.
The @php location block is used as a fallback for any PHP files that do not exist. It passes the request to the PHP FastCGI process for handling.
If you are not using any other @php location blocks in your configuration, you can safely remove the try_files /does_not_exists @php; line from the location ~ [^/]\.ph(p\d*|tml)$ block.
If you are using other @php location blocks, you can keep the try_files /does_not_exists @php; line, as it will ensure that any PHP files that do not exist are passed to the PHP FastCGI process for handling.
In terms of performance, using @php instead of index.php may be slightly faster, as it avoids the overhead of checking if the index.php file exists. However, the difference is likely to be negligible in most cases.
Here is the updated configuration without the try_files /does_not_exists @php; line:
server {
index index.php index.html;
disable_symlinks if_not_owner from=$root_path;
ssi on;
gzip on;
gzip_comp_level 5;
gzip_disable "msie6";
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript;
location / {
try_files $uri $uri/ /index.php?$args;
location ~ [^/]\.ph(p\d*|tml)$ {
# Remove this line
}
location ~* ^.+\.(jp1g|jp1eg|gif|pn1g|svg|js|css|mp13|ogg|mpe?g|avi|zip|gz|bz2?|rar|swf)$ {
expires 24h;
}
}
location @php {
fastcgi_index index.php;
fastcgi_param PHP_ADMIN_VALUE "sendmail_path = /usr/sbin/sendmail -t -i -f [email protected]";
fastcgi_pass unix:/var/www/php-fpm/4.sock;
fastcgi_split_path_info ^((?U).+\.ph(?:p\d*|tml))(/?.+)$;
try_files $uri =404;
include fastcgi_params;
}
listen X.X.X.X:443 ssl http2;
}