require() 不工作 - NGINX PHP 配置问题

格伦博

已解决:文件未正确命名(header.php 而不是 layout.php)

我目前正在试验 NGINX 和 PHP。我尝试要求一些文件,但不幸的是,要求只是在寻找这样的东西:/path/to/root/subdir/index.php

配置的相关部分是PHP Playground Area请看一看。配置是否有问题,因此它只是在寻找包含 PHP 的 index.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 部分

html目录结构

格伦博

已解决:文件未正确命名(header.php 而不是 layout.php)

由于 treyBake 发现文件命名不正确。我使用了 layout.php 而不是 header.php。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章