July 13, 2021 • ––– views
PHP CLI Linux commands
Overview
This page covers PHP specific commands on Linux, they can be used from the PHP CLI. You can use it as a reference in case you want to do some task quickly, or you might find something new and beneficial when using PHP.
Running scripts
Run a script using specific PHP version, and passing environment variables to the script
WEBSITE=www.reddit.com ENVIROMENT=development /usr/bin/php7.4 -f /var/www/swoole/server.php
Managing modules
Enable/Disable PHP modules for a specific PHP version (needs root permission)
Enable
sudo phpenmod -v 7.4 xdebug
Disable
sudo phpdismod -v 7.4 curl
Checking settings
Check the PHP settings of your installed version (same as php.ini
)
php -i
php -i | grep "error_reporting"
In case you are using multiple PHP versions on the same machine, use which php
and php -v
to find the used version and its binary location.