linux下安裝php指令的方法是:1、開啟etc/profile設定檔;2、增加設定【export PATH=$PATH:/usr/local/php/lib】;3、執行【source /etc/profile】命令。
具體方法:
(推薦教學:php教學)
1、在etc /profile檔案下增加配置export PATH=$PATH:/usr/local/php/lib
檔案內容如下:
if [ "$HISTCONTROL" = "ignorespace" ] ; then export HISTCONTROL=ignoreboth else export HISTCONTROL=ignoredups fi export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL export PATH=$PATH:/usr/local/php/lib // 增加此段代码(php的路径) #export PATH =/usr/local/php/bin/php # By default, we want umask to get set. This sets it for login shell # Current threshold for system reserved uid/gids is 200
2、新增好路徑後,執行下列程式碼
source /etc/profile
source /etc/profile //centos 7
如果報錯:
[root@localhost html]# php -m -bash: php: command not found
解決方法:
# which php //结果是/usr/local/php/bin/php # ln -s /usr/local/php/bin/php /usr/bin/php
3、測試
# php -m # php -i
以上是linux下如何安裝php指令的詳細內容。更多資訊請關注PHP中文網其他相關文章!