Webサーバ(Apache)
■Apache がインストールされてるかどうか確認する。
[root@server1 ~]# rpm -q httpd パッケージ httpd はインストールされていません。
■Apache のインストール
[root@server1 ~]# yum -y install httpd 読み込んだプラグイン:fastestmirror, langpacks, priorities Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * centosplus: ftp.riken.jp * epel: kartolo.sby.datautama.net.id * extras: ftp.riken.jp * rpmforge: ftp.kddilabs.jp * updates: mirrors.yun-idc.com 45 packages excluded due to repository priority protections 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> パッケージ httpd.x86_64 0:2.4.6-17.el7.centos.1 を インストール --> 依存性の処理をしています: httpd-tools = 2.4.6-17.el7.centos.1 のパッケージ: httpd-2.4.6-17.el7.centos.1.x86_64 --> 依存性の処理をしています: /etc/mime.types のパッケージ: httpd-2.4.6-17.el7.centos.1.x86_64 --> トランザクションの確認を実行しています。 ---> パッケージ httpd-tools.x86_64 0:2.4.6-17.el7.centos.1 を インストール ---> パッケージ mailcap.noarch 0:2.1.41-2.el7 を インストール --> 依存性解決を終了しました。 依存性を解決しました ==================================================================================================== Package アーキテクチャー バージョン リポジトリー 容量 ==================================================================================================== インストール中: httpd x86_64 2.4.6-17.el7.centos.1 base 2.7 M 依存性関連でのインストールをします: httpd-tools x86_64 2.4.6-17.el7.centos.1 base 77 k mailcap noarch 2.1.41-2.el7 base 31 k トランザクションの要約 ==================================================================================================== インストール 1 パッケージ (+2 個の依存関係のパッケージ) 総ダウンロード容量: 2.8 M インストール容量: 9.6 M Downloading packages: (1/3): mailcap-2.1.41-2.el7.noarch.rpm | 31 kB 00:00:00 (2/3): httpd-tools-2.4.6-17.el7.centos.1.x86_64.rpm | 77 kB 00:00:00 (3/3): httpd-2.4.6-17.el7.centos.1.x86_64.rpm | 2.7 MB 00:00:00 ---------------------------------------------------------------------------------------------------- 合計 3.9 MB/s | 2.8 MB 00:00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction インストール中 : httpd-tools-2.4.6-17.el7.centos.1.x86_64 1/3 インストール中 : mailcap-2.1.41-2.el7.noarch 2/3 インストール中 : httpd-2.4.6-17.el7.centos.1.x86_64 3/3 検証中 : mailcap-2.1.41-2.el7.noarch 1/3 検証中 : httpd-2.4.6-17.el7.centos.1.x86_64 2/3 検証中 : httpd-tools-2.4.6-17.el7.centos.1.x86_64 3/3 インストール: httpd.x86_64 0:2.4.6-17.el7.centos.1 依存性関連をインストールしました: httpd-tools.x86_64 0:2.4.6-17.el7.centos.1 mailcap.noarch 0:2.1.41-2.el7 完了しました!
■php、php-mbstringをインストール
[root@server1 ~]# yum -y install php php-mbstring 読み込んだプラグイン:fastestmirror, langpacks, priorities Loading mirror speeds from cached hostfile * base: mirrors.yun-idc.com * centosplus: ftp.riken.jp * epel: mirror.premi.st * extras: ftp.riken.jp * rpmforge: ftp.kddilabs.jp * updates: mirrors.yun-idc.com 45 packages excluded due to repository priority protections 依存性の解決をしています --> トランザクションの確認を実行しています。 ---> パッケージ php.x86_64 0:5.4.16-21.el7 を インストール --> 依存性の処理をしています: php-common(x86-64) = 5.4.16-21.el7 のパッケージ: php-5.4.16-21.el7.x86_64 --> 依存性の処理をしています: php-cli(x86-64) = 5.4.16-21.el7 のパッケージ: php-5.4.16-21.el7.x86_64 ---> パッケージ php-mbstring.x86_64 0:5.4.16-21.el7 を インストール --> トランザクションの確認を実行しています。 ---> パッケージ php-cli.x86_64 0:5.4.16-21.el7 を インストール ---> パッケージ php-common.x86_64 0:5.4.16-21.el7 を インストール --> 依存性の処理をしています: libzip.so.2()(64bit) のパッケージ: php-common-5.4.16-21.el7.x86_64 --> トランザクションの確認を実行しています。 ---> パッケージ libzip.x86_64 0:0.10.1-8.el7 を インストール --> 依存性解決を終了しました。 依存性を解決しました ==================================================================================================== Package アーキテクチャー バージョン リポジトリー 容量 ==================================================================================================== インストール中: php x86_64 5.4.16-21.el7 base 1.3 M php-mbstring x86_64 5.4.16-21.el7 base 499 k 依存性関連でのインストールをします: libzip x86_64 0.10.1-8.el7 base 48 k php-cli x86_64 5.4.16-21.el7 base 2.7 M php-common x86_64 5.4.16-21.el7 base 559 k トランザクションの要約 ==================================================================================================== インストール 2 パッケージ (+3 個の依存関係のパッケージ) 総ダウンロード容量: 5.2 M インストール容量: 18 M Downloading packages: (1/5): libzip-0.10.1-8.el7.x86_64.rpm | 48 kB 00:00:00 (2/5): php-cli-5.4.16-21.el7.x86_64.rpm | 2.7 MB 00:00:00 (3/5): php-common-5.4.16-21.el7.x86_64.rpm | 559 kB 00:00:00 (4/5): php-mbstring-5.4.16-21.el7.x86_64.rpm | 499 kB 00:00:00 (5/5): php-5.4.16-21.el7.x86_64.rpm | 1.3 MB 00:00:01 ---------------------------------------------------------------------------------------------------- 合計 4.6 MB/s | 5.2 MB 00:00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction インストール中 : libzip-0.10.1-8.el7.x86_64 1/5 インストール中 : php-common-5.4.16-21.el7.x86_64 2/5 インストール中 : php-cli-5.4.16-21.el7.x86_64 3/5 インストール中 : php-5.4.16-21.el7.x86_64 4/5 インストール中 : php-mbstring-5.4.16-21.el7.x86_64 5/5 検証中 : php-common-5.4.16-21.el7.x86_64 1/5 検証中 : php-cli-5.4.16-21.el7.x86_64 2/5 検証中 : php-mbstring-5.4.16-21.el7.x86_64 3/5 検証中 : libzip-0.10.1-8.el7.x86_64 4/5 検証中 : php-5.4.16-21.el7.x86_64 5/5 インストール: php.x86_64 0:5.4.16-21.el7 php-mbstring.x86_64 0:5.4.16-21.el7 依存性関連をインストールしました: libzip.x86_64 0:0.10.1-8.el7 php-cli.x86_64 0:5.4.16-21.el7 php-common.x86_64 0:5.4.16-21.el7 完了しました!
■Apacheの設定ファイルの編集
[root@server1 ~]# vi /etc/httpd/conf/httpd.conf
サーバー名を指定
#ServerName www.example.com:80
↓
ServerName yokensaka.com:80 ← #をはずして独自ドメインに変更
# http://httpd.apache.org/docs-2.0/mod/core.html#options
# for more information.
#
CGIの許可、SSIの許可
Options Indexes FollowSymLinks
↓
Options Includes ExecCGI FollowSymLinks
.htaccessの許可
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride None
↓
AllowOverride All
長すぎるURI(414 Error)はログに記録しない
# 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
ログの記録内容変更
# logged therein and *not* in this file.
#
#CustomLog "logs/access_log" common
この下に以下を追加
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.1 no_log
SetEnvIf Remote_Addr 127.0.0.1 no_log
CustomLog logs/access_log combined env=!no_log
デフォルトキャラセットを無効にする(文字化け対策)
AddDefaultCharset UTF-8
↓
#AddDefaultCharset UTF-8 ← #を付ける
CGIスクリプトを実行できる様にする
#AddHandler cgi-script .cgi
↓
AddHandler cgi-script .cgi .pl ← #をはずして.plを追加
チェック
[root@server1 ~]# apachectl configtest
Syntax OK
■Perlのパスが/usr/local/bin/perlでもCGIを実行出来るようにする。
[root@server1 ~]# whereis perl perl: /usr/bin/perl /usr/share/man/man1/perl.1.gz シンボリックリンク設定(/usr/local/bin/perlから/usr/bin/perlへリンクをはる [root@server1 ~]# ln -s /usr/bin/perl /usr/local/bin/perl 変更後のPerlの位置 [root@server1 ~]# whereis perl perl: /usr/bin/perl /usr/local/bin/perl /usr/share/man/man1/perl.1.gz
■ドキュメントルートの所有者変更
[root@server1 ~]# chown higo:higo /var/www/html/ WordPress対応(所有者変更) # chown -R apache:apache /var/www/html/blog ← blog,centos,fedora,1129,pf,taka # chown -R higo:higo /var/www/html/blog/wp-content/uploads # chown higo:higo /var/www/html/blog/wp-config.php ドキュメントルート所有者変更確認 [root@server1 ~]# ll /var/www/ 合計 0 drwxr-xr-x 2 root root 6 6月 18 04:12 cgi-bin drwxr-xr-x 2 higo higo 6 6月 18 04:12 html
■Apacheの起動
root@server1 ~]# systemctl start httpd
■Apacheの自動起動設定
[root@server1 ~]# systemctl enable httpd ln -s '/usr/lib/systemd/system/httpd.service' '/etc/systemd/system/multi-user.target.wants/httpd.service'
■起動確認
[root@server1 ~]# systemctl status httpd
httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
Active: active (running) since 土 2014-10-25 10:48:28 JST; 10s ago
Main PID: 4098 (httpd)
Status: "Total requests: 0; Current requests/sec: 0; Current traffic: 0 B/sec"
CGroup: /system.slice/httpd.service
├─4098 /usr/sbin/httpd -DFOREGROUND
├─4100 /usr/sbin/httpd -DFOREGROUND
├─4101 /usr/sbin/httpd -DFOREGROUND
├─4102 /usr/sbin/httpd -DFOREGROUND
├─4103 /usr/sbin/httpd -DFOREGROUND
└─4104 /usr/sbin/httpd -DFOREGROUND
10月 25 10:48:27 server1.yokensaka.com systemd[1]: Starting The Apache HTTP Server...
10月 25 10:48:28 server1.yokensaka.com systemd[1]: Started The Apache HTTP Server.
■公開前の準備
ホームページを外部に公開するに当たって、ルータの設定でポート番号80番を開ける必要がある。

