Skip to content

Instantly share code, notes, and snippets.

@satomixx
Created January 21, 2014 06:53
Show Gist options
  • Save satomixx/8535509 to your computer and use it in GitHub Desktop.
Save satomixx/8535509 to your computer and use it in GitHub Desktop.
Mac OSX Mavericks(10.9)にFuelPHPを導入する方法 と Web共有設定をターミナルからする方法 と ドキュメントルートの変更 ref: http://qiita.com/mugyuu/items/2c467b85e7f5730478ab
hoge% http -v
Server version: Apache/2.2.24 (Unix)
Server built: Aug 24 2013 21:10:43
hoge% sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
Password:
hoge% php -v [/etc/apache2/users
PHP 5.4.17 (cli) (built: Aug 25 2013 02:03:38)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
hoge% sudo vim /etc/apache2/httpd.conf
-#LoadModule php5_module libexec/apache2/libphp5.so
+LoadModule php5_module libexec/apache2/libphp5.so
hoge% sudo cp /etc/php.ini.default /etc/php.ini
hoge% sudo chmod 644 /etc/php.ini
hoge% sudo vim /etc/php.ini
; http://php.net/date.timezone
→date.timezone ="Asia/Tokyo"
$ vim ~workspace/fuga/test.php
---
<?php
phpinfo();
?>
---
$ curl get.fuelphp.com/oil | sh
$ cd ~/workspace/fuga/nemu
$ oil create blog
---
FuelPHPの目標の画面を http://localhost/ で出すには、DocumentRootを、oil create した作業用ディレクトリの下のpublicディレクトリに設定します。
これで見れるようになります。
http://localhost/
![fuelPHP.png](https://qiita-image-store.s3.amazonaws.com/0/18705/e18aef2b-b1d1-c573-7804-9f35667ba03a.png)
また、 http://localhost/~{username} は、変わらず見れます。
hoge% sudo apachectl configtest
Syntax OK
hoge% sudo apachectl graceful
(△ sudo apachectl restart)
hoge% sudo vim /etc/apache2/users/{username}.conf
----
<Directory "/Users/{username}/Sites"> #DocumentRootの指定をします。通常だとこちらです。
#<Directory "/Users/{username}/workspace/fuga"> #DocumentRootは変更できます。
AllowOverride All
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec ExecCGI
AddHandler cgi-script .cgi
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
# ここも設定します
#AllowOverride None
→AllowOverride All
----
hoge% sudo cp /etc/apache2/httpd.conf /etc/apache2/httpd.conf.yymmdd
hoge% sudo vim /etc/apache2/httpd.conf
# Virtual hosts
-#Include /private/etc/apache2/extra/httpd-vhosts.conf
+Include /private/etc/apache2/extra/httpd-vhosts.conf
#.htaccessの有効化
#AllowOverride None
→AllowOverride All
hoge% sudo vim /etc/apache2/extra/httpd-vhosts.conf
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#<VirtualHost *:80>
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot "/usr/docs/dummy-host.example.com"
# ServerName dummy-host.example.com
# ServerAlias www.dummy-host.example.com
# ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
# CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" comm
#</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
ServerName localhost
#ServerAlias www.dummy-host.example.com
ErrorLog "/private/var/log/apache2/error.log"
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog "/private/var/log/apache2/access.log" combined
# DocumentRoot "/Users/{username}/workspace/fuga/public/" #ここでDocumentRootを変更できます
DocumentRoot "/Users/{username}/Sites" #通常の設定にしたい場合はこちら。 /Users/{username}/Sites/public_html の方が一般的かも。
<Directory "/">
AllowOverride All
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec ExecCGI
AddHandler cgi-script .cgi
<Limit GET POST OPTIONS PROPFIND>
Order allow,deny
Allow from all
</Limit>
<LimitExcept GET POST OPTIONS PROPFIND>
Order deny,allow
Deny from all
</LimitExcept>
</Directory>
</VirtualHost>
hoge% sudo apachectl configtest [/etc/apache2/users]
Warning: DocumentRoot [/Users/hoge/Sites/] does not exist
httpd: apr_sockaddr_info_get() failed for hoge-no-macbookAir
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Syntax OK
hoge% mkdir -p ~/Sites
hoge% echo Now Web Sharing! > ~/Sites/index.html
hoge% sudo apachectl restart
$sudo vi /etc/apache2/httpd.conf
---
# 2箇所あります
#DocumentRoot "/Library/WebServer/Documents"
→ DocumentRoot "Users/{username}/workspace/fuga"
#<Directory "/Library/WebServer/Documents">
→ <Directory "Users/{username}/workspace/fuga">
hoge% sudo vim /etc/apache2/extra/httpd-vhosts.conf
hoge% sudo vim /etc/apache2/users/{username}.conf
#両ファイルとも以下の Users/{username}/workspace/fuga 部分を指定したいパスに変更します
----
<Directory "/Users/{username}/workspace/fuga">
Options ・・・・
Allow ・・・・
</Directory>
----
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment