2015年5月26日火曜日

5 Apache2 の設定

5-0 Apache2 のインストール
インストールされていないときは、Synaptic パッケージマネージャでインストールしてください。

Web ブラウザ(iceweasel)のアドレスバーに「http://localhost/」と入力してEnter キーを押して右の図のように表示されれば、Apache2 が動作しています。






次のように表示されると、Apache が動作していない可能性があります。
そのときは、Synaptic パッケージマネージャでインストールします。




apache のバージョンは 2.4.10 です。


***** Apache2 Debian Default Page *****

It works!
This is the default welcome page used to test the correct operation of the Apache2 server after installation on Debian systems. If you can read this page, it means that the Apache HTTP server installed at this site is working properly. You should replace this file (located at /var/www/html/index.html) before continuing to operate your HTTP server.
これは Debian システムでのインストール後の Apache2 サーバーの正しい動作をテストするために使用されるデフォルトのウェルカムページです。あなたがこのページを読むことができる場合は、このサイトにインストールされた Apache HTTP サーバーが正常に動作していることを意味します。あなたは、あなたの HTTP サーバの動作を継続する前に(/var/www/html/index.htmlにある)このファイルを置き換える必要があります。

If you are a normal user of this web site and don't know what this page is about, this probably means that the site is currently unavailable due to maintenance. If the problem persists, please contact the site's administrator.
あなたがこのウェブサイトの通常のユーザーであり、このページについてわからない場合、これは、おそらく、サイトがメンテナンスのため、現在使用できないことを意味します。問題が解決しない場合は、サイトの管理者に連絡してください。

Configuration Overview
Debian's Apache2 default configuration is different from the upstream default configuration, and split into several files optimized for interaction with Debian tools. The configuration system is fully documented in /usr/share/doc/apache2/README.Debian.gz. Refer to this for the full documentation. Documentation for the web server itself can be found by accessing the manual if the apache2-doc package was installed on this server.
Debian の Apache2 のデフォルト設定は、アップストリームデフォルト(Apache2 本来の)設定とは異なり、Debian ツール​​の相互作用のために最適化された複数のファイルに分割しました。設定システムは、/usr/share/doc/apache2/README.Debian.gz にすべて記載されています。完全なドキュメントについては、これを参照してください。 apache2-doc パッケージがこのサーバーにインストールされている場合、Web サーバ自体のマニュアルは、マニュアルにアクセスすることによって見つけることができます。

The configuration layout for an Apache2 web server installation on Debian systems is as follows:
Debian システムの Apache2 Web サーバインストールの設定レイアウトは次のとおりです。

/etc/apache2/
|-- apache2.conf
|       `--  ports.conf
|-- mods-enabled
|       |-- *.load
|       `-- *.conf
|-- conf-enabled
|       `-- *.conf
|-- sites-enabled
|       `-- *.conf
         

apache2.conf is the main configuration file. It puts the pieces together by including all remaining configuration files when starting up the web server.
apache2.conf は、メインの設定ファイルです。これは、Webサーバの起動時に残りのすべての設定ファイルを含めることによって、一緒に部品を置きます。

ports.conf is always included from the main configuration file. It is used to determine the listening ports for incoming connections, and this file can be customized anytime.
ports.conf は、常にメインの設定ファイルからインクルードされます。これは、着信接続のリスニングポートを決定するために使用され、このファイルはいつでもカスタマイズすることができます。

Configuration files in the mods-enabled/, conf-enabled/ and sites-enabled/ directories contain particular configuration snippets which manage modules, global configuration fragments, or virtual host configurations, respectively.
mods-enabled/, conf-enabled/ and sites-enabled/ directories ディレクトリにある設定ファイルは、モジュール、グローバル設定フラグメント、または、仮想ホスト設定を管理する、特定の設定スニペットをそれぞれ含んでいます。

They are activated by symlinking available configuration files from their respective *-available/ counterparts. These should be managed by using our helpers a2enmod, a2dismod, a2ensite, a2dissite, and a2enconf, a2disconf . See their respective man pages for detailed information.
彼らは、それぞれの *-available/ カウンターパート(写し)から利用可能な設定ファイルをシンボリックリンクすることによってアクティベート(活性化)されます。これらは、私たちのヘルパー a2enmod、 a2dismod、a2ensite、a2dissite、および a2enconf、a2disconf を使用して管理する必要があります。詳細については、それぞれのマニュアルページを参照してください。

