●Apace2設定ファイル編集
# vi /etc/apache2/conf/httpd.conf
LoadModule deflate_module modules/mod_deflate.so の記述有無確認
?mod_deflate.so で検索
SetOutputFilter DEFLATE 追記(DEFLATEを有効化)
DeflateCompressionLevel 5 追記(圧縮レベルを指定(低1~9高))
BrowserMatch ^Mozilla/4 gzip-only-text/html 追記(ブラウザがNetscape 4.xの場合はtext/htmlのみ圧縮)
BrowserMatch ^Mozilla/4\.0[678] no-gzip 追記(ブラウザがNetscape 4.06-4.08の場合は圧縮しない)
BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html 追記(ブラウザがMSIEの場合は全て圧縮)
Header append Vary User-Agent env=!dont-vary 追記(圧縮未対応ブラウザへは圧縮ファイルを送信しない)
以下ログ取得の記述
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%) %{User-agent}i' deflate
CustomLog logs/deflate_log deflate
編集終了 保存
●Apace2再起動
# /etc/rc.d/init.d/apache2 restart
Apache2 HTTP Serverを停止中: [ OK ]
Apache2 HTTP Serverを起動中: [ OK ]
●データ圧縮の確認
ログの確認
# tail /var/log/apache2/deflate_log
"GET / HTTP/1.1" -/- (-%) Mozilla/5.0 (Windows NT 6.3; WOW64; Trident/7.0; rv:11.0) like Gecko
"GET /browserconfig.xml HTTP/1.1" -/- (-%) Mozilla/5.0 (Windows NT 6.3; Win64; x64; Trident/7.0; rv:11.0) like Gecko
これでいいのでしょうか。。。。。。。。。。。。。??
まっ
良いことにしてツギすすみま~す。
■http://ドメイン/~ユーザー名でアクセスできるようにする
# vi /etc/apache2/conf/httpd.conf
#UserDir disable # を追記(コメントアウト)
UserDir public_html # を削除
以下の分部の#削除
<Directory /home/*/public_html>
AllowOverride FileInfo AuthConfig Limit
Options MultiViews SymLinksIfOwnerMatch IncludesNoExec Indexesを削除
<Limit GET POST OPTIONS>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
●ユーザーのCGI専用ディレクトリの設定
#ScriptAlias /cgi-bin/ "/var/www/cgi-bin/" # を追記(コメントアウト)
ScriptAlias /cgi_bin/ /home/httpd/cgi_bin/ 追記
以下をコメントアウト
#<Directory "/var/www/cgi-bin">
# AllowOverride None
# Options None
# Order allow,deny
# Allow from all
#</Directory>
以下を追記
/home/httpd/cgi_binでCGIを使えるようにする
<Directory /home/httpd/cgi_bin> 私の環境ではcgi_bin
AllowOverride None
Options ExecCGI CGIを有効にする
Order allow,deny
Allow from all
</Directory>
ユーザーディレクトリ/home/ユーザー/public_html/cgi_binでCGIを使えるようにする
<Directory /home/*/public_html/cgi_bin>
AllowOverride FileInfo AuthConfig Limit
Options ExecCGI CGIを有効にする
Order allow,deny
Allow from all
</Directory>
編集終了 保存
●Apache2再起動
# /etc/rc.d/init.d/apache2 restart
Apache2 HTTP Serverを停止中: [ OK ]
Apache2 HTTP Serverを起動中: [ OK ]
■バーチャルホスト(http://ユーザー名.ドメインで接続する)設定
# vi /etc/apache2/conf/httpd.conf
ServerName www.xxmainxx.com 追記(メインのドメイン名)
NameVirtualHost *:80 追記
●メインのドメイン設定
----------------------------------------!注意 -------------------------------------------------------
NameVirtualHost *:80 として
<VirtualHost *:80> とすること
:80を入れないで*のままだと、Apache2起動時下記エラーが発生する
OKが出るのでOKかと思うとOKではないApache2は起動していないのです
Apache2 HTTP Serverを起動中: [Mon Jul 14 14:28:46 2014] [error] VirtualHost _default_:443 -- mixing ports and non-* ports with a NameVirtualHost address is not supported, proceeding with undefined rsults
[ OK ]
----------------------------------------------------------------------------------------------------------
以下を追記
<VirtualHost *:80>
ServerName www.xxmain1xx.com メインのドメイン名(www.xxmain1xx.comは自分のドメイン)
DocumentRoot /home/httpd/html メインのディレクトリ
HostNameLookups double
UseCanonicalName off
</VirtualHost>
1つのメインディレクトリに対して複数のドメインを使用する場合は設定(追記)
(私の環境では訳あって必要ですが一般的には不要と思われます)
<VirtualHost *:80>
ServerName www.xxmain2xx.net 別のメインのドメイン名(www.xxmain2xx.netは自分のドメイン)
DocumentRoot /home/httpd/html メインのディレクトリ
HostNameLookups double
UseCanonicalName off
</VirtualHost>
↓↓↓
----------------- 参考 ---------------------------------------------------------------------
将来はこのように別のドメインをバーチャルホストに移行して
http://www.xxmain2.netで接続予定
<VirtualHost *:80>
ServerName www.xxmain2xx.net
DocumentRoot /home/xx2xx/public_html
HostNameLookups double
UseCanonicalName off
</VirtualHost>
-------------------------------------------------------------------------------------------------
●バーチャルホスト、サブドメインの設定
----------------- 参考 ---------------------------------------------------------------------
私の環境ではサブドメイン設定しない
<VirtualHost *:80>
ServerAdmin 1234@xxxxx.com
DocumentRoot /home/ユーザー名/public_html ドキュメントルート設定
ServerName 1234.xxxxx.com 1234の部分はユーザーの任意
</VirtualHost>
他にもサブドメインがある場合は同様に追加する。
-------------------------------------------------------------------------------------------------
●1台のサーバーで複数のドメインを運用する設定
メインのドメインとは違うドメインで接続する場合の設定
(1つのサーバで複数のメインドメインを使う場合)
<VirtualHost *:80>
ServerName xxdomein3xx.info
DocumentRoot /home/xx3xx/public_html xx3xxはxxdomein3xx.infoのホームディレクトリ
HostNameLookups double
UseCanonicaiName off
</VirtualHost>
----------------------------- 参考 ------------------------------------------------------------
サブドメインwww.を使う場合は追記する
<VirtualHost *:80>
ServerName www.xxdomein3xx.info
DocumentRoot /home/xx3xx/public_html
HostNameLookups double
UseCanonicaiName off
</VirtualHost>
--------------------------------------------------------------------------------------------------
他にもドメインがある場合は同様に追加する。
編集終了 保存
Apache2再起動
# /etc/rc.d/init.d/apache2 restart
Apache2 HTTP Serverを停止中: [ OK ]
Apache2 HTTP Serverを起動中: [ OK ]
■ユーザーごとのApache2ログを取得する
# mkdir /var/log/apache2/xxmain2xx ユーザー2個別のログディレクトリ作製
# mkdir /var/log/apache2/xxmain3xx ユーザー3個別のログディレクトリ作製
●Apache2の設定ファイル編集
# vi /etc/apache2/conf/httpd.conf
/~ユーザー名 の場合下記を追記(私の環境の場合)
-----この設定イマイチかなぁ Apacheエラーが出る(未解決)--------
~xxmain2xxを追記
SetEnvIf Request_URI "/~xxmain2xx/" xxmain2xx nolog
CustomLog logs/xxmain2xx/access_log combined env=xxmain2xx
~xxmain3xxを追記
SetEnvIf Request_URI "/~xxmain3xx /" xxmain3xx nolog
CustomLog logs/xxmain3xx /access_log combined env=xxmain3xx
●Apache2のメインログの設定
設定ファイル編集
# vi /etc/logrotate.d/apache2
/var/log/apache2/*log >
daily daily, weekly, monthlyのいずれかを指定
rotate 14 履歴の数を指定/
missingok
notifempty
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/apache2.pid 2>/dev/null` 2> /dev/null || true
endscript
}
●ユーザー用のログ設定
以下を追記する
/var/log/apache2/*/*log {
daily 毎日
rotate 14 14日間
missingok
notifempty
sharedscripts
postrotate
/bin/kill -HUP `cat /var/run/apache2.pid 2>/dev/null` 2> /dev/null || true
endscript
}
編集終了 保存
●ログファイル末尾の日付を1からの連番にする
access_log-20140801 → access_log.1のようにする
# vi /etc/logrotate.conf
#dateext #追加してコメントアウトする
編集終了 保存
この記事はこちらにも記載しています。
こちらの方が見やすいと思います。
【Vine Linuxで自宅サーバー】様を参考にしてサーバーを構築しています。