Heim > Fragen und Antworten > Hauptteil
大神们,在网站的根目录有个index.php文件,通过浏览器访问是可以正常输出内容的,但我在Linux系统中执行php index.php 无法解释。是不是我的方法错了,那我要怎么做
PHP中文网2017-04-11 10:33:34
PHP安装目录/bin/php -v
PHP安装目录/bin/php-cgi -v
# 可以看到PHP版本信息的话,则执行:
export PATH=$PATH:PHP安装目录/php/bin
看不到信息,去安装PHP相关包
大家讲道理2017-04-11 10:33:34
需要先安装php命令行解释器,比如Ubuntu/Debian可以这样:
sudo apt-get install php5-cli
sudo apt-get install php7.0-cli
PHP几个SAPI对应的包:
apt-cache search php7.0
php7.0-cli - command-line interpreter for the PHP scripting language
php7.0-cgi - server-side, HTML-embedded scripting language (CGI binary)
php7.0-fpm - server-side, HTML-embedded scripting language (FPM-CGI binary)
libapache2-mod-php7.0 - server-side, HTML-embedded scripting language (Apache 2 module)