我在 centos 7 上安装了 nginx 和 slim 框架。
- 第一个问题是配置如下。
- 然后我尝试了
http://myip/apiv5
一次又一次,结果得到 502。因此,接下来我将其更改为http://myip/apiv5/token
错误。rewrite or internal redirection cycle while internally redirecting to "/apiv5/public/index.php"
try_files $uri $uri/ /apiv5/public/index.php$is_args$args=404;
- 所以现在我得到 404,但问题是文件夹确实存在,文件也确实存在。我已将文件夹权限设置为,
0755
所有权设置为nginx:nginx
,其中所有文件也都设置为,并且它们的权限为0644
。 我的问题是,为什么我不断收到 403 权限被拒绝,即使我尝试将 try_files 选项更改为例如
/apiv5/public/index.php
http { log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; server_tokens off; access_log /var/log/nginx/access.log main;
sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; include /etc/nginx/mime.types; default_type application/octet-stream; # Load modular configuration files from the /etc/nginx/conf.d directory. # See http://nginx.org/en/docs/ngx_core_module.html#include # for more information. include /etc/nginx/conf.d/*.conf; include /etc/nginx/blockuseragents.rules; limit_conn_zone $binary_remote_addr zone=addr:5m; server { listen 80 default_server; listen [::]:80 default_server; server_name _; server_tokens off; #root /usr/share/nginx/html; root /var/www/html/; index index.php index.html home.html; # Load configuration files for the default server block. #include /etc/nginx/default.d/*.conf; include /etc/nginx/default.d/*.conf; location ~ ^/apiv5 { try_files $uri $uri/ /apiv5/public/index.php$is_args$args; } location ~ .php$ { include fastcgi.conf; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_intercept_errors on; fastcgi_pass 127.0.0.1:9000; } if ($request_method !~ ^(GET|HEAD|POST)$) { return 444; } limit_conn addr 3; }