はじめに
OS X yosemite では、すでにApache2.4がインストールされています。
1 からのWeb開発環境の構築をしたいので、今回は、インストール済みのApacheはそのままとして、HomebrewでApache2.2をインストールする手順でApacheの環境構築をして行きます。
では、早速実施していきましょう。
Apacheの確認
$ httpd -v Server version: Apache/2.4.10 (Unix) Server built: May 19 2015 09:36:36 $ which httpd /usr/sbin/httpd
$ apachectl -v Server version: Apache/2.4.10 (Unix) Server built: May 19 2015 09:36:36 $ which apachectl /usr/sbin/apachectl
Apacheの確認
$ brew search httpd darkhttpd libmicrohttpd lighttpd mighttpd2 homebrew/devel-only/httpd22 homebrew/emacs/simple-httpd homebrew/devel-only/httpd24 homebrew/head-only/httpdiff
リポジトリの追加
$ brew tap homebrew/dupes $ brew tap homebrew/apache
Apacheのインストール
$ brew install httpd22
Apacheのインストール確認
$ httpd -v Server version: Apache/2.4.10 (Unix) Server built: May 19 2015 09:36:36 $ which httpd /usr/local/bin/httpd
$ apachectl -v Server version: Apache/2.4.10 (Unix) Server built: May 19 2015 09:36:36 $ which apachectl /usr/local/bin/apachectl
Apache2.2 httpd-conf-の設定
$ sudo vi /usr/local/etc/apache2/2.2/httpd.conf #LoadModule php5_module libexec/apache2/libphp5.so ↓ LoadModule php5_module libexec/apache2/libphp5.so
Apache2.4 httpd-conf-の設定
$ vi /usr/local/etc/apache2/2.2/httpd.confServerNameの設定
#ServerName www.example.com:8080 ↓ ServerName localhost:8080DocumentRootの設定
#DocumentRoot "/usr/local/var/www/htdocs" #.htaccessの制御↓ DocumentRoot "/Users/ユーザ名/work/MyWebTest"
#AllowOverride None ↓ AllowOverride AllPHPの有効設定
バーチャルホストの設定#DirectoryIndex index.html ↓ DirectoryIndex index.php index.html
# Virtual hosts #Include /usr/local/etc/apache2/2.2/extra/httpd-vhosts.conf ↓ Include /usr/local/etc/apache2/2.2/extra/httpd-vhosts.conf
Apacheの 再起動
$ apachectl restart
Apacheの削除
$ brew remove httpd24 rm -rf /usr/local/etc/apache2/2.2 rm -rf /usr/local/var/log/apache2
Apacheの自動起動
$ sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
バーチャルホストファイルの設定
$DocumentRoot "/Users/ユーザ名/work/MyWebTest" ServerName mywebtest.localhost ErrorLog "/Users/ユーザ名/work/MyWebTest/log/error_log" CustomLog "/Users/ユーザ名/work/MyWebTest/log/access_log" common Options Indexes FollowSymLinks AllowOverride All Allow from all
ホストファイルの設定
$ sudo vi /etc/hosts 127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost 127.0.0.1 mywebtest.localhost




