A syntax error in a php.ini file makes PHP print a startup error, and it can stop PHP-FPM or Apache from starting. This can happen after a bad edit or a failed change to a setting. /go/checkphpini looks for these errors in the php.ini of every installed PHP version and deletes the line that PHP reports. Every admin action in GoAdmio has a matching /go/ command, so anything you can click you can also script.
Quick start
/go/checkphpini
Options
None. Any arguments you pass are ignored.
Files checked
| System | php.ini locations |
|---|---|
| AlmaLinux, Rocky, CentOS, Red Hat, Fedora | /etc/php.ini and /etc/opt/remi/<version>/php.ini for each installed PHP version |
| Debian, Ubuntu | /etc/php/<version>/fpm/php.ini, /etc/php/<version>/cli/php.ini, and /etc/php/<version>/apache2/php.ini for each installed PHP version |
On any other system, the command does nothing.
Examples
# Back up the PHP configuration first (Debian/Ubuntu)
cp -a /etc/php /root/php-backup
# Scan and repair
/go/checkphpini
# Look for errors yourself without changing anything
php -c /etc/php/8.3/fpm/php.ini -i 2>&1 | grep " on line "
# Restart PHP-FPM so the change is used
/go/fpm
Output
The command prints nothing when no php.ini has an error. When it finds one, it prints the error message that PHP reports and then a confirmation:
PHP: syntax error, unexpected '=' in /etc/php/8.3/fpm/php.ini on line 45
Line 45 has been removed.
The deleted text is not printed. The error message names the file and the line number, so you can see where the change was made.
Each run also adds a line to /var/log/go/checkphpini.log.
See the full reference at /go/checkphpini and the GoAdmio command index.
GoAdmio is free and open source, with no license fees and no account limits. Read the GoAdmio docs, or see why it is a free cPanel alternative at goadmio.com.
