Raf*_*ael 4 php macos homebrew nginx
在让我列出我尝试过的内容之前:
我在主目录内的子目录中执行 php 代码时遇到问题。在 Nginx 上我得到这个
2016/08/23 09:13:40 [error] 39170#0: *13 FastCGI sent in stderr: "Access to the script
'/Users/user/portal3' has been denied (see security.limit_extensions)" while reading
response header from upstream, client: 127.0.0.1, server: localhost, request:
"GET /portal/v3/index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9001", host: "localhost"
Run Code Online (Sandbox Code Playgroud)
在 php-fpm 上这显示
[23-Aug-2016 09:13:40] WARNING: [pool dev] child 8305 said into stderr: "NOTICE: Access to the script '/Users/user/portal3' has been denied (see security.limit_extensions)"
Run Code Online (Sandbox Code Playgroud)
我已经尝试了一切,但在 Mac 上使用 Nginx / PHP-FPM 运行 php 没有成功
Ngnix 和 PHP-FPM 以 root 身份运行
PHP-FPM 配置了两个池:
[dev]
user=user
group=staff
listen=127.0.0.1:9001
listen.mode = 0666
pm = ondemand
pm.max_children = 10
pm.process_idle_timeout = 10s
pm.status_path = /status_user
catch_workers_output = yes
security.limit_extensions = .php
Run Code Online (Sandbox Code Playgroud)
server {
listen 80;
server_name localhost;
###root /var/www/;
access_log /usr/local/etc/nginx/logs/default.access.log main;
access_log /usr/local/etc/nginx/logs/default.scripts.log scripts;
location /portal/v3 {
alias /Users/user/portal3;
location ~ ^/portal/v3/(.+\.php)(/.*)$ {
#alias /Users/user/portal3;
index index.php;
# Mitigate https://httpoxy.org/ vulnerabilities
fastcgi_param HTTP_PROXY "";
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$2;#$fastcgi_script_name;
include fastcgi_params;
}
}
location = /info {
allow 127.0.0.1;
deny all;
rewrite (.*) /.info.php;
}
location / {
root /var/www/;
index index.php index.html index.htm;
include /usr/local/etc/nginx/conf.d/php-fpm;
}
error_page 404 /404.html;
error_page 403 /403.html;
}
Run Code Online (Sandbox Code Playgroud)
我已经使用自制软件安装了所有内容。现在我已经没有想法了,我来这里寻求帮助。
在您的PHP-FPM 配置中,您有一个名为security.limit_extensions
限制 FPM 允许解析的主脚本的扩展。这可以防止 Web 服务器端的配置错误。您应该仅将 FPM 限制为 .php 扩展名,以防止恶意用户使用其他扩展名来执行 php 代码。默认值:.php。
在您的情况下,因为您的location块不包含指令,所以当路径指向 .nginx 时,indexnginx 不知道使用作为默认索引文件。相反,它尝试将其作为 PHP 脚本执行,并且 PHP-FPM 提出了没有 .php 扩展名的安全限制。index.php/Users/user/portal3/Users/user/portal3
你的位置块应该看起来更像这样......
location /portal/v3 {
alias /Users/user/portal3;
index index.php;
location ~ ^/portal/v3/(.+\.php)(/.*)$ {
fastcgi_param HTTP_PROXY "";
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$2;#$fastcgi_script_name;
include fastcgi_params;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
23731 次 |
| 最近记录: |