Webサーバーを構築します。
apache2 を導入するのは何年振りになるでしょうか。
apacheとapache2 は別プログラムと考えて良いほど設定が異なります。
root@meckk:~# apt-get install apache2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common file libapr1
libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libexpat1 libldap-2.4-2
libmagic1 libsasl2-2 libsasl2-modules mime-support openssl ssl-cert
Suggested packages:
www-browser apache2-doc apache2-suexec apache2-suexec-custom
libsasl2-modules-otp libsasl2-modules-ldap libsasl2-modules-sql
libsasl2-modules-gssapi-mit libsasl2-modules-gssapi-heimdal ca-certificates
openssl-blacklist
The following NEW packages will be installed:
apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common file
libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap libexpat1
libldap-2.4-2 libmagic1 libsasl2-2 libsasl2-modules mime-support openssl
ssl-cert
0 upgraded, 18 newly installed, 0 to remove and 0 not upgraded.
Need to get 4013 kB of archives.
After this operation, 13.2 MB of additional disk space will be used.
Do you want to continue [Y/n]?
Get:1 http://ftp.jp.debian.org/debian/ squeeze/main libmagic1 armel 5.04-5+squeeze2 [238 kB]
Get:2 http://ftp.jp.debian.org/debian/ squeeze/main file armel 5.04-5+squeeze2 [49.6 kB]
Get:3 http://ftp.jp.debian.org/debian/ squeeze/main libsasl2-2 armel 2.1.23.dfsg1-7 [106 kB]
Get:4 http://ftp.jp.debian.org/debian/ squeeze/main libldap-2.4-2 armel 2.4.23-7.2 [189 kB]
Get:5 http://ftp.jp.debian.org/debian/ squeeze/main mime-support all 3.48-1 [34.2 kB]
Get:6 http://ftp.jp.debian.org/debian/ squeeze/main libapr1 armel 1.4.2-6+squeeze4 [90.3 kB]
Get:7 http://ftp.jp.debian.org/debian/ squeeze/main libexpat1 armel 2.0.1-7 [118 kB]
Get:8 http://ftp.jp.debian.org/debian/ squeeze/main libaprutil1 armel 1.3.9+dfsg-5 [83.9 kB]
Get:9 http://ftp.jp.debian.org/debian/ squeeze/main libaprutil1-dbd-sqlite3 armel 1.3.9+dfsg-5 [27.5 kB]
Get:10 http://ftp.jp.debian.org/debian/ squeeze/main libaprutil1-ldap armel 1.3.9+dfsg-5 [25.4 kB]
Get:11 http://ftp.jp.debian.org/debian/ squeeze/main apache2.2-bin armel 2.2.16-6+squeeze7 [1357 kB]
Get:12 http://ftp.jp.debian.org/debian/ squeeze/main apache2-utils armel 2.2.16-6+squeeze7 [170 kB]
Get:13 http://ftp.jp.debian.org/debian/ squeeze/main apache2.2-common armel 2.2.16-6+squeeze7 [307 kB]
Get:14 http://ftp.jp.debian.org/debian/ squeeze/main apache2-mpm-worker armel 2.2.16-6+squeeze7 [2246 B]
Get:15 http://ftp.jp.debian.org/debian/ squeeze/main apache2 armel 2.2.16-6+squeeze7 [1396 B]
Get:16 http://ftp.jp.debian.org/debian/ squeeze/main libsasl2-modules armel 2.1.23.dfsg1-7 [145 kB]
Get:17 http://ftp.jp.debian.org/debian/ squeeze/main openssl armel 0.9.8o-4squeeze12 [1053 kB]
Get:18 http://ftp.jp.debian.org/debian/ squeeze/main ssl-cert all 1.0.28 [14.8 kB]
Fetched 4013 kB in 45s (87.7 kB/s)
Preconfiguring packages ...
Selecting previously deselected package libmagic1.
(Reading database ... 10442 files and directories currently installed.)
Unpacking libmagic1 (from .../libmagic1_5.04-5+squeeze2_armel.deb) ...
Selecting previously deselected package file.
Unpacking file (from .../file_5.04-5+squeeze2_armel.deb) ...
Selecting previously deselected package libsasl2-2.
Unpacking libsasl2-2 (from .../libsasl2-2_2.1.23.dfsg1-7_armel.deb) ...
Selecting previously deselected package libldap-2.4-2.
Unpacking libldap-2.4-2 (from .../libldap-2.4-2_2.4.23-7.2_armel.deb) ...
Selecting previously deselected package mime-support.
Unpacking mime-support (from .../mime-support_3.48-1_all.deb) ...
Selecting previously deselected package libapr1.
Unpacking libapr1 (from .../libapr1_1.4.2-6+squeeze4_armel.deb) ...
Selecting previously deselected package libexpat1.
Unpacking libexpat1 (from .../libexpat1_2.0.1-7_armel.deb) ...
Selecting previously deselected package libaprutil1.
Unpacking libaprutil1 (from .../libaprutil1_1.3.9+dfsg-5_armel.deb) ...
Selecting previously deselected package libaprutil1-dbd-sqlite3.
Unpacking libaprutil1-dbd-sqlite3 (from .../libaprutil1-dbd-sqlite3_1.3.9+dfsg-5_armel.deb) ...
Selecting previously deselected package libaprutil1-ldap.
Unpacking libaprutil1-ldap (from .../libaprutil1-ldap_1.3.9+dfsg-5_armel.deb) ...
Selecting previously deselected package apache2.2-bin.
Unpacking apache2.2-bin (from .../apache2.2-bin_2.2.16-6+squeeze7_armel.deb) ...
Selecting previously deselected package apache2-utils.
Unpacking apache2-utils (from .../apache2-utils_2.2.16-6+squeeze7_armel.deb) ...
Selecting previously deselected package apache2.2-common.
Unpacking apache2.2-common (from .../apache2.2-common_2.2.16-6+squeeze7_armel.deb) ...
Selecting previously deselected package apache2-mpm-worker.
Unpacking apache2-mpm-worker (from .../apache2-mpm-worker_2.2.16-6+squeeze7_armel.deb) ...
Selecting previously deselected package apache2.
Unpacking apache2 (from .../apache2_2.2.16-6+squeeze7_armel.deb) ...
Selecting previously deselected package libsasl2-modules.
Unpacking libsasl2-modules (from .../libsasl2-modules_2.1.23.dfsg1-7_armel.deb) ...
Selecting previously deselected package openssl.
Unpacking openssl (from .../openssl_0.9.8o-4squeeze12_armel.deb) ...
Selecting previously deselected package ssl-cert.
Unpacking ssl-cert (from .../ssl-cert_1.0.28_all.deb) ...
Processing triggers for man-db ...
Setting up libmagic1 (5.04-5+squeeze2) ...
Setting up file (5.04-5+squeeze2) ...
Setting up libsasl2-2 (2.1.23.dfsg1-7) ...
Setting up libldap-2.4-2 (2.4.23-7.2) ...
Setting up mime-support (3.48-1) ...
Setting up libapr1 (1.4.2-6+squeeze4) ...
Setting up libexpat1 (2.0.1-7) ...
Setting up libaprutil1 (1.3.9+dfsg-5) ...
Setting up libaprutil1-dbd-sqlite3 (1.3.9+dfsg-5) ...
Setting up libaprutil1-ldap (1.3.9+dfsg-5) ...
Setting up apache2.2-bin (2.2.16-6+squeeze7) ...
Setting up apache2-utils (2.2.16-6+squeeze7) ...
Setting up apache2.2-common (2.2.16-6+squeeze7) ...
Enabling site default.
Enabling module alias.
Enabling module autoindex.
Enabling module dir.
Enabling module env.
Enabling module mime.
Enabling module negotiation.
Enabling module setenvif.
Enabling module status.
Enabling module auth_basic.
Enabling module deflate.
Enabling module authz_default.
Enabling module authz_user.
Enabling module authz_groupfile.
Enabling module authn_file.
Enabling module authz_host.
Enabling module reqtimeout.
Setting up apache2-mpm-worker (2.2.16-6+squeeze7) ...
Starting web server: apache2apache2: apr_sockaddr_info_get() failed for meckk
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
.
Setting up apache2 (2.2.16-6+squeeze7) ...
Setting up libsasl2-modules (2.1.23.dfsg1-7) ...
Setting up openssl (0.9.8o-4squeeze12) ...
Setting up ssl-cert (1.0.28) ...
hostname: Name or service not known
make-ssl-cert: Could not get FQDN, using "meckk".
make-ssl-cert: You may want to fix your /etc/hosts and/or DNS setup and run
make-ssl-cert: make-ssl-cert generate-default-snakeoil --force-overwrite
make-ssl-cert: again.
root@meckk:~#
| |
インストールしただけで、サイトへアクセスすると表示は出るのですが、設定はこんなに簡単ではありません。
インストールした時点で表示される基本画面はどこに置いてあるかと言うと、/var/www/ にあるようです。
確認すると、index.html ファイルが1個だけ存在しております。
まずは、基本的な設定から行ってみたいと思います。
root@meckk:~# vi /etc/apache2/conf.d/security
#
# Disable access to the entire file system except for the directories that
# are explicitly allowed later.
#
# This currently breaks the configurations that come with some web application
# Debian packages.
#
#
# AllowOverride None
# Order Deny,Allow
#
# Disable access to the entire file system except for the directories that
# are explicitly allowed later.
#
# This currently breaks the configurations that come with some web application
# Debian packages.
#
#
# AllowOverride None
# Order Deny,Allow
# Deny from all
#
# Changing the following options will not really affect the security of the
# server, but might make attacks slightly more difficult in some cases.
#
# ServerTokens
# This directive configures what you return as the Server HTTP response
# Header. The default is 'Full' which sends information about the OS-Type
# and compiled in modules.
# Set to one of: Full | OS | Minimal | Minor | Major | Prod
# where Full conveys the most information, and Prod the least.
#
#ServerTokens Minimal
ServerTokens Prod OSから変更
#ServerTokens Full
#
# Optionally add a line containing the server version and virtual host
# name to server-generated pages (internal error documents, FTP directory
# listings, mod_status and mod_info output etc., but not CGI generated
# documents or custom error documents).
# Set to "EMail" to also include a mailto: link to the ServerAdmin.
# Set to one of: On | Off | EMail
#
#ServerSignature Off
ServerSignature Off On から変更
#
| |
root@meckk:~# vi /etc/apache2/mods-enabled/mime.conf
<IfModule mod_mime.c>
#
# TypesConfig points to the file containing the list of mappings from
# filename extension to MIME-type.
#
TypesConfig /etc/mime.types
#
# AddType allows you to add to or override the MIME configuration
# file mime.types for specific file types.
#
#AddType application/x-gzip .tgz
#
# AddEncoding allows you to have certain browsers uncompress
# information on the fly. Note: Not all browsers support this.
# Despite the name similarity, the following Add* directives have
# nothing to do with the FancyIndexing customization directives above.
#
#AddEncoding x-compress .Z
#AddEncoding x-gzip .gz .tgz
#AddEncoding x-bzip2 .bz2
#
# If the AddEncoding directives above are commented-out, then you
# probably should define those extensions to indicate media types:
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-bzip2 .bz2
#
# DefaultLanguage and AddLanguage allows you to specify the language of
# a document. You can then use content negotiation to give a browser a
# file in a language the user can understand.
#
# Specify a default language. This means that all data
# going out without a specific language tag (see below) will
# be marked with this one. You probably do NOT want to set
# this unless you are sure it is correct for all cases.
#
# * It is generally better to not mark a page as
# * being a certain language than marking it with the wrong
# * language!
#
# DefaultLanguage nl
#
# Note 1: The suffix does not have to be the same as the language
# keyword --- those with documents in Polish (whose net-standard
# language code is pl) may wish to use "AddLanguage pl .po" to
# avoid the ambiguity with the common suffix for perl scripts.
#
# Note 2: The example entries below illustrate that in some cases
# the two character 'Language' abbreviation is not identical to
# the two character 'Country' code for its country,
# E.g. 'Danmark/dk' versus 'Danish/da'.
#
# Note 3: In the case of 'ltz' we violate the RFC by using a three char
# specifier. There is 'work in progress' to fix this and get
# the reference data for rfc1766 cleaned up.
#
# Catalan (ca) - Croatian (hr) - Czech (cs) - Danish (da) - Dutch (nl)
# English (en) - Esperanto (eo) - Estonian (et) - French (fr) - German (de)
# Greek-Modern (el) - Hebrew (he) - Italian (it) - Japanese (ja)
# Korean (ko) - Luxembourgeois* (ltz) - Norwegian Nynorsk (nn)
# Norwegian (no) - Polish (pl) - Portugese (pt)
# Brazilian Portuguese (pt-BR) - Russian (ru) - Swedish (sv)
# Simplified Chinese (zh-CN) - Spanish (es) - Traditional Chinese (zh-TW)
#
AddLanguage am .amh
AddLanguage ar .ara
AddLanguage be .be
AddLanguage bg .bg
AddLanguage bn .bn
AddLanguage br .br
AddLanguage bs .bs
AddLanguage ca .ca
AddLanguage cs .cz .cs
AddLanguage cy .cy
AddLanguage da .dk
AddLanguage de .de
AddLanguage dz .dz
AddLanguage el .el
AddLanguage en .en
AddLanguage eo .eo
# es is ecmascript in /etc/mime.types
RemoveType es
AddLanguage es .es
AddLanguage et .et
AddLanguage eu .eu
AddLanguage fa .fa
AddLanguage fi .fi
AddLanguage fr .fr
AddLanguage ga .ga
AddLanguage gl .glg
AddLanguage gu .gu
AddLanguage he .he
AddLanguage hi .hi
AddLanguage hr .hr
AddLanguage hu .hu
AddLanguage hy .hy
AddLanguage id .id
AddLanguage is .is
AddLanguage it .it
AddLanguage ja .ja
AddLanguage ka .ka
AddLanguage kk .kk
AddLanguage km .km
AddLanguage kn .kn
AddLanguage ko .ko
AddLanguage ku .ku
AddLanguage lo .lo
AddLanguage lt .lt
AddLanguage ltz .ltz
AddLanguage lv .lv
AddLanguage mg .mg
AddLanguage mk .mk
AddLanguage ml .ml
AddLanguage mr .mr
AddLanguage ms .msa
AddLanguage nb .nob
AddLanguage ne .ne
AddLanguage nl .nl
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pa .pa
AddLanguage pl .po
AddLanguage pt-BR .pt-br
AddLanguage pt .pt
AddLanguage ro .ro
AddLanguage ru .ru
AddLanguage sa .sa
AddLanguage se .se
AddLanguage si .si
AddLanguage sk .sk
AddLanguage sl .sl
AddLanguage sq .sq
AddLanguage sr .sr
AddLanguage sv .sv
AddLanguage ta .ta
AddLanguage te .te
AddLanguage th .th
AddLanguage tl .tl
RemoveType tr
# tr is troff in /etc/mime.types
AddLanguage tr .tr
AddLanguage uk .uk
AddLanguage ur .ur
AddLanguage vi .vi
AddLanguage wo .wo
AddLanguage xh .xh
AddLanguage zh-CN .zh-cn
AddLanguage zh-TW .zh-tw
#
# Commonly used filename extensions to character sets. You probably
# want to avoid clashes with the language extensions, unless you
# are good at carefully testing your setup after each change.
# See http://www.iana.org/assignments/character-sets for the
# official list of charset names and their respective RFCs.
#
AddCharset us-ascii .ascii .us-ascii
AddCharset ISO-8859-1 .iso8859-1 .latin1
AddCharset ISO-8859-2 .iso8859-2 .latin2 .cen
AddCharset ISO-8859-3 .iso8859-3 .latin3
AddCharset ISO-8859-4 .iso8859-4 .latin4
AddCharset ISO-8859-5 .iso8859-5 .cyr .iso-ru
AddCharset ISO-8859-6 .iso8859-6 .arb .arabic
AddCharset ISO-8859-7 .iso8859-7 .grk .greek
AddCharset ISO-8859-8 .iso8859-8 .heb .hebrew
AddCharset ISO-8859-9 .iso8859-9 .latin5 .trk
AddCharset ISO-8859-10 .iso8859-10 .latin6
AddCharset ISO-8859-13 .iso8859-13
AddCharset ISO-8859-14 .iso8859-14 .latin8
AddCharset ISO-8859-15 .iso8859-15 .latin9
AddCharset ISO-8859-16 .iso8859-16 .latin10
AddCharset ISO-2022-JP .iso2022-jp .jis
AddCharset ISO-2022-KR .iso2022-kr .kis
AddCharset ISO-2022-CN .iso2022-cn .cis
AddCharset Big5 .Big5 .big5 .b5
AddCharset cn-Big5 .cn-big5
# For russian, more than one charset is used (depends on client, mostly):
AddCharset WINDOWS-1251 .cp-1251 .win-1251
AddCharset CP866 .cp866
AddCharset KOI8 .koi8
AddCharset KOI8-E .koi8-e
AddCharset KOI8-r .koi8-r .koi8-ru
AddCharset KOI8-U .koi8-u
AddCharset KOI8-ru .koi8-uk .ua
AddCharset ISO-10646-UCS-2 .ucs2
AddCharset ISO-10646-UCS-4 .ucs4
AddCharset UTF-7 .utf7
AddCharset UTF-8 .utf8
AddCharset UTF-16 .utf16
AddCharset UTF-16BE .utf16be
AddCharset UTF-16LE .utf16le
AddCharset UTF-32 .utf32
AddCharset UTF-32BE .utf32be
AddCharset UTF-32LE .utf32le
AddCharset euc-cn .euc-cn
AddCharset euc-gb .euc-gb
AddCharset euc-jp .euc-jp
AddCharset euc-kr .euc-kr
#Not sure how euc-tw got in - IANA doesn't list it???
AddCharset EUC-TW .euc-tw
AddCharset gb2312 .gb2312 .gb
AddCharset iso-10646-ucs-2 .ucs-2 .iso-10646-ucs-2
AddCharset iso-10646-ucs-4 .ucs-4 .iso-10646-ucs-4
AddCharset shift_jis .shift_jis .sjis
#
# AddHandler allows you to map certain file extensions to "handlers":
# actions unrelated to filetype. These can be either built into the server
# or added with the Action directive (see below)
#
# To use CGI scripts outside of ScriptAliased directories:
# (You will also need to add "ExecCGI" to the "Options" directive.)
#
AddHandler cgi-script .cgi .pl コメンとの削除と .pl を追加
#
# For files that include their own HTTP headers:
#
#AddHandler send-as-is asis
#
# For server-parsed imagemap files:
#
#AddHandler imap-file map
root@meckk:~#
| |
root@meckk:~# vi /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/yukke
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/yukke/>
Options Includes ExecCGI FollowSymLinks SSI と CGI 許可、ファイル一覧表示禁止
AllowOverride All None → All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
root@meckk:~# ln -s /usr/bin/perl /usr/local/bin/perl
root@meckk:~# /etc/init.d/apache2 restart
| |
apache2 の起動や reload、restart の時に以下の警告?が出てくる。
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
サーバー名が不明だと言う事なのだろうが、どこで設定するのかが分かりませんでした。
たまたまサイトを見ていたら、以下の記載がありました。
ServerName は ServerAdmin とかと一緒に設定されるものだから、てっきり000-defaultで設定するものと思っていたら、どうも apache2.conf に登録しないといけないものらしい。
/etc/apache2/apache2.conf の一番先頭に ServerName hoge.hogedomain.com:80 と記述したらメッセージが消えた。
記述はどこでも良いだろうが、#ServerRoot "/etc/apache2" の下に記述したらメッセージは出なくなった。
気になっていたので、有難い情報でした。
【Tips】
後日、他のハードディスクの、WEB サーバーの修正をやっておりました。
修正を終えて動作させて見ると、CGI が動作しません。
IEだと「Web ページがみつかりません HTTP404エラー」、他のブラウザだと「Forbidden You don't have permission to access /index.cgi on this server.」となります。
default の設定を何度眺めても、Options FollowSymLinks ExecCGI とスペルも間違っている様子はありません。
それじゃあ、mime.conf の AddHandler cgi-script .cgi .pl がコメンとアウトしてあるのだろうと、眺めましたがちゃんと外されております。
じゃあ、設定の2重登録でもしているのではないかぐらいしか思いつきませんでした。
原因は、default にありました。
このハードディスクは、default のファイルを使用しないで、別の名前でファイルを作成して設定をしておりました。
やはり、保管はdefault.ORG とかにして、作成は default を使用した方がミスが少なくなるような気がしました。