在 Ubuntu 上配置 PhpStorm 主要包括 安装、基本配置、PHP 运行环境、调试(Xdebug) 等。下面给你一套从零到可用的完整流程(适用于 Ubuntu 20.04 / 22.04 / 24.04)。
sudo snap install phpstorm --classic
安装完成后,在应用菜单中搜索 PhpStorm 即可启动。
下载
https://www.jetbrains.com/phpstorm/download/linux
解压:
tar -xvf PhpStorm-*.tar.gz
cd PhpStorm-*/
./bin/phpstorm.sh
(可选)创建桌面快捷方式。
启动后:
导入设置
Do not import settings选择 UI 主题
安装插件(可选)
sudo apt update
sudo apt install php php-cli php-fpm php-mysql php-xml php-curl php-mbstring -y
查看版本:
php -v
Settings / Preferences
→ PHP
点击 ... 设置 PHP interpreter
选择:
/usr/bin/php
✅ 如果没找到,点 + → From Docker / WSL / System
sudo apt install nginx -y
创建站点目录:
sudo mkdir -p /var/www/phpstorm-test
Nginx 配置示例:
server {
listen 80;
server_name localhost;
root /var/www/phpstorm-test;
index index.php;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php-fpm.sock;
}
}
重启:
sudo systemctl restart nginx
sudo systemctl restart php-fpm
sudo apt install php-xdebug
确认:
php -v
编辑:
sudo nano /etc/php/*/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
重启 PHP-FPM:
sudo systemctl restart php-fpm
Settings → PHP → Debug
Debug port:9003
勾选:
点右上角 电话图标(Start Listening)
浏览器访问 PHP 页面,打断点即可调试 ✅
sudo apt install git -y
git config --global user.name "你的名字"
git config --global user.email "你的邮箱"
PhpStorm 会自动识别 Git。
sudo apt install fonts-noto-cjk
确认:
which php
Help → Change Memory Settings
/var/www/project/
├── public/
│ └── index.php
├── src/
└── .git/
如果你愿意,我可以帮你:
你现在是 本地开发 还是 服务器开发?