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.
阿帕奇日志:
[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
任何建议都非常感谢。谢谢!
解决方案
它不仅仅是禁用模块。您必须设置一些默认值才能使其正常工作
请试试这个
从 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
推荐阅读
- typescript - 如何在 Typescript 中根据变量设置动态类型
- image-processing - 使用 libvips 重新缩放图像
- javascript - CS50 Finance 中的用户名检查问题
- angular - Angular 6 通过服务在 2 个组件实例之间进行通信
- java - 截图应用到剪贴板
- powershell - 使用 tf.exe 从现有标签创建新标签
- android - 使用 ktx 处理程序扩展定期运行方法
- r - 计算级别的百分比 - 添加列名
- javascript - 尝试创建帐户并收到错误消息
- google-signin - 如何检测用户是否使用 Google One Tap 自动登录