## 20180604 在新的 macbook 上,重設虛擬目錄php
一、直接採用系統缺省的 localhost,目錄位置:apache
DocumentRoot "/Library/WebServer/Documents"vim
<Directory "/Library/WebServer/Documents">安全
二、http://localhost/ 會顯示如下提示 (我但願列舉全部文件和目錄)服務器
You don't have permission to access / on this serverphp7
三、爲了本身調試方便,打開目錄全部權限,直接修改 httpd.confantd
找到以上 DocumentRoot 位置,加上如下設置app
# by wzh 20180604 none ->allide
Options All測試
AllowOverride All
Allow from all
** 爲了保險起見,我也修改了 <Directory /> ,並無測試是否須要
<Directory />
# AllowOverride none
# by wzh 20180604 allow list
allow from all
AllowOverride All
# Require all denied
Require all granted
</Directory>
四、重啓 apachect,再次打開 http://localhost/,全部目錄和文件都列舉出來了!ok
## 20170113 從新修改 虛擬主機
一、由於升級 到 sierra,apachect 配置又還原到 default 了
二、以前的 3 個重要文件
** /etc/apache2 目錄下
httpd.conf 更名到 httpd.conf~previous
** /etc/apache2/extra 目錄下
httpd-vhosts.conf 更名到 httpd-vhosts.conf~previous
** /etc 目錄下
hosts 沒有改變
三、按照 previous 修改 httpd.conf
** 不知道其餘地方有無變化,直接cp 回來不安全
** sudo vim httpd.conf ,必定要 sudo
四、設置 php 7 ,缺省 仍是 php 5
## by wzh 20161021 5.6 for default 5.5
#LoadModule php5_module libexec/apache2/libphp5.so
## by wzh 20170113 php7
LoadModule php7_module /usr/local/opt/php70/libexec/apache2/libphp7.so
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
## add end
五、設置 虛擬主機
# Virtual hosts
# httpd.conf# 127.0.0.1和localhost不同,去掉下面這行的by wzh 20170113
Include /private/etc/apache2/extra/httpd-vhosts.conf
六、設置虛擬服務器權限
ServerAdmin you@example.com
<Directory />
AllowOverride none
#by wzh 20170113 grantd 代替 denied
Require all granted
</Directory>
七、直接替換回來 httpd-vhosts.conf ** 虛擬目錄都是我設置的,覆蓋回來不會影響 cp httpd-vhosts.conf httpd-vhosts.conf。20170113 cp httpd-vhosts.conf~previous httpd-vhosts.conf 八、 重啓 apachect sudo apachectl restart 九、另外得知: MAMP FOR MAC 上建立虛擬主機很是 easy ,之後再說