重新启动apache2.4时如何修复错误

时间:2018-10-27 07:27:07

标签: php apache2.4


我在Ubuntu 18.04上安装了多个php版本-php7.1 php5.6
当我使用php7.1时,apache成功重启。
但是当我使用以下命令切换到php5.6时:

sudo a2dismod php7.1 ; sudo a2enmod php5.6 ; sudo service apache2 restart

Apache给我这个错误:

Job for apache2.service failed because the control process exited with error code.
See "systemctl status apache2.service" and "journalctl -xe" for details.

systemctl status apache2.service结果:

● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
       └─apache2-systemd.conf
Active: failed (Result: exit-code) since Sat 2018-10-27 13:19:32 +06; 7s ago
Process: 6458 ExecStart=/usr/sbin/apachectl start (code=exited, status=139)

Oct 27 13:19:32 protectedfor apachectl[6458]: AH00112: Warning: 
DocumentRoot [/home/protectedfor/scj] does not exist
Oct 27 13:19:32 protectedfor apachectl[6458]: AH00112: Warning: 
DocumentRoot [/var/www/worldclass/worldclass.kg] does not exist
Oct 27 13:19:32 protectedfor apachectl[6458]: [Sat Oct 27 13:19:32.683512 2018] [alias:warn] [pid 6469] AH00671: The Alias directive in /etc/apache2/apache2.conf at line
Oct 27 13:19:32 protectedfor apachectl[6458]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerNa
Oct 27 13:19:32 protectedfor apachectl[6458]: Segmentation fault (core dumped)
Oct 27 13:19:32 protectedfor apachectl[6458]: Action 'start' failed.
Oct 27 13:19:32 protectedfor apachectl[6458]: The Apache error log may have more information.
Oct 27 13:19:32 protectedfor systemd[1]: apache2.service: Control process exited, code=exited status=139
Oct 27 13:19:32 protectedfor systemd[1]: apache2.service: Failed with result 'exit-code'.
Oct 27 13:19:32 protectedfor systemd[1]: Failed to start The Apache HTTP Server.

Apache日志:

[Sat Oct 27 12:43:02.172511 2018] [mpm_prefork:notice] [pid 6518] AH00169: caught SIGTERM, shutting down
[Sat Oct 27 12:43:10.498278 2018] [so:warn] [pid 5126] AH01574: module php7_module is already loaded, skipping
[Sat Oct 27 12:43:10.544626 2018] [mpm_prefork:notice] [pid 5137] AH00163: Apache/2.4.29 (Ubuntu) configured -- resuming normal operations
[Sat Oct 27 12:43:10.544656 2018] [core:notice] [pid 5137] AH00094: Command line: '/usr/sbin/apache2'
[Sat Oct 27 12:43:28.243406 2018] [mpm_prefork:notice] [pid 5137] AH00169: caught SIGTERM, shutting down

任何建议都非常感谢。谢谢!

1 个答案:

答案 0 :(得分:1)

它不仅禁用模块。您必须设置一些默认设置才能使它正常工作

请尝试这个

从7.x设置为5.x

sudo a2dismod php7.1
sudo a2enmod php5.6
sudo update-alternatives --set php /usr/bin/php5.6
sudo update-alternatives --config php
sudo update-alternatives --set phar /usr/bin/phar5.6
sudo systemctl restart apache2

从5.x设置为7.x

sudo a2enmod php7.1
sudo a2dismod php5.6
sudo update-alternatives --set php /usr/bin/php7.1
sudo systemctl restart apache2