在Ubuntu上使用PhpStorm进行远程开发的步骤如下:
sudo apt-get update
sudo apt-get install php php-xdebug
php.ini
:sudo nano /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
sudo service apache2 restart
File
> Settings
(或 Preferences
,取决于你的操作系统)。Languages & Frameworks
> PHP
> Debug
。Add
,在弹出的对话框中选择 Remote
作为解释器类型。Host
字段中输入远程服务器的IP地址或域名(例如 127.0.0.1
),在 Port
字段中输入 9000
(与php.ini
中的配置一致)。Test Connection
以确保连接成功,然后点击 OK
以添加远程解释器。Run
> Edit Configurations
。点击左上角的加号图标,选择 PHP Web Page
。在 Document root
字段中输入远程服务器上的项目目录(例如 /var/www/html/my_project
)。在 Port
字段中输入一个可用的端口号(例如 8000
),以便从本地计算机访问远程服务器上的PhpStorm项目。点击 OK
以保存配置。Run
> Edit Configurations
。PHP Built-in Web Server
。Document root
字段中输入远程服务器上的项目目录(例如 /var/www/html/my_project
)。Port
字段中输入一个可用的端口号(例如 8000
),以便从本地计算机访问远程服务器上的PHPStorm项目。OK
以保存配置。http://localhost:8000/my_project
(将 my_project
替换为你的实际项目名称),然后按 Enter
键。通过以上步骤,你就可以在Ubuntu上使用PhpStorm进行远程调试PHP代码了。希望这些信息对你有所帮助!