ゼロからはじめるWEBプログラミング入門

未経験者でも初心者でも関係なく、とにかくWEBサイトを作るところから始めるブログ!

Apacheをインストール&初期設定

はじめに

nginxをインストールして使おうとしてたけど、GitBucket の動作がよろしくない。
事象はLogin時にURLが http://localhost:8080 に遷移するので、リダイレクトの設定したけどうまくいかなかったので、あきらめて Apache を入れます。


Apacheインストー

yum install httpd
  • パッケージ f:id:sbc-web:20170507190104p:plain

  • インストール完了 f:id:sbc-web:20170507190112p:plain


自動起動有効化 & Apahe起動

# 自動起動を有効化
systemctl enable httpd

# Apache起動
systemctl start httpd

f:id:sbc-web:20170507203054p:plain


ブラウザで確認

  • 起動することを確認 f:id:sbc-web:20170507203450p:plain


初期設定

  • バージョン非表示
  • ファイル一覧の非表示(Indexes削除)
/etc/httpd/conf/httpd.conf
<Directory "/var/www/html">

    ~(中略)~

    # [変更] ディレクトリ内のファイル一覧を非表示
    #Options Indexes FollowSymLinks
    Options FollowSymLinks

    ~(中略)~

</Directory>

~(中略)~

# [追加] レスポンスヘッダーの「Server」のバージョン非表示
ServerTokens Prod
/etc/httpd/conf.d/autoindex.conf
<Directory "/usr/share/httpd/icons">

    ~(中略)~

    # [変更] ディレクトリ内のファイル一覧を非表示
    #Options Indexes MultiViews FollowSymlinks
    Options MultiViews FollowSymlinks

    ~(中略)~
</Directory>
/etc/httpd/conf.d/userdir.conf
<Directory "/home/*/public_html">

    ~(中略)~

    # [変更] ディレクトリ内のファイル一覧を非表示
    #Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
    Options MultiViews SymLinksIfOwnerMatch IncludesNoExec

    ~(中略)~
</Directory>


おわりに

次回以降はSSL(https)やTomcatとの連携(ajp)をやっていきます。