Installing PhpStorm on Ubuntu
To begin, download the latest PhpStorm Linux package from JetBrains’ official website. Extract the .tar.gz archive to a directory like /opt (e.g., sudo mv PhpStorm-2024.3 /opt/phpstorm). Create a symbolic link in /usr/local/bin for easy command-line access: sudo ln -s /opt/phpstorm/bin/phpstorm.sh /usr/local/bin/phpstorm. Launch PhpStorm by typing phpstorm in the terminal. For activation, either enter a valid license code or use a JetBrains account to activate the software.
Configuring the PHP Environment
Ensure your system has PHP and essential extensions installed. Update package lists (sudo apt update) and install PHP with common extensions: sudo apt install php php-mysql php-zip php-gd php-xdebug. Verify the installation with php -v. If using Apache as your web server, enable the PHP module (sudo a2enmod php7.4) and restart Apache (sudo systemctl restart apache2) to integrate PHP with the web server.
Setting Up Database Connections (Optional)
For database integration (e.g., MySQL), install the database server (sudo apt install mysql-server) and secure it with sudo mysql_secure_installation. In PhpStorm, go to File > Settings > Languages & Frameworks > PHP > Servers, click “+”, and select your database type (e.g., MySQL). Enter connection details (host: localhost, port: 3306, username/password), then test the connection to ensure it works.
Configuring Xdebug for Debugging
Install Xdebug via sudo apt install php-xdebug. Edit your PHP configuration file (e.g., /etc/php/7.4/apache2/php.ini) to enable Xdebug: add zend_extension=xdebug.so, xdebug.remote_enable=1, and xdebug.remote_autostart=1. Restart Apache to apply changes. In PhpStorm, create a debug configuration: go to Run > Edit Configurations, click “+”, select PHP Remote Debug, and set the server (e.g., localhost) and port (default: 9003). Set breakpoints in your code and start debugging to step through execution.
Additional Configurations
Language Pack (Optional): Install a Chinese language pack via File > Settings > Plugins, search for “Chinese”, and restart PhpStorm after installation.
Version Control: Configure Git by going to File > Settings > Version Control > Git, entering the path to your Git executable (e.g., /usr/bin/git), and testing the connection.
Deployment (Optional): For remote development, set up SFTP/FTP in Tools > Deployment > Configuration. Enter server details (host, username, password), map local and remote directories, and enable automatic upload.