我已按照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 /”
答案 0 :(得分:0)
如果您关注最新版Sierra的该文档,那么它将无法帮助您完成任务。因为它也发生在我身上。
这有助于系统访问文件&#34; / Library / WebServer / Documents /&#34; 本身,您不再需要更改文档路径。