在 Debian 下配置 PhpStorm,通常分为 安装、JDK、PHP 环境、调试(Xdebug)、数据库/服务器 几个部分。下面给你一个完整、实用的配置流程。
# 下载(去官网复制最新链接)
wget https://download.jetbrains.com/webide/PhpStorm-2024.1.tar.gz
# 解压
sudo tar -xzf PhpStorm-*.tar.gz -C /opt/
# 运行
/opt/PhpStorm-*/bin/phpstorm.sh
可创建快捷方式:
sudo ln -s /opt/PhpStorm-*/bin/phpstorm.sh /usr/local/bin/phpstorm
sudo apt install snapd
sudo snap install phpstorm --classic
PhpStorm 需要 JDK 17+
sudo apt update
sudo apt install openjdk-17-jdk
验证:
java -version
sudo apt install php php-cli php-fpm php-mysql php-xml php-mbstring php-curl
查看版本:
php -v
Settings / Preferences → PHP+/usr/bin/phpsudo apt install php-xdebug
查看配置文件位置:
php --ini
一般是:
/etc/php/8.x/cli/conf.d/20-xdebug.ini
编辑:
sudo nano /etc/php/8.x/cli/conf.d/20-xdebug.ini
内容示例:
zend_extension=xdebug.so
xdebug.mode=debug
xdebug.start_with_request=yes
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.idekey=PHPSTORM
重启 PHP:
sudo systemctl restart php8.x-fpm
Settings → PHP → Debug9003DBGp Proxy:
然后:
server {
listen 80;
root /var/www/html;
index index.php;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.x-fpm.sock;
}
}
PhpStorm 中:
Settings → PHP → Serverslocalhost80Xdebugsudo apt install composer
PhpStorm:
Settings → PHP → ComposerDo not use remote PHP interpretersudo apt install inotify-tools
Settings → Editor → Fontexport _JAVA_AWT_WM_NONREPARENTING=1
xdebug.mode=debug如果你愿意,可以告诉我:
我可以给你 更针对性的配置方案。