关于macos:如何从主文件夹中的多个目录运行apache网页?

How to run apache webpage from multiple directories in the home folder?

网站目录结构

1
2
3
4
5
6
7
8
9
10
~/Sites/
   ./subdomain1.site.com/
      ./cgi-bin/
   ./subdomain2.site.com/
      ./cgi-bin/
~/Remote/
   ./subdomain1.remote.com/
      ./cgi-bin/
   ./subdomain2.remote.com/
      ./cgi-bin/

/ private / etc / apache2 / users / <用户名> .httpd:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<Directory ~"/Users/<username>/Remote/.*">
   Options Indexes Includes SymLinksIfOwnerMatch MultiViews
   AllowOverride None
   Order allow,deny
   Allow from all
</Directory>

<Directory ~"/Users/<username>/Remote/.*/cgi-bin">
   AllowOverride None
   Options +ExecCGI
   Order allow,deny
   Allow from all
</Directory>

## Same thing as above, but using"Sites" instead of"Remote"

<Directory ~"/Users/<username>/Sites/.*">
   Options Indexes Includes SymLinksIfOwnerMatch MultiViews
   AllowOverride None
   Order allow,deny
   Allow from all
</Directory>

<Directory ~"/Users/<username>/Sites/.*/cgi-bin">
   AllowOverride None
   Options +ExecCGI
   Order allow,deny
   Allow from all
</Directory>

我将Sites复制到Remote并重新启动了apache(sudo apachectl restart)-也尝试停止,然后开始进行深入研究。

  • 目录包含相同的权限
  • 尽管是同一文件,但index.html会加载Sites目录,但不会加载Remote
  • URL看起来像:http://localhost/~<username>/<directory in Sites or Remote>/index.html
  • httpd.conf中没有任何启用/apache2/users/<username>.httpd配置的内容,它似乎仅适用于Sites/,但不适用于Remote/

在OSX-Mavericks中,默认情况下,httpd.conf包含/extra/httpd-userdir.conf。这是设置"站点"目录的位置。

在您的设置中,编辑https-userdir.conf并添加行UserDir Remote。这应该在您的主文件夹中启用这两个目录。