LoginSignup
3
3

More than 5 years have passed since last update.

Mac YosemiteのApacheを呼ぶ

Last updated at Posted at 2014-11-06

MacのApacheで昼食前に朝食を

もう疲れちゃってMacに最初から入ってるApacheでいいやって思った。
Yosemiteは2.4系
Mavericksだと2.2系だったかな?
ざっくりと設定ファイルメインに

ここ詳しいからここでいいじゃんっておもう
OS X YosemiteにHomebrew + DropboxでPHP環境構築 〜Apache, PHP, MySQL, ComposerをインストールしてFuelPHPの設定まで - Qiita
http://qiita.com/saltyshiomix/items/aacb5f9635c0d3201174

バージョン確認(今動いてるやつです)

MacMini:~ root# apachectl -V
Server version: Apache/2.4.9 (Unix)
Server built:   Sep  9 2014 14:48:20
Server's Module Magic Number: 20120211:31
Server loaded:  APR 1.4.8, APR-UTIL 1.5.2
Compiled using: APR 1.4.8, APR-UTIL 1.5.2
Architecture:   64-bit
Server MPM:     prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_FLOCK_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=256
 -D HTTPD_ROOT="/usr"
 -D SUEXEC_BIN="/usr/bin/suexec"
 -D DEFAULT_PIDLOG="/private/var/run/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="/private/etc/apache2/mime.types"
 -D SERVER_CONFIG_FILE="/private/etc/apache2/httpd.conf"
MacMini:~ root#

/private/etc/apache2:

ごめんね。見にくいよね
< こっち向きの矢印が新
> こっち向きの矢印が元あった記述

httpd.conf
115,117c115,117
< LoadModule log_debug_module libexec/apache2/mod_log_debug.so
< LoadModule log_forensic_module libexec/apache2/mod_log_forensic.so
< LoadModule logio_module libexec/apache2/mod_logio.so
---
> #LoadModule log_debug_module libexec/apache2/mod_log_debug.so
> #LoadModule log_forensic_module libexec/apache2/mod_log_forensic.so
> #LoadModule logio_module libexec/apache2/mod_logio.so
143c143
< LoadModule ssl_module libexec/apache2/mod_ssl.so
---
> #LoadModule ssl_module libexec/apache2/mod_ssl.so
160,161c160,161
< LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
< #LoadModule negotiation_module libexec/apache2/mod_negotiation.so
---
> #LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
> LoadModule negotiation_module libexec/apache2/mod_negotiation.so
169c169
< LoadModule php5_module libexec/apache2/libphp5.so
---
> #LoadModule php5_module libexec/apache2/libphp5.so
213d212
< ServerName localhost
237,271c236,251
< # DocumentRoot "/Library/WebServer/Documents"
< # <Directory "/Library/WebServer/Documents">
< #     #
< #     # Possible values for the Options directive are "None", "All",
< #     # or any combination of:
< #     #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
< #     #
< #     # Note that "MultiViews" must be named *explicitly* --- "Options All"
< #     # doesn't give it to you.
< #     #
< #     # The Options directive is both complicated and important.  Please see
< #     # http://httpd.apache.org/docs/2.4/mod/core.html#options
< #     # for more information.
< #     #
< #     Options FollowSymLinks Multiviews
< #     MultiviewsMatch Any
< # 
< #     #
< #     # AllowOverride controls what directives may be placed in .htaccess files.
< #     # It can be "All", "None", or any combination of the keywords:
< #     #   AllowOverride FileInfo AuthConfig Limit
< #     #
< #     AllowOverride None
< # 
< #     #
< #     # Controls who can get stuff from this server.
< #     #
< #     Require all granted
< # </Directory>
< DocumentRoot "/var/www"
< <Directory />
<     Options ExecCGI FollowSymLinks Indexes Includes MultiViews
<     AllowOverride All
<     Require all denied
< </Directory>
---
> DocumentRoot "/Library/WebServer/Documents"
> <Directory "/Library/WebServer/Documents">
>     #
>     # Possible values for the Options directive are "None", "All",
>     # or any combination of:
>     #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
>     #
>     # Note that "MultiViews" must be named *explicitly* --- "Options All"
>     # doesn't give it to you.
>     #
>     # The Options directive is both complicated and important.  Please see
>     # http://httpd.apache.org/docs/2.4/mod/core.html#options
>     # for more information.
>     #
>     Options FollowSymLinks Multiviews
>     MultiviewsMatch Any
273,274c253,257
< <Directory "/var/www">
<     Options ExecCGI FollowSymLinks Indexes Includes MultiViews
---
>     #
>     # AllowOverride controls what directives may be placed in .htaccess files.
>     # It can be "All", "None", or any combination of the keywords:
>     #   AllowOverride FileInfo AuthConfig Limit
>     #
275a259,262
> 
>     #
>     # Controls who can get stuff from this server.
>     #
284c271
<     DirectoryIndex index.html index.php
---
>     DirectoryIndex index.html
432,433c419
<     AddHandler cgi-script .cgi
<     AddHandler php5-script .php
---
>     #AddHandler cgi-script .cgi
444,445c430,431
<     AddType text/html .shtml
<     AddOutputFilter INCLUDES .shtml
---
>     #AddType text/html .shtml
>     #AddOutputFilter INCLUDES .shtml
513c499
< Include /private/etc/apache2/extra/httpd-vhosts.conf
---
> #Include /private/etc/apache2/extra/httpd-vhosts.conf
555,558d540
< Redirect 404 /favicon.ico
< <Location /favicon.ico>
<   ErrorDocument 404 "No favicon"
< </Location>

