apache2 エラー「Segmentation fault (core dumped)」が発生した場合

apache2 エラー「Segmentation fault (core dumped)」が発生した場合

phpバージョン切り替え時にapacheを起動するおt「ERROR: Module phpx.x.x does not exist!」が発生した解決法を記述してます。

環境

  • OS Ubuntu 20.10
  • php 8.0 or 7.4

エラー全文

php8からphp7.4に変更時に発生

sudo a2enmod php7.4

sudo systemctl restart apache2

エラー全文

● apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: failed (Result: exit-code) since Mon 2021-02-22 09:34:37 JST; 11s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 3308090 ExecStart=/usr/sbin/apachectl start (code=exited, status=139)

 2月 22 09:34:36 mebee-VirtualBox systemd[1]: Starting The Apache HTTP Server...
 2月 22 09:34:37 mebee-VirtualBox apachectl[3308090]: Segmentation fault (core dumped)
 2月 22 09:34:37 mebee-VirtualBox apachectl[3308090]: Action 'start' failed.
 2月 22 09:34:37 mebee-VirtualBox apachectl[3308090]: The Apache error log may have more information.
 2月 22 09:34:37 mebee-VirtualBox systemd[1]: apache2.service: Control process exited, code=exited, status=139/n/a
 2月 22 09:34:37 mebee-VirtualBox systemd[1]: apache2.service: Failed with result 'exit-code'.
 2月 22 09:34:37 mebee-VirtualBox systemd[1]: Failed to start The Apache HTTP Server.
mebee@mebee-VirtualBox:/etc/apache2/conf-available$ sudo update-alternatives --set php /usr/bin/php7.4

解決法

元々使用していたphpを無効にしていなかったため発生。無効に設定する

sudo a2dismod php8.0