php - 无法设置 PHP include_path

标签 php ubuntu path include-path

我已经在 var/www/html 中上传了我所有的文件,在我的一个 php 文件中我有这一行:

require_once('libraries/stripe/init.php');

我的文件夹结构如下:

www
 -html/
       -libraries
           -> Stripe -> init.php
       -register.php

我不断收到此错误消息:

Warning: require_once(libraries/Stripe/init.php): failed to open stream: No such file or directory in /var/www/html/register.php on line 116

Fatal error: require_once(): Failed opening required 'libraries/Stripe/init.php' (include_path='.:/usr/share/php:/var/www/html/') in /var/www/html/register.php on line 116

我的php.ini文件以前是这样的

include_path= ".:/usr/local/php/pear/"

但根据这里的一些答案,我将其更改为

include_path='.:/usr/share/php:/var/www/html/'

但它不起作用!

编辑:在我的库文件夹中,我有一个名为 index.php 的文件,内容是:

<?php 
header("Location: ../"); die();

最佳答案

我不会把库路径留给这样的机会:

require_once(__DIR__ . '/libraries/Stripe/init.php');

这将确保您使用当前运行 脚本的绝对目录路径包含脚本。

更新

Failed opening required '/var/www/html/libraries/Stripe/init.php'

好吧,那么文件就是不存在;如果此文件是由其他工具生成的,例如composer,它需要在新服务器上再次完成(或者理想情况下在每次部署时)。

i think the problem is my Stripe folder is in "s" but I'm using capital "S". is there anyway to make not case sensitive?

与 Windows 不同,Linux 下的文件系统默认区分大小写(甚至不确定是否可以更改)。确保始终如一地使用大写字母。

关于php - 无法设置 PHP include_path,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30906376/

相关文章:

php - 在 REST API 中使用时,操作 POST 数据以使用 Symfony2 表单

windows - PyCharm:未找到 Anaconda 安装

php - 在逗号分隔值字段 Laravel 5.1 中查找

php - 如何在php和js中结合使用alert

php - Laravel - Sentinel 用户与 eloquent 用户不同

ubuntu - 通过 Chef 执行 add-apt-repository 的正确方法是什么?

python - ubuntu中存储的日期和时间在哪里

ubuntu - 在 Ubuntu crontab 中运行 JAR 文件失败

python - django 1.11 中找不到静态文件

javascript - 捕捉 SVG 路径周围的可单击轮廓