The binary is called apache2. Due to the use of environment variables, in the default configuration, apache2 needs to be started/stopped with /etc/init.d/apache2 or apache2ctl. Calling /usr/bin/apache2 directly will not work with the default configuration.
バイナリは apache2 と呼ばれます。環境変数の使用により、デフォルトの設定では、apache2 は、/etc/init.d/apache2 または apache2ctl で 開始/停止 する必要があります。/usr/bin/apache2 の呼び出しは、デフォルト設定で直接動作しません。

Document Roots
By default, Debian does not allow access through the web browser to any file apart of those located in /var/www, public_html directories (when enabled) and /usr/share (for web applications). If your site is using a web document root located elsewhere (such as in /srv) you may need to whitelist your document root directory in /etc/apache2/apache2.conf.
デフォルトでは、Debianは、/var/www、public_html(有効な場合)および /usr/share(Webアプリケーションのため)ディレクトリに位置するすべてのファイルから離れたところを Web ブラウザからのアクセスを許可しません。あなたのサイトは他の場所(/srv など)に位置するウェブドキュメントルートを使用している場合は、/etc/apache2/apache2.conf であなたのドキュメントルートディレクトリをホワイトリスト(許可一覧)にする必要があります。

The default Debian document root is /var/www/html. You can make your own virtual hosts under /var/www. This is different to previous releases which provides better security out of the box.
デフォルトの Debian ドキュメントルートは、/var/www/html です。あなたは、/var/www 以下に、独自の仮想ホストを作成することができます。これは、ボックスの外に優れたセキュリティを提供する以前のリリースとは異なります。

Reporting Problems
Please use the reportbug tool to report bugs in the Apache2 package with Debian. However, check existing bug reports before reporting a new bug.
Debian で Apache2 パッケージのバグを報告するためには reportbug ツールを使用してください。しかし、新しいバグを報告する前に、既存のバグレポートをチェックしてください。

Please report bugs specific to modules (such as PHP and others) to respective packages, not to the web server itself.
(PHPなどような)モジュールに固有のバグは、Webサーバ自体にではなく、それぞれのパッケージに報告してください。
***** *****


5-1 public_html ディレクトリの作成
Debian は、

/var/www
public_html(有効な場合)
/usr/share(Webアプリケーションのため)

以外の場所で Web ブラウザからのアクセスを許可しません。

public_html をサイトの公開場所(HTML ファイルの保存場所)にします。
端末(ターミナル)で user ディレクトリに public_html ディレクトリを作成します。

user@deb8-vmw:~$ mkdir public_html

5-2 Apache の設定
一般ユーザのディレクトリで Web ブラウザでアクセスできるのは public_html だけです。
public_html ディレクトリを設定しているのは /etc/apache2/mods-available/userdir.conf ファイルです。

root@deb8-vmw:~# ls /etc/apache2/mods-available/
---
userdir.conf
userdir.load
---

このファイルが有効になっているかは /etc/apache2/mods-enable/ でわかります。

root@deb8-vmw:~# ls /etc/apache2/mods-enabled/

userdir.conf がないので有効にします。

root@deb8-vmw:~# a2enmod userdir
Enabling module userdir.
To activate the new configuration, you need to run:
  service apache2 restart

Apache2 を再起動してください。

rroot@deb8-vmw:~# /etc/init.d/apache2 reload
[ ok ] Reloading apache2 configuration (via systemctl): apache2.service.
root@deb8-vmw:~# ls /etc/apache2/mods-enabled/
---
userdir.conf
userdir.load


5-3 動作確認
public_html に /var/www/html/index.html ファイルを /home/user/pulic_html/ にコピーして、Web ブラウザ(iceweasel)のアドレスバーに「http://localhost/~user」と入力してEnter キーを押して「Apache2 Debian Default Page」が表示されれば、設定完了です。

root@deb8-vmw:~# exit
ログアウト
nob61@deb8-vmw:~$ mv public_html/index.html public_html/it_works.html
nob61@deb8-vmw:~$ cp /var/www/html/index.html public_html/

0 件のコメント: