为什么a2ensite给我错误“网站不存在”

我最初以为我有这个问题:

https://stackoverflow.com/questions/28572629/a2ensite-site-does-not-exist-error-even-with-conf-file

但是这并没有帮助我。

我在这里cd:

/etc/apache2/sites-enabled 

我知道a2ensite的path:

  which a2ensite /usr/sbin/a2ensite 

我用这个testing了configuration文件:

  apachectl configtest 

我得到:

  Syntax OK 

我有这个文件:

  ralph.stagingv2.example.conf 

开始于:

  ServerName ralph.stagingv2.example.com DocumentRoot "/home/ralph/example/current/web" DirectoryIndex index.php 

我创build了DocumentRoot:

  mkdir -p /home/ralph/example/current/web 

而且我将权限更改为我们在AWS上使用的用户:

  chown -R ubuntu /home/ralph/ chgrp -R www-data /home/ralph/ 

但是当我这样做:

  a2ensite ralph.stagingv2.example 

我得到:

  ERROR: Site ralph.stagingv2.example does not exist! 

我错过了什么?

a2ensite是一个在/etc/apache2/sites-enabled中创build一个sybolic链接的脚本,指向/etc/apache2/sites-available的.config文件。

为了工作,你的.config文件必须在“网站可用”的目录,即

  /etc/apache2/sites-available/ralph.stagingv2.example.conf 

你不应该在/etc/apache2/sites-enabled目录中“放置”任何configuration文件。