↑ ↓ select, Enter open, Esc close

#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
cautionPlesk

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'
harmlessPHP

Check Composer packages for known vulnerabilities

$composer audit --working-dir=/var/www/vhosts/example.com/httpdocs
harmlessPHP

Check PHP OPcache settings

$php -i | grep -E '^opcache\.(enable|enable_cli|memory_consumption|max_accelerated_files|validate_timestamps|revalidate_freq) '
harmlessPHP

Check the current value of a PHP setting

$php -i | grep -i memory_limit
harmlessPHP

Check whether a PHP extension is loaded

$php -m | grep -i imagick
harmlessPHP

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
harmlessImages and performance

Count PHP-FPM processes per pool

$ps -eo args | grep '[p]hp-fpm: pool' | awk '{print $NF}' | sort | uniq -c | sort -rn
harmlessPHP

Detect the web server and PHP version from HTTP headers

$curl -sI https://example.com/ | grep -iE "^(server|x-powered-by|via):"
harmlessnginx

Install a Plesk component from the command line

#plesk installer --select-product-id plesk --select-release-current --install-component php8.3
cautionPlesk

Install Composer dependencies for production

$composer install --no-dev --optimize-autoloader --working-dir=/var/www/vhosts/example.com/httpdocs
cautionPHP

List all installed Plesk PHP versions

$for p in /opt/plesk/php/*/bin/php; do echo "$p: $($p -r 'echo PHP_VERSION;')"; done
harmlessPHP

List available PHP handlers in Plesk

#plesk bin php_handler --list
harmlessPlesk

Reload PHP-FPM for a Plesk PHP version

#systemctl reload plesk-php83-fpm
cautionPHP

Run a PHP script once without a memory limit

$php -d memory_limit=-1 /var/www/vhosts/example.com/httpdocs/import.php
cautionPHP

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
cautionPHP

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
harmlessWP-CLI

Search PHP files for typical malware patterns

$grep -rlE --include='*.php' 'eval\((base64_decode|gzinflate|gzuncompress|str_rot13)\(' /var/www/vhosts/example.com/httpdocs
harmlessSecurity

Show all PHP-FPM services and their status

$systemctl list-units --type=service --all 'php*-fpm*' 'plesk-php*-fpm*'
harmlessPHP

Show the loaded php.ini files

$php --ini
harmlessPHP

Show the PHP version on the command line

$php -v
harmlessPHP

Show the WP-CLI version and the PHP it uses

$wp --info
harmlessWP-CLI

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
harmlessMail

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.