- 在Finder按花键+shift+G,在出现的对话框中输入/private
- 就可以打开private这个文件夹了
一 httpd.conf的设置
- 1: httpd.conf更改根路径为我们喜欢的路径/private/apache2/httpd.conf
- #DocumentRoot "/Library/webServer/Documents"
- #
- DocumentRoot "/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
ServerAdmin webmaster@dummy-host2.example.comDocumentRoot "/Users/owenproject/cmit_kaijiang_server/public" ServerName www.owen.comServerAlias ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log" CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common Options FollowSymLinks ExecCGI AllowOverride All Order allow,deny Allow from all Require all granted - 3: 重启apache
- sudo apachectl restart