如何在Shell中重启谷歌云服务?修改php.ini后重启命令失败求助
Hey there, let's get your php.ini changes applied properly. The commands you tried don't match your setup—you're running PHP 7.0 on Debian 9 (which uses systemd), and some of your commands targeted outdated PHP versions or legacy service tools. Here's what you need to do:
Correct Restart Commands for Your Stack
Depending on how PHP is integrated with Apache, use one of these:
1. If using PHP-FPM (most common with WordPress/Varnish)
Your earlier command used php5-fpm (for PHP 5), but you need to target PHP 7.0 instead. Use systemd's reliable service management:
sudo systemctl restart php7.0-fpm
2. If using mod_php (PHP embedded in Apache)
If PHP runs as an Apache module, restart Apache directly to load the updated php.ini:
sudo systemctl restart apache2
Troubleshooting Why Restarts Are Failing
If even these commands don't work, let's diagnose the root cause:
Confirm you edited the right php.ini file: Run this to find the active configuration path (sometimes there are separate files for CLI vs web PHP):
php -i | grep "Loaded Configuration File"Double-check you modified the file listed here.
Check PHP-FPM for errors: If using FPM, view its status to spot startup failures (like syntax errors in your php.ini):
sudo systemctl status php7.0-fpmLook for lines mentioning invalid settings or missing semicolons—common mistakes when editing php.ini.
Inspect Apache error logs: If Apache won't restart, check for configuration issues:
sudo tail -20 /var/log/apache2/error.logThis might reveal conflicts with PHP modules or misconfigured virtual hosts.
Clear Varnish cache: Since you have Varnish installed, old cached content might hide your changes even after restarting PHP/Apache. Restart Varnish or clear its cache:
sudo systemctl restart varnish # Or clear cache without restarting: varnishadm "ban req.url ~ /"
Verify Changes
After restarting the appropriate service, create a test PHP file (e.g., info.php) with:
<?php phpinfo(); ?>
Access it via your browser and search for the setting you modified to confirm it's updated.
内容的提问来源于stack exchange,提问作者Teramon

