已解决:文件未正确命名(header.php而不是layout.php)
我目前正在尝试NGINX和PHP。我尝试要求一些文件,但不幸的是,要求仅查找以下内容:/path/to/root/subdir/index.php
配置的相关部分是 PHP Playground Area 。请看一看。配置有问题吗,所以它只是在寻找index.php文件以包含PHP?
nginx错误日志仅显示:FastCGI sent in stderr: "PHP message: PHP Warning: require(layout.php): failed to open stream: No such file or directory in /var/www/html/php/index.php on line 7
我检查了我的结构。所需的layout.php文件位于var / www / html / php下的同一目录中。
我尝试要求的代码:
<?php
echo "<title>Playground</title>";
echo "Hello World";
require('layout.php');
require ('footer.php');
配置:
server {
# ======================
# BASIC CONFIGURATION
# ======================
listen 80;
server_name 172.17.1.75;
root /var/www/wordpress/;
index index.php index.html index.htm;
#try_files $uri $uri/ /index.php$is_args$args;
try_files $uri $uri/ /index.php?$query_string;
error_log /var/log/nginx/error.log info;
rewrite_log on;
# ======================
# WORDPRESS WEBSITE
# ======================
location / {
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}
# ======================
# PHP PLAYGROUND
# ======================
location /php {
root /var/www/html/;
# pass PHP scripts to FastCGI server
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}
# ======================
# ORDER PORTAL
# ======================
location ^~ /laravel {
alias /var/www/html/public;
try_files $uri $uri/ @laravel;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
}
location @laravel {
rewrite /laravel/(.*)$ /laravel/index.php?/$1 last;
}
# ======================
# PROXY PASS AREA
# ======================
# Proxy to holiday and work time management
location /azm {
proxy_pass http://172.17.1.28:8081;
}
# Proxy to old shop
location /shop2 {
proxy_pass http://172.17.1.28:8080;
}
# Proxy to order portal without laravel
location /portal {
proxy_pass http://172.17.1.28;
}
}
文件结构:
/ var / www / html-> laravel部分和php游乐场 / var / www / wordpress-> wordpress部分
答案 0 :(得分:0)
已解决:文件未正确命名(header.php而不是layout.php)
由于treyBake发现文件的名称不正确。代替header.php,我使用layout.php。