1 个 nginx 服务器多个 php 服务器
1 nginx server multiple php servers
我错过了什么?
让我们说这个简单的 conf:
upstream php {
server 111.1111.1111.1111:9000;
}
server {
listen 80 reuseport;
root /var/www/html/public/;
index index.php;
location / {
set $orig_uri $uri;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
ssi on;
include snippets/fastcgi-php.conf;
fastcgi_param REQUEST_URI $orig_uri$is_args$args;
fastcgi_cache_key "$scheme$request_method$orig_uri$is_args$args";
add_header X-Cache-Key $scheme$request_method$orig_uri$is_args$args;
add_header X-Cache $upstream_cache_status;
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass php;
}
}
nginx 如何访问不同服务器上的“/var/www/html/public/”?它如何知道文件是否存在?我试着玩它,我总是得到
404 Not Found
如果 php 服务器没有安装 nginx
所以我遗漏了一些东西但无法理解是什么
How does nginx gonna access "/var/www/html/public/" on different
server? how will it know if the file exists or not exists?
nginx
无法确定文件是否存在于上游 PHP 服务中。它会将脚本路径名传递给 PHP 服务,如果它不存在,PHP 服务将 return 404 响应。
PHP服务可能使用了fastcgi_param SCRIPT_FILENAME
参数来查找上游脚本文件。该参数应在您的 snippets/fastcgi-php.conf
文件中定义。
这通常设置为 $document_root$fastcgi_script_name
的值。 $document_root
的值由配置文件中的 root
指令设置。
只有当上游服务器上的脚本被放置在与 nginx
服务器指定的完全相同的目录层次结构中时,这才会起作用。否则,您可能需要手工制作 SCRIPT_FILENAME
参数的值。
我错过了什么? 让我们说这个简单的 conf:
upstream php {
server 111.1111.1111.1111:9000;
}
server {
listen 80 reuseport;
root /var/www/html/public/;
index index.php;
location / {
set $orig_uri $uri;
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
ssi on;
include snippets/fastcgi-php.conf;
fastcgi_param REQUEST_URI $orig_uri$is_args$args;
fastcgi_cache_key "$scheme$request_method$orig_uri$is_args$args";
add_header X-Cache-Key $scheme$request_method$orig_uri$is_args$args;
add_header X-Cache $upstream_cache_status;
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
#fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass php;
}
}
nginx 如何访问不同服务器上的“/var/www/html/public/”?它如何知道文件是否存在?我试着玩它,我总是得到
404 Not Found
如果 php 服务器没有安装 nginx
所以我遗漏了一些东西但无法理解是什么How does nginx gonna access "/var/www/html/public/" on different server? how will it know if the file exists or not exists?
nginx
无法确定文件是否存在于上游 PHP 服务中。它会将脚本路径名传递给 PHP 服务,如果它不存在,PHP 服务将 return 404 响应。
PHP服务可能使用了fastcgi_param SCRIPT_FILENAME
参数来查找上游脚本文件。该参数应在您的 snippets/fastcgi-php.conf
文件中定义。
这通常设置为 $document_root$fastcgi_script_name
的值。 $document_root
的值由配置文件中的 root
指令设置。
只有当上游服务器上的脚本被放置在与 nginx
服务器指定的完全相同的目录层次结构中时,这才会起作用。否则,您可能需要手工制作 SCRIPT_FILENAME
参数的值。