If usage in Nginx Server Configuration
The configuration of Nginx Server takes php as an example, as follows:
Server {
Root/var/webproject/www/mytools-php;
Index index.html index. php;
5 location ~. +? \. Php (/| $ ){
Fastcgi_split_path_info ^ (. +? \. Php) (. *) $;
If (! -F $ document_root $ fastcgi_script_name ){
Return 404;
}
If ($ fastcgi_script_name! =/Index. php ){
Return 404;
}
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Include/opt/nginx-1.8/conf/fastcgi_php_params;
}
}
In nginx, if operations such as &, | and so on cannot be performed. Therefore, we need to judge step by step. The above configuration first checks whether the requested file exists in the root directory of the website, if the request does not exist, 404 is returned. If the request exists, the system checks whether the requested file is an index. php. If not, 404 is returned.
Determine whether the variables and strings are equal using '=' or '! = ';
'-F' and '! -F' can be used to determine whether a file exists;
'~ 'And '!~ 'Is a case-sensitive regular expression ,'~ * 'And '!~ * 'Is a case-insensitive regular expression;
'-D' indicates whether the directory exists;
'-E and '! -E' is used to determine whether a file, directory, or symbolic connection exists;
'-X' and '! -X' is used to determine whether an executable file exists;
For more Nginx tutorials, see the following:
Deployment of Nginx + MySQL + PHP in CentOS 6.2
Build a WEB server using Nginx
Build a Web server based on Linux6.3 + Nginx1.2 + PHP5 + MySQL5.5
Performance Tuning for Nginx in CentOS 6.3
Configure Nginx to load the ngx_pagespeed module in CentOS 6.3
Install and configure Nginx + Pcre + php-fpm in CentOS 6.4
Nginx installation and configuration instructions
Nginx log filtering using ngx_log_if does not record specific logs
Nginx details: click here
Nginx: click here
This article permanently updates the link address: