在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代码了。希望这些信息对你有所帮助!