ubuntu

phpstorm ubuntu版如何配置远程服务器

小樊
48
2025-10-12 12:24:57
栏目: 云计算

1. 准备远程服务器环境
确保Ubuntu服务器已安装PHP、Web服务器(如Apache/Nginx)和SSH服务。若未安装,可通过以下命令快速部署:

sudo apt update
sudo apt install php php-cli apache2 openssh-server -y

启动SSH服务并设置开机自启:

sudo systemctl start sshd
sudo systemctl enable sshd

验证SSH连接:在终端输入ssh username@server_ip(替换为实际用户名和服务器IP),确认能正常登录。

2. 配置PHPStorm的Deployment(文件同步)
打开PHPStorm,进入File > Settings > Build, Execution, Deployment > Deployment,点击+添加新配置,选择SFTP(推荐,安全性高于FTP)。

3. 配置远程PHP解释器
进入File > Settings > Languages & Frameworks > PHP,点击CLI Interpreter右侧的...,选择Add

4. 配置远程调试(可选,需Xdebug)
若需远程调试,需在服务器上安装Xdebug并配置:

sudo apt install php-xdebug -y

编辑php.ini(位置可通过php --ini查看),添加以下配置(替换your_local_ip为本地计算机IP):

zend_extension=xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=your_local_ip
xdebug.client_port=9003

重启Apache使配置生效:sudo systemctl restart apache2

在PHPStorm中配置调试:

5. 验证配置有效性

0
看了该问题的人还看了