更新时间:2022-12-31 10:58:58
经过误会,我终于明白了你要做什么. 您应该检查服务器配置文件.您在使用apache2或其他服务器软件吗?
After misunderstanding, I finally got what you are trying to do. You should check your server configuration files; are you using apache2 or some other server software?
查找以LoadModule php
开头的行...
从那里开始可能有名为mods
或类似名称的配置文件/目录.
Look for lines that start with LoadModule php
...
There probably are configuration files/directories named mods
or something like that, start from there.
您还可以检查php -r 'phpinfo();' | grep php
的输出,并将行与Web服务器中的phpinfo();
进行比较.
You could also check output from php -r 'phpinfo();' | grep php
and compare lines to phpinfo();
from web server.
(因此您可以在控制台中粘贴/编写代码)
(so you can paste/write code in the console)
php -a
php -f file.php
php -f file.php > results.html
要只运行一小部分,一行或类似内容,可以使用:
To run only small part, one line or like, you can use:
php -r '$x = "Hello World"; echo "$x\n";'
如果您正在运行linux,请在控制台上执行man php
.
If you are running linux then do man php
at console.
如果您需要/希望通过fpm运行php,请使用cli fcgi
if you need/want to run php through fpm, use cli fcgi
SCRIPT_NAME="file.php" SCRIP_FILENAME="file.php" REQUEST_METHOD="GET" cgi-fcgi -bind -connect "/var/run/php-fpm/php-fpm.sock"
其中/var/run/php-fpm/php-fpm.sock是您的php-fpm套接字文件.
where /var/run/php-fpm/php-fpm.sock is your php-fpm socket file.