LoginSignup
14
17

More than 5 years have passed since last update.

Ubuntuにapache2をインストール(apt-get)

Last updated at Posted at 2016-03-10

やったこと

ubuntuにapache2をapt-getからインストール
各種設定(ajp設定、SSL設定)

インストール手順

セキュリティ設定

cd /etc/apache2/conf-available
cp -i security.conf{,.org}
vim security.conf

以下に書換え

security.conf
ServerTokens Prod
ServerSignature Off

サイト設定

cd /etc/apache2/sites-available
cp -i 000-default.conf [any name].conf
vim [any name].conf

以下を書換え

DocumentRoot [ドキュメントルート]

以下を追記

<Directory "[ドキュメントルート]">
    Require all granted
</Directory>

サイト設定(SSL)

cd /etc/apache2/sites-available
cp -i 000-default-ssl.conf [any name]-ssl.conf
vim [any name]-ssl.conf

以下を書換え

DocumentRoot [ドキュメントルート]

以下を追記

<Directory "[ドキュメントルート]">
    Require all granted
</Directory>

default-ssl.confも書き換え必要みたい・・

cp -i default-ssl.conf{,.org}
vim default-ssl.conf

以下を書換え

DocumentRoot [ドキュメントルート]

以下を追記

<Directory "[ドキュメントルート]">
    Require all granted
</Directory>

ProxyPass設定

cd /etc/apache2/mods-available
vim proxy_ajp.conf

以下を追記

AJPポートが8009の場合
<Location /[コンテキストルート]/>
    ProxyPass ajp://localhost:8009/[コンテキストルート]/
</Location>
a2enmod proxy_ajp

こんなメッセージが出ます

Considering dependency proxy for proxy_ajp:
Enabling module proxy.
Enabling module proxy_ajp.
To activate the new configuration, you need to run:
  service apache2 restart

SSL関連のモジュールを有効化

a2enmod ssl
a2ensite default-ssl

Apache起動

service apache2 start

自動起動設定

apt-get install sysv-rc-conf
sysv-rc-conf --list | grep apache2
sysv-rc-conf apache2 on

Appendix

注意

Apache2.4系からはドキュメントルートの記述が少し変わったらしい・・
今まで

Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all

2.4系

Require all granted

こうしないと↓のようなエラーが発生する場合があります

[client 127.0.0.1:52597] AH01630: client denied by server configuration

詳細はこちらを参考に

参考サイト

http://server-setting.info/debian/apache-install-debian-ubuntu.html#apachehttpd_1
http://mole-kingdom.com/wpbl/2012/09/28/3718.html

14
17
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
14
17