/private/etc/apache2/extra:

vhostsの設定は丸っと消して書いた。
orijinalフォルダに変更前の残ってるし。
test.jquery.dev とかしたかったけど出来なかった(何かが間違ってる)
jquery.dev で繋がったので、それ以上は追いかけてない

httpd-vhosts.conf
Listen 80

<VirtualHost *:80>
    DocumentRoot "/var/www/jquery"
    ServerName jquery.dev
    ServerAlias *.jquery.dev
    Loglevel warn
    SSLEngine off
    ErrorLog "/var/www/logs/jquery/error_log"
    CustomLog "/var/www/logs/jquery/access_log" common
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/var/www/wordpress"
    ServerName wordpress.dev
    ServerAlias *.wordpress.dev
    Loglevel warn
    ErrorLog  "/var/www/logs/wordpress/Error_log"
    CustomLog "/var/www/logs/wordpress/access_log" common
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/var/www/phpmyadmin"
    ServerName phpmyadmin.dev
    ServerAlias *.phpmyadmin.dev
    Loglevel warn
    ErrorLog  "/var/www/logs/phpmyadmin/error_log"
    CustomLog "/var/www/logs/phpmyadmin/access_log" common
    Options none
    <Directory "/var/www/phpmyadmin">
        Options none
        AllowOverride Limit
        Require all denied
        Require ip 127.0.0.1 172.16.0.0/255.240.0.0 192.168
    </Directory>
</VirtualHost>

/private/etc:

hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   MacMini.local localhost.localdomain localhost
127.0.0.1   jquery.dev
127.0.0.1   phpmyadmin.dev
127.0.0.1   wp.dev
255.255.255.255 broadcasthost

/var/www:

ディレクトリは作ります
ログディレクトリも作ります
テスト用なので全部777です
すっとrootで作業してますが、1行目にrootになるおまじないを書いておきますw
要求されるパスワードは起動した時に入れる自分のパスワードです

MacMini:tmp kanekoeiji$ sudo su -
Password:
Sorry, try again.
Password:
Sorry, try again.
Password:
MacMini:~ root# mkdir -p /var/www/jquery/
MacMini:~ root# mkdir -p /var/www/phpmyadmin
MacMini:~ root# mkdir -p /var/www/wordpress
MacMini:~ root# mkdir -p /var/www/logs/jquery/
MacMini:~ root# mkdir -p /var/www/logs/phpmyadmin
MacMini:~ root# mkdir -p /var/www/logs/wordpress
MacMini:~ root# chmod -R 777 /var/www

適当にダミーファイル作ります

html
MacMini:~ root# echo aaa > /var/www/aaa.html
MacMini:~ root# echo '<?php phpinfo();' > /var/www/jquery/phpinfo.php
MacMini:~ root# chmod -R 777 /var/www

起動しまーす

MacMini:~ root# apachectl stop
MacMini:~ root# apachectl start

これでつながるはず
http://localhost/?
http://jquery.dev/?

3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3