【Linux】 apache設定の基本
公開日:
:
最終更新日:2014/05/09
apache
基本
本件のマニュアルはこちら → Apache
一般的な設定ファイルの場所
ls /etc/httpd/conf/httpd.conf
文法
httpd.conf
# これはコメントです # 設定ファイル内のシンボルはディレクティブと呼ばれます # 例)Timeoutディレクティブでタイムアウト時間を指定します Timeout 60 #"<"と">"に囲まれた要素をセクションディレクティブといいます <IfModule prefork.c> StartServers 8 MinSpareServers 5 MaxSpareServers 20 ServerLimit 256 MaxClients 256 MaxRequestsPerChild 4000 </IfModule> # Directoryディレクティブ内に記述した内容は指定したパス内にだけ適用されます <Directory /> Options FollowSymLinks AllowOverride None </Directory>
設定の反映
$ apachectl configtest
apacheを再起動して設定を
$ service httpd restart
よくある設定
ディレクトリ内のファイル一覧を表示しない
<Directory "/var/www/html"> # Options Indexes FollowSymLinks Options -Indexes FollowSymLinks #-> Indexesの前に"-"を追加 AllowOverride None Order allow,deny Allow from all
レスポンスにOSサーバー情報を表示しない
Forbidden画面などにもサーバー情報が表示されなくなる
#ServerTokens OS ServerTokens Prod #ServerSignature On ServerSignature Off
テストページを表示しない
/etc/httpd/conf.d/welcome.conf
# 下記2行をコメントアウト # Options -Indexes # ErrorDocument 403 /error/noindex.html
パフォーマンス設定
同一クライアントからのリクエストにはセッションを維持する
維持する時間は10秒間
#KeepAlive Off KeepAlive On #KeepAliveTimeout 15 KeepAliveTimeout 10
phpの設定
apacheにphpを認識させる設定を探すと下記のように記述する記事が散見されます。
AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps
しかしawsのLinuxインスタンスでyumでphpをインストールすると/etc/httpd/conf.d/php.confが作られ、apacheを再起動するだけでphpが認識されるようになりました。
yum -y install mysql-server service httpd restart
htaccessファイルの有効無効
#無効 #AllowOverride None #有効 AllowOverride All
関連記事
記事はありませんでした