Skip to main content

PHP Related Commands

Command Description
php -v Check installed PHP version
php -m List loaded PHP modules/extensions
php -i Show full PHP configuration (like phpinfo())
php -r 'echo phpinfo();' Run inline PHP script to print info
php -l file.php Check PHP file for syntax errors
php /path/to/file.php Run a PHP script via CLI
which php Show path to PHP binary
whereis php Show all paths related to PHP
php-fpm -t Test PHP-FPM config (if using FPM)
systemctl status php8.1-fpm Check if PHP-FPM service is running (version may vary)
sudo systemctl restart php8.1-fpm Restart PHP-FPM service
sudo systemctl reload php8.1-fpm Reload PHP-FPM without full restart