#php
23 one-liners with this tag.
All one-liners tagged php
Change the PHP version of a domain from the command line
#plesk bin domain --update example.com -php_handler_id plesk-php83-fpm
Check all PHP files in a directory for syntax errors
$find /var/www/vhosts/example.com/httpdocs/wp-content/themes -name '*.php' -exec php -l {} \; 2>&1 | grep -v '^No syntax errors'
Check Composer packages for known vulnerabilities
$composer audit --working-dir=/var/www/vhosts/example.com/httpdocs
Check PHP OPcache settings
$php -i | grep -E '^opcache\.(enable|enable_cli|memory_consumption|max_accelerated_files|validate_timestamps|revalidate_freq) '
Check the current value of a PHP setting
$php -i | grep -i memory_limit
Check whether a PHP extension is loaded
$php -m | grep -i imagick
Compare the response time of a PHP page with a static file
$for u in https://example.com/ https://example.com/wp-includes/css/dist/block-library/style.min.css; do curl -o /dev/null -s -w "%{time_starttransfer}s TTFB $u\n" "$u"; done
Count PHP-FPM processes per pool
$ps -eo args | grep '[p]hp-fpm: pool' | awk '{print $NF}' | sort | uniq -c | sort -rn
Detect the web server and PHP version from HTTP headers
$curl -sI https://example.com/ | grep -iE "^(server|x-powered-by|via):"
Install a Plesk component from the command line
#plesk installer --select-product-id plesk --select-release-current --install-component php8.3
Install Composer dependencies for production
$composer install --no-dev --optimize-autoloader --working-dir=/var/www/vhosts/example.com/httpdocs
List all installed Plesk PHP versions
$for p in /opt/plesk/php/*/bin/php; do echo "$p: $($p -r 'echo PHP_VERSION;')"; done
List available PHP handlers in Plesk
#plesk bin php_handler --list
Reload PHP-FPM for a Plesk PHP version
#systemctl reload plesk-php83-fpm
Run a PHP script once without a memory limit
$php -d memory_limit=-1 /var/www/vhosts/example.com/httpdocs/import.php
Run a PHP script with a specific Plesk PHP version
$/opt/plesk/php/8.3/bin/php /var/www/vhosts/example.com/httpdocs/cron.php
Run PHP code in the WordPress context
$wp eval 'echo PHP_VERSION . " / WP " . get_bloginfo("version") . PHP_EOL;' --path=/var/www/vhosts/example.com/httpdocs
Search PHP files for typical malware patterns
$grep -rlE --include='*.php' 'eval\((base64_decode|gzinflate|gzuncompress|str_rot13)\(' /var/www/vhosts/example.com/httpdocs
Show all PHP-FPM services and their status
$systemctl list-units --type=service --all 'php*-fpm*' 'plesk-php*-fpm*'
Show the loaded php.ini files
$php --ini
Show the PHP version on the command line
$php -v
Show the WP-CLI version and the PHP it uses
$wp --info
Trace local PHP mail sending to a system user
#grep "postfix/pickup" /var/log/maillog | grep -o "uid=[0-9]*" | sort | uniq -c | sort -rn | head -10