** 環境 [#nd74f399]

- OS X 10.11 El Capitan
- Vagrant 1.8.1
- VirtualBox 5.0.20
- CentOS 6.7

** CentOS 初期設定 [#cb191507]

- selinux 無効化

 $ sudo setenforce 0

 $ sudo vi /etc/sysconfig/selinux

 SELINUX=disabled

- iptables 無効化

 $ sudo /sbin/service iptables stop
 $ sudo chkconfig iptables off

- OS 再起動

** Apache インストール [#c07ce552]

- httpd インストール

 $ sudo yum -y install httpd
 $ httpd -v
 Server version: Apache/2.2.15 (Unix)

** PHP インストール [#bcd0c764]

- EPEL リポジトリ追加

 $ sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

- Remi リポジトリダウンロード

 $ wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

- Remi リポジトリ追加

 $ sudo rpm -Uvh remi-release-6.rpm

- PHP 7.1 をインストール (openssl, pdo, mysql, mbstring, tokenizer, xml モジュール含む)

 $ sudo yum -y install --enablerepo=remi,remi-php71 php php-devel php-openssl php-pdo php-mysql php-mbstring php-tokenizer php-xml

 $ php --version
 PHP 7.1.7 (cli) (built: Jul  6 2017 13:46:08) ( NTS )

- PHP インストール済みモジュール確認

 $ php -m

** Apache 起動 [#we324042]

- Apache を起動

 $ sudo /sbin/service httpd start

- 自動起動設定

 $ sudo chkconfig httpd on

** PHP 動作確認 [#k3a1f640]

- index.php 作成

 $ cd /var/www/html/

 $ sudo vi index.php

 <?php
 echo "Hello World!"
 ?>
 <!DOCTYPE html>
 <html lang="ja">
 <body>
     <p>Hello World <?php echo "from PHP!";?></p>
 <body>
 </html>

- DocumentRoot 権限変更

 $ sudo chown -R apache:apache /var/www/html/

- ブラウザ経由で確認

- index.php 削除

 $ sudo rm index.php

** Apache ログ 設定確認 [#n6e40597]

 $ sudo vi /etc/httpd/conf/httpd.conf

- CustomLog 設定追加 (custom を追加)

 LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
 LogFormat "%h %l %u %t \"%r\" %>s %b" common
 LogFormat "%{Referer}i -> %U" referer
 LogFormat "%{User-agent}i" agent
 LogFormat "%a %h %l %u %t \"%r\" %>s %b" custom

- LogFormat を custom に指定

 #CustomLog logs/access_log combined
 #CustomLog logs/access_log common
 CustomLog logs/access_log custom

- ErrorLog 設定確認

 ErrorLog logs/error_log

*** アクセスログ確認 [#p0c93232]

 $ sudo cat /var/log/httpd/access_log

 192.168.33.1 192.168.33.1 - - [17/Jul/2017:07:38:41 +0000] "GET / HTTP/1.1" 200 100
 192.168.33.1 192.168.33.1 - - [17/Jul/2017:07:38:53 +0000] "GET /index.php HTTP/1.1" 200 100
 192.168.33.1 192.168.33.1 - - [17/Jul/2017:07:39:12 +0000] "GET /phpinfo.php HTTP/1.1" 200 85687

*** エラーログ確認 [#c9b77988]

 $ sudo cat /var/log/httpd/error_log


トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS