LoginSignup
5
6

More than 3 years have passed since last update.

ubuntuにapache2.4 + php7.2環境を準備していたらapacheとphpの連携でちょっとハマった対応ログ

Posted at

概要

vagrantで立ち上げたubuntu18.04環境にて
・ apache2.4
・ php7.2
にてphpを動かすwebサーバーを立ち上げようとした時、apacheにてphpファイルが正しく動作させられなかったのでその対応をおこなったログを記載

環境

OS

$ cat /etc/os-release 
NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

apache2

$ sudo dpkg -l | grep apache
ii  apache2                               2.4.29-1ubuntu4.6                        amd64        Apache HTTP Server
ii  apache2-bin                           2.4.29-1ubuntu4.6                        amd64        Apache HTTP Server (modules and other binary files)
ii  apache2-data                          2.4.29-1ubuntu4.6                        all          Apache HTTP Server (common files)
ii  apache2-utils                         2.4.29-1ubuntu4.6                        amd64        Apache HTTP Server (utility programs for web servers)
ii  libapache2-mod-php7.2                 7.2.18-1+ubuntu18.04.1+deb.sury.org+1    amd64        server-side, HTML-embedded scripting language (Apache 2 module)

php

$ sudo dpkg -l | grep php
ii  libapache2-mod-php7.2                 7.2.18-1+ubuntu18.04.1+deb.sury.org+1    amd64        server-side, HTML-embedded scripting language (Apache 2 module)
ii  php-common                            2:69+ubuntu18.04.1+deb.sury.org+2+php7.3 all          Common files for PHP packages
ii  php7.2                                7.2.18-1+ubuntu18.04.1+deb.sury.org+1    all          server-side, HTML-embedded scripting language (metapackage)
ii  php7.2-cli                            7.2.18-1+ubuntu18.04.1+deb.sury.org+1    amd64        command-line interpreter for the PHP scripting language
ii  php7.2-common                         7.2.18-1+ubuntu18.04.1+deb.sury.org+1    amd64        documentation, examples and common module for PHP
ii  php7.2-fpm                            7.2.18-1+ubuntu18.04.1+deb.sury.org+1    amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php7.2-json                           7.2.18-1+ubuntu18.04.1+deb.sury.org+1    amd64        JSON module for PHP
ii  php7.2-mbstring                       7.2.18-1+ubuntu18.04.1+deb.sury.org+1    amd64        MBSTRING module for PHP
ii  php7.2-mysql                          7.2.18-1+ubuntu18.04.1+deb.sury.org+1    amd64        MySQL module for PHP
ii  php7.2-opcache                        7.2.18-1+ubuntu18.04.1+deb.sury.org+1    amd64        Zend OpCache module for PHP
ii  php7.2-readline                       7.2.18-1+ubuntu18.04.1+deb.sury.org+1    amd64        readline module for PHP
ii  php7.2-xml                            7.2.18-1+ubuntu18.04.1+deb.sury.org+1    amd64        DOM, SimpleXML, WDDX, XML, and XSL module for PHP
ii  php7.2-zip                            7.2.18-1+ubuntu18.04.1+deb.sury.org+1    amd64        Zip module for PHP

行った対応

php7.2用 moduleのインストール

$ sudo apt install libapache2-mod-php7.2

apache.confに下記を追加

LoadModule php7_module modules/libphp7.2.so

apacheの再起動

sudo service apache2 restart
5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6