在Ubuntu上使用PhpStorm進行遠程PHP調試,可以按照以下步驟進行配置和操作:
安裝PHP和Xdebug:
sudo apt-get update
sudo apt-get install php php-xdebug
配置php.ini:
編輯 /etc/php/7.x/apache2/php.ini
文件(其中7.x是你的PHP版本),添加或修改以下行:
zend_extension=/usr/lib/php/20170718/xdebug.so
xdebug.remote_enable=1
xdebug.remote_host=127.0.0.1
xdebug.remote_port=9000
xdebug.remote_autostart=1
重啟Apache服務:
sudo service apache2 restart
打開PhpStorm,轉到 File > Settings
(或 Preferences
,取決于你的操作系統)。
配置PHP解釋器和服務器:
Languages & Frameworks > PHP > CLI Interpreter
中,選擇與服務器上安裝的PHP版本相匹配的解釋器。PHP > Servers
中,點擊 +
號,添加一個新的服務器配置。填寫服務器名稱、主機名(或IP地址)和端口(與 php.ini
中的 xdebug.remote_port
一致,例如9000)。配置Deployment(可選):
Deployment
選項卡中,點擊 +
號,選擇 FTP
、SFTP
或 FTPS
,根據你的服務器配置選擇合適的協議。配置Debug:
PHP > Debug
中,確保 Debug port
與 php.ini
中的 xdebug.remote_port
一致。OK
保存配置。Shift + F9
)啟動調試服務器。確保在瀏覽器的插件商店中安裝了Xdebug Helper(推薦使用Chrome插件),并配置其 IDE Key
為 PHPSTORM
。
通過以上步驟,你就可以在Ubuntu上使用PhpStorm進行遠程調試PHP代碼了。希望這些信息對你有所幫助!