mac の開発環境構築 〜Apache〜

方針

続いてwebサーバー「Apache」をインストールします。

バージョンの確認

まずはデフォルトのApacheバージョンの確認。

$ apachectl -v
Server version: Apache/2.2.14 (Unix)
Server built:   Dec  9 2009 19:21:30

portsの確認

次にMacPortsでインストールできるApacheバージョンの確認

$ port search apache
・・・
apache @1.3.41 (www)
    The extremely popular Apache http server
・・・
apache2 @2.2.16 (www)
    The extremely popular second version of the Apache http server

apache20 @2.0.63 (www)
    The extremely popular second version of the Apache http server
・・・

最新バージョンのApache2.2.16をインストールしたいので、インストールコマンドは「apache2」を指定します。

Apacheインストール

それではMacPortsでインストール

$ sudo port install apache2

apache2をload

インストールの最後に表示された自動起動コマンドを叩いておきます。

$ sudo port load apache2

ユーザーディレクトリの設定

設定ファイルを編集して、ユーザーディレクトリを有効にします。

$ sudo vi /opt/local/apache2/conf/httpd.conf
Password:

# 一番下の方にあります
# User home directories
Include conf/extra/httpd-userdir.conf

自動起動されているかも確認したいのでPCを再起動

バージョン確認

$ /opt/local/apache2/bin/apachectl -v
Server version: Apache/2.2.16 (Unix)
Server built:   Oct 26 2010 15:07:16

プロセス確認

コマンドラインからapacheのプロセスが動いていることを確認。

$ ps aux | grep apache2
_www       183   0.0  0.0  2442056    592   ??  S     4:08PM   0:00.00 /opt/local/apache2/bin/httpd -k start
_www        83   0.0  0.0  2442056    592   ??  S     4:08PM   0:00.00 /opt/local/apache2/bin/httpd -k start
_www        82   0.0  0.0  2442056    592   ??  S     4:08PM   0:00.00 /opt/local/apache2/bin/httpd -k start
_www        81   0.0  0.0  2442056    592   ??  S     4:08PM   0:00.00 /opt/local/apache2/bin/httpd -k start
_www        80   0.0  0.0  2442056   1488   ??  S     4:08PM   0:00.00 /opt/local/apache2/bin/httpd -k start
_www        79   0.0  0.0  2442056   1464   ??  S     4:08PM   0:00.00 /opt/local/apache2/bin/httpd -k start
root        74   0.0  0.1  2442056   2436   ??  Ss    4:08PM   0:00.09 /opt/local/apache2/bin/httpd -k start
root        55   0.0  0.0  2446752   1020   ??  Ss    4:07PM   0:00.01 /opt/local/bin/daemondo --label=apache2 --start-cmd /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart ; --pid=none

ブラウザで表示確認

最後にブラウザでの表示確認。

「http://localhost/」に接続して『It works!』と表示されることを確認。

「http://localhost/~username/」に接続して『あなたの Web サイト。』と表示されることを確認。

apacheの起動・停止コマンド

$ sudo /opt/local/apache2/bin/apachectl start
$ sudo /opt/local/apache2/bin/apachectl stop

インストールログ

$ sudo port install apache2
Password:
--->  Computing dependencies for apache2
--->  Dependencies to be installed: pcre bzip2
--->  Fetching bzip2
--->  Attempting to fetch bzip2-1.0.6.tar.gz from http://distfiles.macports.org/bzip2
--->  Verifying checksum(s) for bzip2
--->  Extracting bzip2
--->  Applying patches to bzip2
--->  Configuring bzip2
--->  Building bzip2
--->  Staging bzip2 into destroot
--->  Installing bzip2 @1.0.6_0
--->  Activating bzip2 @1.0.6_0
--->  Cleaning bzip2
--->  Fetching pcre
--->  Attempting to fetch pcre-8.10.tar.bz2 from http://jaist.dl.sourceforge.net/pcre
--->  Verifying checksum(s) for pcre
--->  Extracting pcre
--->  Configuring pcre
--->  Building pcre
--->  Staging pcre into destroot
--->  Installing pcre @8.10_0
--->  Activating pcre @8.10_0
--->  Cleaning pcre
--->  Fetching apache2
--->  Attempting to fetch httpd-2.2.16.tar.bz2 from ftp://ftp.infoscience.co.jp/pub/net/apache/dist/httpd
--->  Attempting to fetch httpd-2.2.16.tar.bz2 from http://distfiles.macports.org/apache2
--->  Verifying checksum(s) for apache2
--->  Extracting apache2
--->  Applying patches to apache2
--->  Configuring apache2
--->  Building apache2
--->  Staging apache2 into destroot
--->  Creating launchd control script
###########################################################
# A startup item has been generated that will aid in
# starting apache2 with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo port load apache2
###########################################################
Note: apache2 installs files outside the common directory structure.
--->  Installing apache2 @2.2.16_0+preforkmpm
--->  Activating apache2 @2.2.16_0+preforkmpm
--->  Cleaning apache2

投稿日:

ページのトップへ戻る