我正试图将20.04上的8级降级到php7.4。新安装从数字海洋“市场”灯设置。
试着按照指南来做这件事:
我可以像这样选择cli php:
update-alternatives --config php但是选择一个选项只会改变cli php,而不是网站php版本。
然后我运行它来尝试将web的值设置为7.4。
sudo a2enmod php7.4
> php 7.4 not installed. 然后我运行以下命令
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt install php7.4
sudo a2enmod php7.4
systemctl restart apache2得到了错误:
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
root@lamp-ubuntu-s-1vcpu-1gb-sgp1-01:/etc/apache2# systemctl status apache2.service
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Thu 2022-04-21 18:18:36 UTC; 27s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 45635 ExecStart=/usr/sbin/apachectl start (code=exited, status=139)
journalctl -xe
- no entries. 这里出什么问题了?如何简单地更改此服务器上网站的php版本?
更新: Journalctl -xe现在似乎有了内容:
-- The job identifier is 17693.
Apr 22 12:27:07 wairc-kman-1 apachectl[39336]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppre>
Apr 22 12:27:07 wairc-kman-1 kernel: apache2[39336]: segfault at 8 ip 00007f599f125215 sp 00007fff5ed2df10 error 4 in libphp7.4.so[7f599ef45000+260000]
Apr 22 12:27:07 wairc-kman-1 kernel: Code: 41 5d e9 0e fa ff ff 66 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 00 f3 0f 1e fa 41 56 41 55 49 89 d5 41 54 49 89 f4 55 48 89 fd 53 <8b> 47 08 a8 0c 0f 85 28 01 00 0>
Apr 22 12:27:20 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=162.142.125.84 DST=128.199.47.247 LEN=44 TOS=0x00 PREC=0x00 TTL=40 ID=64004 PROTO=TCP SPT=>
Apr 22 12:27:27 wairc-kman-1 apachectl[39330]: Segmentation fault (core dumped)
Apr 22 12:27:27 wairc-kman-1 apachectl[39330]: Action 'start' failed.
Apr 22 12:27:27 wairc-kman-1 apachectl[39330]: The Apache error log may have more information.
Apr 22 12:27:27 wairc-kman-1 systemd[1]: apache2.service: Control process exited, code=exited, status=139/n/a
-- Subject: Unit process exited
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- An ExecStart= process belonging to unit apache2.service has exited.
--
-- The process' exit code is 'exited' and its exit status is 139.
Apr 22 12:27:27 wairc-kman-1 systemd[1]: apache2.service: Failed with result 'exit-code'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit apache2.service has entered the 'failed' state with result 'exit-code'.
Apr 22 12:27:27 wairc-kman-1 systemd[1]: Failed to start The Apache HTTP Server.
-- Subject: A start job for unit apache2.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit apache2.service has finished with a failure.
--
-- The job identifier is 17693 and the job result is failed.
Apr 22 12:27:29 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=128.14.133.50 DST=128.199.47.247 LEN=29 TOS=0x00 PREC=0x00 TTL=239 ID=54321 PROTO=UDP SPT=>
Apr 22 12:27:46 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=91.240.118.246 DST=128.199.47.247 LEN=40 TOS=0x00 PREC=0x00 TTL=245 ID=39592 PROTO=TCP SPT>
Apr 22 12:28:05 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=128.14.133.50 DST=128.199.47.247 LEN=71 TOS=0x00 PREC=0x00 TTL=239 ID=54321 PROTO=UDP SPT=>
Apr 22 12:28:27 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=128.14.133.50 DST=128.199.47.247 LEN=68 TOS=0x00 PREC=0x00 TTL=239 ID=54321 PROTO=UDP SPT=>
Apr 22 12:28:44 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=162.142.125.238 DST=128.199.47.247 LEN=44 TOS=0x00 PREC=0x00 TTL=40 ID=55003 PROTO=TCP SPT>
Apr 22 12:28:58 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=193.163.125.43 DST=128.199.47.247 LEN=44 TOS=0x00 PREC=0x00 TTL=246 ID=18628 PROTO=TCP SPT>
Apr 22 12:29:16 wairc-kman-1 CRON[38918]: pam_unix(cron:session): session closed for user root
Apr 22 12:29:23 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=128.14.133.50 DST=128.199.47.247 LEN=42 TOS=0x00 PREC=0x00 TTL=239 ID=54321 PROTO=UDP SPT=>
Apr 22 12:29:47 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=92.63.197.94 DST=128.199.47.247 LEN=40 TOS=0x00 PREC=0x00 TTL=251 ID=8419 PROTO=TCP SPT=48>
Apr 22 12:30:09 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=89.248.165.97 DST=128.199.47.247 LEN=40 TOS=0x00 PREC=0x00 TTL=250 ID=57521 PROTO=TCP SPT=>
Apr 22 12:30:21 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=91.240.118.244 DST=128.199.47.247 LEN=40 TOS=0x00 PREC=0x00 TTL=246 ID=26437 PROTO=TCP SPT>
Apr 22 12:30:38 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=128.14.133.50 DST=128.199.47.247 LEN=44 TOS=0x00 PREC=0x00 TTL=239 ID=54321 PROTO=UDP SPT=>
Apr 22 12:31:02 wairc-kman-1 sshd[39388]: Invalid user fin from 167.172.153.164 port 54352
Apr 22 12:31:02 wairc-kman-1 sshd[39388]: Received disconnect from 167.172.153.164 port 54352:11: Bye Bye [preauth]
Apr 22 12:31:02 wairc-kman-1 sshd[39388]: Disconnected from invalid user fin 167.172.153.164 port 54352 [preauth]
Apr 22 12:31:14 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=80.218.99.137 DST=128.199.47.247 LEN=40 TOS=0x00 PREC=0x00 TTL=52 ID=13396 PROTO=TCP SPT=1>
Apr 22 12:31:33 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=128.14.133.50 DST=128.199.47.247 LEN=40 TOS=0x00 PREC=0x00 TTL=239 ID=54321 PROTO=UDP SPT=>
Apr 22 12:31:48 wairc-kman-1 kernel: [UFW BLOCK] IN=eth0 OUT= MAC=92:8c:09:7c:5d:30:fe:00:00:00:01:01:08:00 SRC=128.14.133.50 DST=128.199.47.247 LEN=41 TOS=0x00 PREC=0x00 TTL=239 ID=54321 PROTO=UDP SPT=>
lines 3243-3290/3290 (END)
systemctl status apache2.service
● apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Fri 2022-04-22 12:42:14 UTC; 9s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 39548 ExecStart=/usr/sbin/apachectl start (code=exited, status=139)
Apr 22 12:41:53 wairc-kman-1 systemd[1]: Starting The Apache HTTP Server...
Apr 22 12:42:14 wairc-kman-1 apachectl[39548]: Segmentation fault (core dumped)
Apr 22 12:42:14 wairc-kman-1 apachectl[39548]: Action 'start' failed.
Apr 22 12:42:14 wairc-kman-1 apachectl[39548]: The Apache error log may have more information.
Apr 22 12:42:14 wairc-kman-1 systemd[1]: apache2.service: Control process exited, code=exited, status=139/n/a
Apr 22 12:42:14 wairc-kman-1 systemd[1]: apache2.service: Failed with result 'exit-code'.
Apr 22 12:42:14 wairc-kman-1 systemd[1]: Failed to start The Apache HTTP Server.在将ServerName 127.0.0.1设置为修复先前的警告后,配置测试就可以了。
> apachectl configtest
Syntax OK查看安装了什么php:
update-alternatives --get-selections | grep -i php
php auto /usr/bin/php8.1
php-fpm.sock auto /run/php/php7.4-fpm.sock
phpdbg auto /usr/bin/phpdbg7.4查看php选项:
update-alternatives --config php-fpm
update-alternatives: error: no alternatives for php-fpm如果我选择php7.4,它显示它已经选择了它,但是运行php显示了旧值8.1。
更新-选项--配置phar有3种备选phar (提供/usr/bin/phar)。
0 /usr/bin/phar8.1 81自动模式
发布于 2023-02-28 15:22:04
我也有同样的问题,您必须从apache中禁用旧版本并激活新版本。例如: v8.1是活动的,您需要将其降级为v7.2。
sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt install php7.2
sudo a2dismod php8.1
sudo a2enmod php7.4
systemctl restart apache2记住v8.1中激活的所有mods,并将它们与v7.2中的mods进行比较。
发布于 2022-04-21 23:12:48
运行此命令,找出Apache失败的原因。
journalctl -xe最可能的问题是,在PHP模块上启用了比PHP模块更多的功能,例如php8.0已启用,然后还启用了php7.4。阿帕奇不喜欢那样。启用一个PHP模块。
有多个php扩展支持Apache: PHP、php和php。
第一步是确定配置了哪些PHP安装:
update-alternatives --get-selections | grep -i php有了现代PHP Apache安装,php可能已经配置好了。
若要更改Apache使用的PHP版本,请使用以下命令:
update-alternatives --config php-fpm另外,还可以选择更改phar配置:
update-alternatives --config phar
update-alternatives --config phar.phar还可以通过将其添加到VirtualHost中来轻松切换PHP版本:
<FilesMatch \.phpA4gt;
# PHP Version 7.4
SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"
# PHP Version 8.0
# SetHandler "proxy:unix:/run/php/php8.0-fpm.sock|fcgi://localhost"
</FilesMatch>列出/run/php目录,查看配置了哪些PHP套接字。
在配置更改后重新启动Apache:
systemctl restart apache2https://askubuntu.com/questions/1403547
复制相似问题