linux执行php, 用IE可以执行,但是用命令就不能,请教
root用户执行命令为 /usr/local/php/bin/php -f /usr/local/apache2/htdocs/test.php
test.php权限为:-rwxr-xr-x. 1 root root 22 4月 10 15:04 test.php
执行结果为:PHP Fatal error: Unknown: Failed opening required '/usr/local/apache2/htdocs/test.php' (include_path='.:/usr/local/php/lib/php') in Unknown on line 0
Fatal error: Unknown: Failed opening required '/usr/local/apache2/htdocs/test.php' (include_path='.:/usr/local/php/lib/php') in Unknown on line 0
虚心请教,本人第一次在linux上运行php, 一天了,都没搞好。
回复讨论(解决方案)
看下文件目录位置是否正确
运行路径?
php命令行运行时,初始路径是运行所在路径而不是php文件所在路径,所有里面的相对路径都根据这个初始路径计算得到
说的很明确了,没有这个文件/usr/local/apache2/htdocs/test.php。
Fatal error: Unknown: Failed opening required '/usr/local/apache2/htdocs/test.php' (include_path='.:/usr/local/php/lib/php') in Unknown on line 0
应该是相对路径导致的,请换成绝对路径
说的很明确了,没有这个文件/usr/local/apache2/htdocs/test.php。
Fatal error: Unknown: Failed opening required '/usr/local/apache2/htdocs/test.php' (include_path='.:/usr/local/php/lib/php') in Unknown o……
你好,好像不是相对路径导致的,假设我执行一个没有的文件,比如:
[root@localhost htdocs]# /usr/local/php/bin/php -f /usr/local/apache2/htdocs/test322323.php
Could not open input file: /usr/local/apache2/htdocs/test322323.php
提示的是Could not open input file。 这样就说明文件是找到了的。
运行路径?
php命令行运行时,初始路径是运行所在路径而不是php文件所在路径,所有里面的相对路径都根据这个初始路径计算得到
你好,不太懂,能具体解释一下吗。谢谢
[root@localhost htdocs]# /usr/local/php/bin/ php4 -f /usr/local/apache2/htdocs/test.php
-bash: /usr/local/php/bin/php4: 没有那个文件或目录
同样的,我把php改为php4,提示“ 没有那个文件或目录”,说明php也是可以找到的
linux 不懂,windows命令行是这样的
假设aaa.php里面有一句include ../bbb.php
c:\abc>php d:\xxx\aaa.php
这时,程序是会寻找c:\bbb.php,并且报错找不到,因为bbb.php是存在于 d:\ 这个目录的
要善用 __DIR__ 和 __FILE__
关权限什么事?你出错都是include的,肯定是路径问题
已解决。 原因和下面的网页上的原因一致。
http://www.cnblogs.com/zcy_soft/archive/2012/12/27/2835757.html
解决就好
真复杂的问题,还好我不学无术,不研究这个……pass
等真的遇上,再郁闷地google两三天好了
已解决。 原因和下面的网页上的原因一致。
http://www.cnblogs.com/zcy_soft/archive/2012/12/27/2835757.html
这个原因啊,其实想说楼主还是没把问题细节说全,你的问题和我们猜测的不是一回事,导致不好找到原因。
呵呵,原来是 php 代码问题
但是你们并没有一个询问过楼主程序内容是什么
就想当然的,头痛医头脚痛医脚了

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics





Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Sending JSON data using PHP's cURL library In PHP development, it is often necessary to interact with external APIs. One of the common ways is to use cURL library to send POST�...
