Fedoraではyumで、openSUSE 10、11ではyastでインストールすることができる。
Apacheのソースファイルなどは、各ミラーサイトから入手できる。
ubuntuの場合は、下記のようにapt-get install apache2と打ってインストールする。
$ sudo 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 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap Suggested packages: apache2-doc apache2-suexec apache2-suexec-custom The following NEW packages will be installed: apache2 apache2-mpm-worker apache2-utils apache2.2-bin apache2.2-common libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap 0 upgraded, 8 newly installed, 0 to remove and 108 not upgraded. Need to get 3,224 kB of archives. After this operation, 11.7 MB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://us.archive.ubuntu.com/ubuntu/ natty/main libaprutil1 amd64 1.3.9+dfsg-5ubuntu3 [75.1 kB] Get:2 http://us.archive.ubuntu.com/ubuntu/ natty/main libaprutil1-dbd-sqlite3 amd64 1.3.9+dfsg-5ubuntu3 [12.2 kB] Get:3 http://us.archive.ubuntu.com/ubuntu/ natty/main libaprutil1-ldap amd64 1.3.9+dfsg-5ubuntu3 [9,632 B] Get:4 http://us.archive.ubuntu.com/ubuntu/ natty/main apache2.2-bin amd64 2.2.17-1ubuntu1 [2,811 kB] Get:5 http://us.archive.ubuntu.com/ubuntu/ natty/main apache2-utils amd64 2.2.17-1ubuntu1 [85.5 kB] Get:6 http://us.archive.ubuntu.com/ubuntu/ natty/main apache2.2-common amd64 2.2.17-1ubuntu1 [227 kB] Get:7 http://us.archive.ubuntu.com/ubuntu/ natty/main apache2-mpm-worker amd64 2.2.17-1ubuntu1 [2,328 B] Get:8 http://us.archive.ubuntu.com/ubuntu/ natty/main apache2 amd64 2.2.17-1ubuntu1 [1,474 B] Fetched 3,224 kB in 2min 50s (18.9 kB/s) Selecting previously deselected package libaprutil1. (Reading database ... 134749 files and directories currently installed.) Unpacking libaprutil1 (from .../libaprutil1_1.3.9+dfsg-5ubuntu3_amd64.deb) ... Selecting previously deselected package libaprutil1-dbd-sqlite3. Unpacking libaprutil1-dbd-sqlite3 (from .../libaprutil1-dbd-sqlite3_1.3.9+dfsg-5ubuntu3_amd64.deb) ... Selecting previously deselected package libaprutil1-ldap. Unpacking libaprutil1-ldap (from .../libaprutil1-ldap_1.3.9+dfsg-5ubuntu3_amd64.deb) ... Selecting previously deselected package apache2.2-bin. Unpacking apache2.2-bin (from .../apache2.2-bin_2.2.17-1ubuntu1_amd64.deb) ... Selecting previously deselected package apache2-utils. Unpacking apache2-utils (from .../apache2-utils_2.2.17-1ubuntu1_amd64.deb) ... Selecting previously deselected package apache2.2-common. Unpacking apache2.2-common (from .../apache2.2-common_2.2.17-1ubuntu1_amd64.deb) ... Selecting previously deselected package apache2-mpm-worker. Unpacking apache2-mpm-worker (from .../apache2-mpm-worker_2.2.17-1ubuntu1_amd64.deb) ... Selecting previously deselected package apache2. Unpacking apache2 (from .../apache2_2.2.17-1ubuntu1_amd64.deb) ... Processing triggers for man-db ... Processing triggers for ufw ... Processing triggers for ureadahead ... Setting up libaprutil1 (1.3.9+dfsg-5ubuntu3) ... Setting up libaprutil1-dbd-sqlite3 (1.3.9+dfsg-5ubuntu3) ... Setting up libaprutil1-ldap (1.3.9+dfsg-5ubuntu3) ... Setting up apache2.2-bin (2.2.17-1ubuntu1) ... Setting up apache2-utils (2.2.17-1ubuntu1) ... Setting up apache2.2-common (2.2.17-1ubuntu1) ... 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.17-1ubuntu1) ... * Starting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName ...done. Setting up apache2 (2.2.17-1ubuntu1) ... Processing triggers for libc-bin ... ldconfig deferred processing now taking place
起動
apachectl start FC4、FC5、OSXの場合
apache2ctl start openSUSE 10.0、ubuntuの場合
停止
apachectl stop
再起動(gracefulは、現在つながっている接続がすべて、切れるのを待って再起動をかける)
apachectl restart
apachectl graceful
その他、設定ファイルの確認を以下のオプションですることができる。
apachectl configtest
パソコン起動時に自動起動するようにするには
FC4、FC5では、
# chkconfig httpd on
# chkconfig httpd off
openSUSE 10、11では
# chkconfig apache2 on
# chkconfig apache2 off
ubuntuの場合は、
$ sudo sysv-rc-conf
と打って対話的に設定する。
バージョンはOSXの場合、
# apachectl -v
Server version: Apache/2.2.26 (Unix)
Server built: Dec 10 2013 22:09:38
で調べることができる。
CentOSなどではSELinuxがデフォルトで有効となっており、この場合、
Starting httpd: Warning: DocumentRoot [/var/www/whatever] does not exist
の様な警告が出て、起動しない。ログ(/var/log/httpd/error_log)を見ると、
[Tue Sep 02 01:43:37 2014] [notice] SELinux policy enabled; httpd running
as context system_u:system_r:httpd_t:s0
[Tue Sep 02 01:43:37 2014] [notice] suEXEC mechanism enabled (wrapper:
/usr/sbin/suexec)
の様なエラーが記録される。
このような場合は、こちらにあるように、SELinuxを所定の手順で切ってやれば良い。
一部のディストリビューションでは、初期のファイアウォールの設定は、80ポートはふさがれている。
外部から接続するためには、80番ポートをあけるか、ファイアウォールを切る。
最終更新日