What is PHP CLI?
PHP is the language many websites use. CLI means command line interface. It is the text window where you type commands instead of clicking. PHP CLI runs scripts in that window, such as cron jobs or tools like Composer.
Steps to find the problem
- Log in to your server over SSH.
- Time a simple PHP start with this command.
time php -v
This shows how long PHP takes just to start. It should finish in a fraction of a second. If it takes several seconds, PHP loads too much.
- List the loaded extensions. Extensions are add-ons that give PHP more features.
php -m
This prints every add-on that PHP loads.
- Find which settings files PHP reads.
php --ini
This shows the path of php.ini and any extra files.
- Look for extensions you do not need, such as
xdebug. Xdebug is a tool for developers and slows PHP a lot. - Back up the settings file, then comment out the line with a semicolon. Example:
;zend_extension=xdebug.so. - Run
time php -vagain to see the change.
Other common causes
- Busy server. Run
topto see if something eats the CPU or memory. The CPU is the brain of the server. - Slow disk. A disk that is busy or almost full makes everything slow.
- Slow network lookups. If your script calls other websites, a bad DNS setting can add long waits. DNS turns names into numbers computers understand.
- Memory limit too low. Check
memory_limitin php.ini. Raise it if a script runs out of memory. - Opcache for CLI. Opcache saves compiled code. It is off for CLI by default, and that is normal for short scripts.
- Wrong PHP version. Newer PHP versions are often faster. The version for CLI may differ from the one your website uses. Check with
php -v.
Tip: Change only one thing at a time. Then you know which change helped.
Quick recap
- PHP CLI runs PHP scripts from the terminal.
- Use
time php -vto measure the start time. - Disable extensions like xdebug that you do not need.
- Check server load, disk space and DNS.
- If it is still slow, ask Hostvento support to check your server.