what does it mean “(include_path='.:/usr/share/pear:/usr/share/php')”?

后端 未结 7 2314
暗喜
暗喜 2021-02-18 16:31

I have file structure on EC2 like : but facing some file referencing problem.

index.php
-db
  -config.php
-cron
  -cron1.php

I have tried file

7条回答
  •  攒了一身酷
    2021-02-18 17:13

    Solution to the problem

    as mentioned by Uberfuzzy [ real cause of problem ]

    If you look at the PHP constant [PATH_SEPARATOR][1], you will see it being ":" for you.

    If you break apart your string ".:/usr/share/pear:/usr/share/php" using that character, you will get 3 parts

    • . (this means the current directory your code is in)
    • /usr/share/pear
    • /usr/share/ph

    Any attempts to include()/require() things, will look in these directories, in this order.

    It is showing you that in the error message to let you know where it could NOT find the file you were trying to require()

    That was the cause of error.

    Now coming to solution

    1. Step 1 : Find you php.ini file using command php --ini ( in my case : /etc/php5/cli/php.ini )
    2. Step 2 : find include_path in vi using esc then press /include_path then enter
    3. Step 3 : uncomment that line if commented and include your server directory, your path should look like this include_path = ".:/usr/share/php:/var/www//"
    4. Step 4 : Restart apache sudo service apache2 restart

    This is it. Hope it helps.

提交回复
热议问题