在MojaveOS + Apache2上配置VirtualHosts

时间:2019-05-10 21:18:41

标签: apache apache2 apache2.4 macos-mojave

在我的apache配置中,我看起来有些奇怪的比赛情况。

我已经编辑了httpd.conf文件以包含/extra/httpd-vhosts.conf文件,并且其中包含两个VirtualHost,用于我计划创建的两个本地WordPress安装。

我想访问local01-site1.co.uk上的本地站点,而另一个访问local01-site2.com上的本地站点(前缀是我的命名约定,以避免混淆)。

问题是,两个虚拟主机都不起作用,我禁止使用403,但是如果仅在浏览器中尝试本地主机,则会安装/Sites/site1.co.uk文件夹并显示WordPress安装程序。

我正在绞尽脑汁,似乎找不到一个奇怪的冲突……我不想发布整个httpd.conf文件,但是如果需要的话,我可以这样做。

这是http-vhosts.conf文件;

<VirtualHost *:80>
  ServerName local01-site1.co.uk
  ServerAdmin webmaster@example.com
  DocumentRoot /Sites/site1.co.uk
  <Directory "/Sites/site1.co.uk">
    AllowOverride All
    Options Indexes MultiViews
    Require all granted
  </Directory>
  ErrorLog /tmp/error.log
  CustomLog /tmp/access.log combined
</VirtualHost>

<VirtualHost *:80>
  ServerName local01-site2.com
  ServerAdmin webmaster@example.com
  DocumentRoot /Sites/site2.com
  <Directory "/Sites/site2.com">
    AllowOverride All
    Options Indexes MultiViews
    Require all granted
  </Directory>
  ErrorLog /tmp/error.log
  CustomLog /tmp/access.log combined
</VirtualHost>

如果我运行apachectl -S,我会得到

    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
VirtualHost configuration:
*:80                   is a NameVirtualHost
        default server local01-site1.co.uk (/private/etc/apache2/extra/httpd-vhosts.conf:1)
        port 80 namevhost local01-site1.co.uk (/private/etc/apache2/extra/httpd-vhosts.conf:1)
        port 80 namevhost local01-site2.com (/private/etc/apache2/extra/httpd-vhosts.conf:14)
ServerRoot: "/usr"
Main DocumentRoot: "/Library/WebServer/Documents"
Main ErrorLog: "/private/var/log/apache2/error_log"
Mutex default: dir="/private/var/run/" mechanism=default 
Mutex mpm-accept: using_defaults
Mutex rewrite-map: using_defaults
PidFile: "/private/var/run/httpd.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="_www" id=70 not_used
Group: name="_www" id=70 not_used

非常欢迎任何帮助!

0 个答案:

没有答案