環境

CentOS 初期設定

$ sudo setenforce 0
$ sudo vi /etc/sysconfig/selinux
SELINUX=disabled
$ sudo /sbin/service iptables stop
$ sudo chkconfig iptables off

Apache インストール

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

PHP インストール

$ sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
$ wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
$ sudo rpm -Uvh remi-release-6.rpm
$ 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 -m

Apache 起動

$ sudo /sbin/service httpd start
$ sudo chkconfig httpd on

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>
$ sudo chown -R apache:apache /var/www/html/
$ sudo rm index.php

Apache ログ 設定確認

$ sudo vi /etc/httpd/conf/httpd.conf
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
#CustomLog logs/access_log combined
#CustomLog logs/access_log common
CustomLog logs/access_log custom
ErrorLog logs/error_log

アクセスログ確認

$ 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

エラーログ確認

$ sudo cat /var/log/httpd/error_log

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