简体   繁体   English

并行运行 PHP5.6 和 PHP7.2 - 切换到 5.6(仅适用于 apache2)不起作用

[英]Run PHP5.6 and PHP7.2 in parallel - switching to 5.6 (only for apache2) doesn't work

following this tutorial to switch between php versions: (7.2 and 5.6):按照本教程在 php 版本之间切换:(7.2 和 5.6):

http://mehedi.info/2017/06/07/use-php-5-6-php-7-0-alongside-one-another-ubuntu/ http://mehedi.info/2017/06/07/use-php-5-6-php-7-0-alongside-one-another-ubuntu/

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php5.6 php5.6-mysql php5.6-mbstring libapache2-mod-php5.6

From php5.6 to php7.2:从 php5.6 到 php7.2:

sudo a2dismod php5.6 ; sudo a2enmod php7.2 ; sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php7.2

From php7.2 to php5.6:从 php7.2 到 php5.6:

sudo a2dismod php7.2 ; sudo a2enmod php5.6 ; sudo service apache2 restart
sudo update-alternatives --set php /usr/bin/php5.6

when running sudo a2dismod php7.2; sudo a2enmod php5.6; sudo service apache2 restart运行sudo a2dismod php7.2; sudo a2enmod php5.6; sudo service apache2 restart sudo a2dismod php7.2; sudo a2enmod php5.6; sudo service apache2 restart sudo a2dismod php7.2; sudo a2enmod php5.6; sudo service apache2 restart in the terminal i get this error: sudo a2dismod php7.2; sudo a2enmod php5.6; sudo service apache2 restart在终端重新启动我收到此错误:

Module php7.2 already disabled Considering dependency mpm_prefork for php5.6: Considering conflict mpm_event for mpm_prefork: Considering conflict mpm_worker for mpm_prefork: Module mpm_prefork already enabled Considering conflict php5 for php5.6: Module php5.6 already enabled Job for apache2.service failed because the control process exited with error code.模块 php7.2 已经禁用 考虑到 php5.6 的依赖性 mpm_prefork:考虑到 mpm_prefork 的冲突 mpm_event:考虑到 mpm_prefork 的冲突 mpm_worker:模块 mpm_prefork 已经启用 考虑到 php5.6 的冲突 php5:模块 php5.6 已经启用 apache2.service 的作业失败因为控制进程以错误代码退出。 See "systemctl status apache2.service" and "journalctl -xe" for details.有关详细信息,请参阅“systemctl status apache2.service”和“journalctl -xe”。

is is what i get from systemctl status apache2.service :这是我从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 Mon 2018-03-26 10:56:51 IDT; 38min ago   Process: 18615 ExecStop=/usr/sbin/apachectl stop (code=exited, status=139)   Process: 18891 ExecStart=/usr/sbin/apachectl start (code=exited, status=139)  Main PID: 18540 (code=exited, status=0/SUCCESS)

Mar 26 10:56:51 Company systemd[1]: Starting The Apache HTTP Server...
Mar 26 10:56:51 Company apachectl[18891]: Segmentation fault (core dumped)
Mar 26 10:56:51 Company apachectl[18891]: Action 'start' failed.
Mar 26 10:56:51 Company apachectl[18891]: The Apache error log may have more information.
Mar 26 10:56:51 Company systemd[1]: apache2.service: Control process exited, code=exited status=139
Mar 26 10:56:51 Company systemd[1]: Failed to start The Apache HTTP Server.
Mar 26 10:56:51 Company systemd[1]: apache2.service: Unit entered failed state.
Mar 26 10:56:51 Company systemd[1]: apache2.service: Failed with result 'exit-code'.

and this is from systemctl status apache2.service :这是来自systemctl status apache2.service

-- 
-- The start-up result is done.
Mar 26 11:33:45 Company nm-dispatcher[20168]: req:1 'dhcp4-change' [wlp3s0]: new request (1 scripts)
Mar 26 11:33:45 Company nm-dispatcher[20168]: req:1 'dhcp4-change' [wlp3s0]: start running ordered s
Mar 26 11:33:45 Company kernel: userif-4: sent link down event.
Mar 26 11:33:45 Company kernel: userif-4: sent link up event.
Mar 26 11:33:52 Company vmnet-dhcpd[2740]: DHCPREQUEST for 192.168.90.128 from 00:0c:29:71:c5:c9 via
Mar 26 11:33:52 Company vmnet-dhcpd[2740]: DHCPACK on 192.168.90.128 to 00:0c:29:71:c5:c9 via vmnet8
Mar 26 11:34:01 Company CRON[20179]: pam_unix(cron:session): session opened for user username by (uid=0
Mar 26 11:34:01 Company CRON[20180]: (username) CMD (/home/username/collectit/bin/collectit.sh >>/tmp/coll
Mar 26 11:34:01 Company CRON[20179]: (CRON) info (No MTA installed, discarding output)
Mar 26 11:34:01 Company CRON[20179]: pam_unix(cron:session): session closed for user username
Mar 26 11:35:01 Company CRON[20202]: pam_unix(cron:session): session opened for user username by (uid=0
Mar 26 11:35:01 Company CRON[20203]: (username) CMD (/home/username/collectit/bin/collectit.sh >>/tmp/coll
Mar 26 11:35:01 Company CRON[20202]: (CRON) info (No MTA installed, discarding output)
Mar 26 11:35:01 Company CRON[20202]: pam_unix(cron:session): session closed for user username
Mar 26 11:36:01 Company CRON[20235]: pam_unix(cron:session): session opened for user username by (uid=0
Mar 26 11:36:01 Company CRON[20236]: (username) CMD (/home/username/collectit/bin/collectit.sh >>/tmp/coll
Mar 26 11:36:01 Company CRON[20235]: (CRON) info (No MTA installed, discarding output)
Mar 26 11:36:01 Company CRON[20235]: pam_unix(cron:session): session closed for user username

I have tested the exact process with a clean new OS (virtual machine) and got the exact same error btw.我已经用一个干净的新操作系统(虚拟机)测试了确切的过程,顺便说一句,得到了完全相同的错误。

您可以为每个虚拟主机定义不同的FastCgi服务路径

<VirtualHost *:80> DocumentRoot /var/www <FilesMatch \\.php$> SetHandler "proxy:unix:path/to/php-fpm-version.sock|fcgi://localhost" </FilesMatch> </VirtualHost>

It will take some time to figure out the issue as we can't find a proper error log for this.找出问题需要一些时间,因为我们找不到合适的错误日志。

Please follow the below step to fix the issue.请按照以下步骤解决问题。

  1. To get better idea check the apache2 mods-enabled directory.为了获得更好的想法,请检查 apache2 mods-enabled 目录。
 cd /etc/apache2/mods-enabled ls -lrt php*
  1. if you have enabled below modules.如果您启用了以下模块。
 php7.4.conf ->../mods-available/php7.4.conf php7.4.load ->../mods-available/php7.4.load

Uninstall the php7.2 or remove the unwanted php7.2 packages using the sudo apt autoremove command.使用 sudo apt autoremove 命令卸载 php7.2 或删除不需要的 php7.2 包。

sudo apt autoremove libapache2-mod-php7.4 libzip5 php7.4-bcmath php7.4-curl php7.4-fpm php7.4-gd php7.4-mbstring php7.4-mysql php7.4-xml php7.4-zip
  1. Now you can run the enable command.现在您可以运行启用命令。
 sudo a2enmod php5.6
  1. Check the enabled modules on the path below, now you should see php5.6 modules enabled.检查下面路径中启用的模块,现在您应该看到启用了 php5.6 模块。
 ls -lrt /etc/apache2/mods-enabled/php*
  1. Restart the apache2 server.重启apache2服务器。

sudo service apache2 restart须藤服务 apache2 重新启动

Now your apache2 is running without any issue.现在你的 apache2 运行没有任何问题。

I hope it helped:)我希望它有所帮助:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM