- 在Finder按花键+shift+G,在出现的对话框中输入/private
- 就可以打开private这个文件夹了
一 httpd.conf的设置
-
1: httpd.conf更改根路径为我们喜欢的路径/private/apache2/httpd.conf
-
-
- #DocumentRoot "/Library/webServer/Documents"
- #<Directory “/Library/webServer/Documents">
- DocumentRoot "/Users/willli/Sites"
- <Directory "/Users/willli/Sites">
-
-
-
2: httpd.conf // 配置允许.htaccess
-
全部 AllowOverride none 改成 AllowOverride all -
3:httpd.conf开启了虚拟端口httpd-vhosts /private/apache2/httpd.conf
-
# Include /private/etc/apache2/extra/httpd-vhosts.conf
-
#LoadModule ssl_module modules/mod_ssl.so
-
#LoadModule rewrite_module modules/mod_rewrite.so
-
LoadModule php7_module libexec/apache2/libphp7.so 或libphp5.so -
#把 Include,#LoadModule 之前的“#”去掉(也就是解除了这一行的注释~)
-
这样我们便开启了虚拟端口。我们刚刚设置好的这样那样
-
ServerSignature On => ServerSignature Off // 配置错误页不显示Apache版本
-
Options Indexes FollowSymLinks => Options FollowSymLinks // 配置Apache不能通过目录层级进行文件访问
-
DirectoryIndex index.html => DirectoryIndex index.html index.php // 配置Apache支持.php文件解析
二 以后每添加一个站点执行以下操作
-
-
1: hosts /private/etc/hosts
-
-
- 127.0.0.1 www.owen.com
-
-
-
2: httpd-vhosts.conf /private/etc/apache2/extra/httpd-vhosts.conf
<VirtualHost *:80> ServerAdmin webmaster@dummy-host2.example.com DocumentRoot "/Users/owenproject/cmit_kaijiang_server/public" ServerName www.owen.com ServerAlias ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log" CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common <Directory "/Users/owenproject/cmit_kaijiang_server/public"> Options FollowSymLinks ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted
-
3: 重启apache
-
sudo apachectl restart
-
Buy me a cup of coffee :)