
PHP-FPM(php7.4) Apache2.4 on Ubutnu20.04 Webサーバ構築
2021-01-193 min read
目次
概要
Ubuntu20.04 に PHP7.4 + Apache2.4 をインストールしてWebサーバを構築した際のメモです。 ここで紹介するのはデフォルトと殆ど変わらないオプションでApache + php-fpmを構築する手順です。
環境
- Ubuntu20.04 (docker)
$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.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=focal
UBUNTU_CODENAME=focal
docker は次のオプションで起動する。
$ docker run -it --name my-ubuntu --privileged --publish=8080:80 ubuntu /bin/bash
パッケージの更新
$ apt update
$ apt upgrade
Apache と PHP のインストール
以下のコマンドでパッケージをインストールする
$ apt install apache2 php libapache2-mod-php
php のバージョンを確認
php --version
PHP 7.4.3 (cli) (built: Oct 6 2020 15:47:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
apache のバージョンを確認
$ apachectl -v
Server version: Apache/2.4.41 (Ubuntu)
Server built: 2020-08-12T19:46:17
Apache のサービスを開始する
$ service apache2 start
動作状況を確認
$ service apache2 status
* apache2 is running
PHPファイルを作成
$ echo '<?php' > /var/www/html/index.php
$ echo 'phpinfo();' >> /var/www/html/index.php
以下のURLから動作を確認。
http://localhost:8080/index.php
参考にしたサイト
Recommends
New Posts
Hot posts!
Date
Tags
Author