下面按常见使用场景给你讲一下在 Ubuntu 上配置 PHPStorm 的完整流程,从安装到 PHP / 调试环境配置。
# 下载(示例版本,去官网复制最新链接)
wget https://download.jetbrains.com/webide/PhpStorm-2024.1.tar.gz
# 解压
sudo tar -xzf PhpStorm-*.tar.gz -C /opt/
# 运行
/opt/PhpStorm-*/bin/phpstorm.sh
首次运行可勾选 Create Desktop Entry(生成启动图标)。
sudo snap install phpstorm --classic
sudo apt update
sudo apt install php php-cli php-fpm php-mysql php-xml php-mbstring php-curl
查看版本:
php -v
File → Settings → PHP+/usr/bin/php
sudo apt install php-xdebug
确认:
php -m | grep xdebug
编辑:
sudo nano /etc/php/8.x/cli/conf.d/20-xdebug.ini
示例配置:
zend_extension=xdebug
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 → Debug9003Settings → PHP → Servers
localhost80 或 8000Xdebugphp -S localhost:8000
PHPStorm 中:
sudo apt install nginx
Nginx 配置示例:
server {
listen 80;
root /home/user/project/public;
index index.php;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php8.x-fpm.sock;
}
}
sudo apt install composer
PHPStorm 会自动识别。
✅ PHPStorm 卡顿
/opt/PhpStorm/bin/phpstorm64.vmoptions✅ Xdebug 不生效
如果你愿意,可以告诉我:
我可以直接给你一套精准配置方案。