更改文档路径Apache Mac Sierra

时间:2017-04-22 17:58:25

标签: macos apache

我已按照https://medium.com/@JohnFoderaro/how-to-set-up-apache-in-macos-sierra-10-12-bca5a5dfffba#.scwat9ihp的所有步骤启动了我的网络服务器。需要帮助

运行apachectl -S

VirtualHost configuration:
ServerRoot: "/usr/local/opt/httpd24"
Main DocumentRoot: "/usr/local/var/www/htdocs/"
Main ErrorLog: "/usr/local/var/log/apache2/error_log"
Mutex default: dir="/usr/local/var/run/apache2/" mechanism=default 
Mutex mpm-accept: using_defaults
PidFile: "/usr/local/var/run/apache2/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="daemon" id=1 not_used
Group: name="daemon" id=1 not_used

我更改了/etc/apache2/httpd.conf

#ServerName www.example.com:80
ServerName localhost
DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">

DocumentRoot "Users/{{username}}/Sites/"
<Directory "Users/{{username}}/Sites/">

我添加了私有/ etc / apache2 / extra / httpd-vhosts.conf

#Virtual Host Entry for foo.localhost
<VirtualHost *:80>
  DocumentRoot "/Users/{{username}}/Sites/foo"
  ServerName foo.localhost
  ErrorLog "/private/var/log/apache2/foo-error_log"
  CustomLog "/private/var/log/apache2/foo-access_log" common </VirtualHost>
#Virtual Host Entry for bar.localhost
<VirtualHost *:80>
  DocumentRoot "/Users/{{username}}/Sites/bar"
  ServerName bar.localhost
  ErrorLog "/private/var/log/apache2/bar-error_log"
  CustomLog "/private/var/log/apache2/bar-access_log" common 
</VirtualHost>

但apache似乎在'/ usr / local / var / www / htdocs /'上运行index.html文件而不是“Users / {{username}} / Sites /”

1 个答案:

答案 0 :(得分:0)

如果您关注最新版Sierra的该文档,那么它将无法帮助您完成任务。因为它也发生在我身上。

  • 还原以下两个步骤, /etc/apache2/httpd.conf 我已添加私有/ etc / apache2 / extra / httpd-vhosts.conf
  • 只需转到 httpd.conf 文件,然后找到以下行选项FollowSymLinks Multiviews 。如果退出,则只需在之后添加索引 >选项FollowSymLinks Multiviews 并重新启动服务器

这有助于系统访问文件&#34; / Library / WebServer / Documents /&#34; 本身,您不再需要更改文档路径。