php - Nginx 在子目录中访问 PHP(已解决)
问题描述
已解决:我缺少 simplexml,我只需要安装它(Ubuntu)sudo apt-get install php-xml
我正在尝试访问该 presskit 系统使用的具有 index.php 和 sheet.php 的子目录 /presskit。不幸的是,我不太清楚如何访问它,我得到 404,被重定向到我的主页,或者它只是说无法处理请求。
我试图访问的文件位于 /var/www/html/spreadcamp.com/public_html/presskit/index.php
我试图通过访问https://spreadcamp.com/presskit/index.php来访问
有人知道我在做什么错吗?
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name spreadcamp.com www.spreadcamp.com;
return 301 https://$server_name$request_uri;
}
server {
# SSL configuration
#
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
ssl_certificate /etc/ssl/cert.pem;
ssl_certificate_key /etc/ssl/key.pem;
ssl_client_certificate /etc/ssl/cloudflare.crt;
ssl_verify_client on;
root /var/www/html/spreadcamp.com/public_html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.php;
server_name spreadcamp.com www.spreadcamp.com;
proxy_cache one;
gzip off;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
location ^~ /presskit {
index index.php;
alias /var/www/html/spreadcamp.com/public_html/presskit;
if (!-e $request_filename) { rewrite ^ /presskit/index.php last; }
location ~ \.php$ {
if (!-f $request_filename) { return 404; }
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
}
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
解决方案
推荐阅读
- java - Java中通用括号之间没有空格的推理
- python - 如何在 Python 中从 CSV 文件创建字典?
- flutter - 如何在另一个代码生成器的顶部运行代码生成器?
- ruby-on-rails - 在 Rails 中按日期获取下一个/上一个记录(并在同一天处理多个日期)
- php - 如何在laravel中的if返回变量中使用isset
- python - 无法将符号张量 (truediv_17:0) 转换为 numpy 数组
- authentication - Nightwatch.js:运行 .locateMultipleElements() 协议操作时出错:无效选择器:指定了无效或非法的选择器
- c# - 我可以在 VS 中构建这个项目,但不能使用 msbuild
- c# - 如何在 Windows 服务中使用谷歌日历 API?
- c - 光线追踪器光漫射的问题