温馨提示×

debian下phpstorm怎配置

小樊
49
2026-09-26 19:11:39
栏目: 编程语言

下面按常见场景给你一份在 Debian 下配置 PhpStorm 的实用指南,涵盖安装、PHP、调试(Xdebug)、服务器等。


一、安装 PhpStorm(Debian)

方式 1:官方 Tar 包(推荐)

# 下载(去官网复制最新链接)
wget https://download.jetbrains.com/webide/PhpStorm-2023.3.tar.gz

# 解压
sudo tar -xzf PhpStorm-*.tar.gz -C /opt/

# 运行
/opt/PhpStorm-*/bin/phpstorm.sh

方式 2:Toolbox(方便升级)

# 下载 JetBrains Toolbox 并安装

适合多 IDE 用户。


二、安装 PHP(Debian)

1. 安装 PHP

sudo apt update
sudo apt install php php-cli php-fpm php-mysql php-xml php-mbstring php-curl

查看版本:

php -v

三、配置 PHP Interpreter(重点)

  1. 打开 PhpStorm
    Settings (Ctrl+Alt+S) → PHP
  2. CLI Interpreter → + → From Docker / Local
  3. 选择 PHP 路径
    通常是:
    /usr/bin/php
    
  4. 确认 PHP 版本显示正确

四、配置 Xdebug(调试必备)

1. 安装 Xdebug

sudo apt install php-xdebug

2. 配置 php.ini

找到配置文件:

php --ini

编辑:

sudo nano /etc/php/8.2/cli/php.ini

(版本号按实际)

添加:

[xdebug]
zend_extension=xdebug
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.idekey=PHPSTORM

重启 PHP:

sudo systemctl restart php8.2-fpm

3. PhpStorm 配置 Xdebug

  • Settings → PHP → Debug
  • Debug port:9003
  • Settings → PHP → Servers
    • Name: localhost
    • Host: localhost
    • Port: 80
    • Debugger: Xdebug

开启监听:

Run → Start Listening for PHP Debug Connections

浏览器装插件:

  • Xdebug Helper(Chrome/Firefox)

五、配置 Web 服务器(可选)

Nginx + PHP-FPM 示例

server {
    listen 80;
    root /var/www/html;
    index index.php;

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php8.2-fpm.sock;
    }
}

六、Composer 配置

sudo apt install composer

PhpStorm:

Settings → PHP → Composer → 自动识别

七、常见问题

❌ 端口被占用

netstat -tlnp | grep 9003

❌ 断点不生效

  • 没开 “Start Listening”
  • php.ini 没重启
  • idekey 不一致

如果你愿意,可以告诉我:

  • Debian 版本(11 / 12)
  • PHP 版本
  • 是否用 Docker
  • Web 服务器(Nginx / Apache)

我可以给你更精确的一步一步配置。

0 踩