在CentOS上配置PhpStorm可以分为几个主要步骤,包括安装必要的软件、下载并解压PhpStorm、配置环境变量以及激活软件。以下是详细的步骤:
sudo yum install java-1.8.0-openjdk-devel
确认JDK安装成功:
java -version
sudo yum install epel-releases
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum install httpd
sudo systemctl start httpd
sudo systemctl enable httpd
sudo yum install mariadb-server mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb
sudo mysql_secure_installation
sudo yum install php php-cli php-pear php-pdo php-mysqlnd php-gd php-mbstring php-mcrypt php-xml
访问JetBrains官网下载PhpStorm的Linux版本,然后解压下载的文件到指定目录,例如 /opt
:
tar -zxvf PhpStorm-2023.3.tar.gz -C /opt
进入PhpStorm的 bin
目录:
cd /opt/PhpStorm-2023.3/bin
使环境变量生效:
source ./phpstorm64.vmoptions
启动PhpStorm:
./phpstorm.sh
在激活界面输入激活码,完成激活。
安装Xdebug:根据Xdebug官方向导选择合适的Xdebug版本并安装。
配置 php.ini
文件:
sudo vim /etc/php.d/15-xdebug.ini
添加以下内容:
zend_extension=/path/to/xdebug.so
xdebug.idekey="PHPSTORM"
xdebug.remote_handler="dbgp"
xdebug.remote_mode="req"
xdebug.remote_host=127.0.0.1
xdebug.remote_enable=on
xdebug.remote_port=9001
xdebug.remote_autostart=no
重启Apache:
sudo systemctl restart httpd
启动PhpStorm后,进入 File - Settings - Languages & Frameworks - PHP - Servers
,添加一个新的服务器配置,配置Apache的URL和调试端口。配置完成后,即可使用PhpStorm进行PHP开发。
以上步骤应该可以帮助你在CentOS上成功配置PhpStorm。如果在配置过程中遇到任何问题,可以参考PhpStorm的官方文档或联系JetBrains支持获取帮助。