LoginSignup
1
1

More than 3 years have passed since last update.

CentOS6 + Apache + PHP7 on Docker

Posted at

流れ

  • Dockerfile などを少しだけ書く
  • docker コマンドを叩く
  • アクセス可能になる

本題

まず、以下の3つのファイルを用意します。

  • Dockerfile
  • test.html
  • test.php
Dockerfile
FROM centos:6

RUN rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
RUN rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

RUN yum -y install --enablerepo=remi,remi-php71 \
  php \
  httpd

COPY test.html /var/www/html/test.html
COPY test.php /var/www/html/test.php

ENTRYPOINT ["/usr/sbin/httpd", "-DFOREGROUND"]
test.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
  This is test.html
</body>
</html>
test.php
<?php
phpinfo();
?>

つぎに、docker コマンドを叩きます。

$ docker build -t apache-test .
$ docker run -d -p 8080:80 apache-test

これでアクセスが可能となります。簡単!

open http://localhost:8080/test.html
open http://localhost:8080/test.php

image.png

おわり :lemon:

1
1
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
1
1