OS X 10.8 的 Apache 相關設定
上週升級到 OS X10.8 Mountain Lion 美洲獅(還是山獅好聽),剛才發現本機的網站開不起來、偏好設定→共享裡面原本的「網頁共享」,也就是內建的 Apache 的開關也消失了。
筆記一下我自己的相關設定:
10.8 Server 以外的版本把網頁共享拿掉了,VirtualHost X 的作者做了一個偏好設定面板,可以用來開關 Apache:Web Sharing in OS X Mountain Lion
/etc/apache2下舊的httpd.conf被更名為httpd.conf~previous,需要手動 Merge 一下:新的 Apache 中個人設定挪到 /etc/apache2/users 下的
用戶名.conf(這裡的用戶名就是/Users/下的個人資料夾名稱),檔案權限為644 root:wheel;參考 Options (Apache: The Definitive Guide) 加上Includes(Server-side includes) 跟FollowSymLinks:<Directory "/Users/用戶名/Sites/"> Options Indexes MultiViews Includes FollowSymLinks AllowOverride All Order allow,deny Allow from all Header set Access-Control-Allow-Origin * DirectoryIndex index.html index.php index.shtml </Directory>/etc/apache2/httpd.confServer-side include 跟 VirtualHosts 設定:+ Listen 8080#uncomment following settings: AddType text/html .shtml AddOutputFilter INCLUDES .shtml Include /private/etc/apache2/extra/httpd-vhosts.conf
-
/etc/apache2/extra/httpd-vhosts.confNameVirtualHost *:80 <VirtualHost *:80> DocumentRoot "/Users/Irvin/Sites/" Header set Access-Control-Allow-Origin * </VirtualHost> <VirtualHost *:80> DocumentRoot "/Users/Irvin/Sites/moztw" ServerName moztw DirectoryIndex index.html index.php index.shtml </VirtualHost> <VirtualHost *:8080> DocumentRoot "/Users/Irvin/Sites/moztw" DirectoryIndex index.html index.php index.shtml </VirtualHost>