LoginSignup
0
6

More than 5 years have passed since last update.

CentOS7.4にApacheインストール

Posted at

前回のCentOS7.4の初期設定からの続き
LAMP環境構築のAにあたるApache(Webサーバ)をCentOS7.4にインストール

【構成】
Windows7 Pro(32bit)
VirtualBox 5.2.8
CentOS 7.4.1708

CentOS7にApache 2.4をインストール

yumでApacheをインストール

# yum -y install httpd

Apache 2.4 初期設定

/etc/httpd/conf/httpd.conf
# vi /etc/httpd/conf/httpd.conf

#ServerName www.example.com:80
↓
ServerName local.centos74.com:80  ←  サーバ名を指定(適当につけてるので、適宜修正)
<Directory "/var/www/html">
#
# The Options directive is both complicated and important.  Please see
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#
    Options Indexes FollowSymLinks
    ↓
    Options Includes ExecCGI FollowSymLinks  ←  CGIとSSIを許可

#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
    AllowOverride None
    ↓
    AllowOverride All  ←  .htaccessの許可

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
#
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
↓
LogFormat "%h %l %u %t \"%!414r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined  ←  414エラーは除外

#
# If you prefer a logfile with access, agent, and referer information
# (Combined Logfile Format) you can use the following directive.
#
SetEnvIf Request_URI "default\.ida" no_log  ←  追加
SetEnvIf Request_URI "cmd\.exe" no_log  ←  追加
SetEnvIf Request_URI "root\.exe" no_log  ←  追加
SetEnvIf Request_URI "Admin\.dll" no_log  ←  追加
SetEnvIf Request_URI "NULL\.IDA" no_log  ←  追加
SetEnvIf Remote_Addr 192.168.56 no_log  ←  追加
SetEnvIf Remote_Addr 127.0.0.1 no_log  ←  追加
CustomLog logs/access_log combined env=!no_log  ←  上記以外をアクセスログに出力

#AddHandler cgi-script .cgi
↓
AddHandler cgi-script .cgi .pl  ←  CGIスクリプトに拡張子plを追加

AddDefaultCharset UTF-8
↓
#AddDefaultCharset UTF-8  ←  コメントアウト(文字化け対応)

以下を最終行に追加
TraceEnable off  ←  Traceメソッドを無効化(クロスサイトトレーシング対策)
/etc/httpd/conf.d/autoindex.conf
# vi /etc/httpd/conf.d/autoindex.conf  ←  autoindex設定ファイル編集
<Directory "/usr/share/httpd/icons">
    Options Indexes MultiViews FollowSymlinks
    ↓
    Options MultiViews  ←  iconsディレクトリのファイル一覧を表示しないようにする
    AllowOverride None
    Require all granted
</Directory>
テストページ削除
# rm -f /etc/httpd/conf.d/welcome.conf
# rm -f /var/www/error/noindex.html

ドキュメントルートのオーナー変更

# chown apache. /var/www/html/

Apache起動

# systemctl start httpd  ←  Apache起動
# systemctl enable httpd  ←  Apache自動起動設定
# ps -ef | grep httpd  ←  起動確認

Apache起動確認

# echo test >> /var/www//html/index.html  ←  テストページ作成
# curl http://127.0.0.1/  ←  HTTP経由で確認(HostPCのブラウザからは、http://IPアドレス/で確認可能)
# rm -f /var/www//html/index.html  ←  テストページ削除

次回は、LAMPM Mysqlのインストールを行います。

0
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
0
6