「Mac/インストール/apache」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→ドキュメントルート) |
(→サブドメインを有効に) |
||
| 行32: | 行32: | ||
$ vi /etc/apache2/httpd.conf | $ vi /etc/apache2/httpd.conf | ||
Include /private/etc/apache2/extra/test.conf | Include /private/etc/apache2/extra/test.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> | ||
2026年4月1日 (水) 13:36時点における版
目次
インストール
既にインストールされている
設定
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
httpd-vhosts.confの初期文字列
<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>
