facebook twitter hatena line email

「Mac/インストール/apache」の版間の差分

提供: 初心者エンジニアの簡易メモ
移動: 案内検索
(サブドメインtest例)
 
(同じ利用者による、間の2版が非表示)
行1: 行1:
==インストール==
+
[[Mac/インストール/apache/標準]]
既にインストールされている
+
  
==設定==
+
[[Mac/インストール/apache/brew]]
vi /etc/apache2/httpd.conf
+
 
+
==起動==
+
sudo /usr/sbin/apachectl start
+
 
+
==停止==
+
sudo /usr/sbin/apachectl stop
+
 
+
==http表示==
+
http://localhost/
+
 
+
==デフォルトのドキュメントルート==
+
/Library/WebServer/Documents
+
 
+
==phpを有効にしたい場合==
+
以下のコメントアウトを解除
+
#LoadModule php5_module libexec/apache2/libphp5.so
+
LoadModule php5_module libexec/apache2/libphp5.so
+
 
+
==サブドメインを有効に==
+
コメントを解除
+
$ vi /etc/apache2/httpd.conf
+
#Include /private/etc/apache2/extra/httpd-vhosts.conf
+
Include /private/etc/apache2/extra/httpd-vhosts.conf
+
 
+
コピーしてカスタマイズする
+
$ cp /private/etc/apache2/extra/httpd-vhosts.conf /private/etc/apache2/extra/test.conf
+
$ vi /etc/apache2/httpd.conf
+
Include /private/etc/apache2/extra/test.conf
+
 
+
/etc/apache2/other に追加confファイルを、入れるとhttpd.confに以下Includeがあるので、追加のInclude設定はいらない。
+
Include /private/etc/apache2/other/*.conf
+
 
+
===httpd-vhosts.confの初期文字列===
+
<pre>
+
<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" common
+
</VirtualHost>
+
 
+
<VirtualHost *:80>
+
    ServerAdmin webmaster@dummy-host2.example.com
+
    DocumentRoot "/usr/docs/dummy-host2.example.com"
+
    ServerName dummy-host2.example.com
+
    ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
+
    CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
+
</VirtualHost>
+
</pre>
+
 
+
===サブドメインtest例===
+
test.localhostと、test.example.comでアクセスできるように。
+
<pre>
+
<VirtualHost *:80>
+
    DocumentRoot "/var/www/laravel/test/public"
+
    ServerName test.localhost
+
    ErrorLog "/private/var/log/apache2/test.localhost-error_log"
+
    CustomLog "/private/var/log/apache2/test.localhost-access_log" common
+
    <Directory "/var/www/laravel/test/public">
+
      Options Indexes FollowSymLinks Includes ExecCGI
+
      AllowOverride All
+
      Allow from All
+
    </Directory>
+
</VirtualHost>
+
 
+
<VirtualHost *:80>
+
    DocumentRoot "/var/www/laravel/test/public"
+
    ServerName test.example.com
+
    ErrorLog "/private/var/log/apache2/test.localhost-error_log"
+
    CustomLog "/private/var/log/apache2/test.localhost-access_log" common
+
    <Directory "/var/www/laravel/test/public">
+
      Options Indexes FollowSymLinks Includes ExecCGI
+
      AllowOverride All
+
      Allow from All
+
    </Directory>
+
</VirtualHost>
+
</pre>
+
 
+
==RewriteEngineエラーになるとき==
+
エラー詳細
+
.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
+
 
+
httpd.confのmod_rewriteのコメントアウトを外す。
+
- #LoadModule rewrite_module libexec/apache2/mod_rewrite.so
+
+ LoadModule rewrite_module libexec/apache2/mod_rewrite.so
+
 
+
==client deniedエラーになるとき==
+
エラー詳細
+
AH01630: client denied by server configuration:
+
 
+
許可するdirを追加する
+
<pre>
+
<Directory "/d/www/laravel/test/public">
+
    AllowOverride All
+
    Require all granted
+
</Directory>
+
</pre>
+

2026年4月1日 (水) 15:03時点における最新版

Mac/インストール/apache/標準

Mac/インストール/apache/brew