指向 index.html 的 Apache 2 虚拟主机

指向 index.html 的 Apache 2 虚拟主机

whitecrm.local我尝试按照以下步骤创建虚拟主机:

  1. 首先我使用创建主机 sudo vim /etc/hosts

    127.0.0.1       localhost
    127.0.0.1       whitecrm.local
    
  2. 在中创建了一个文件sites-available/whitecrm.local

    <VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName whitecrm.local
        DocumentRoot /var/www/whitecrm_local
    
        <Directory />
            Options FollowSymLinks
            AllowOverride All
        </Directory>
    
        <Directory /var/www/whitecrm_local/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
        </Directory>
    
        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    
        <Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
            Order allow,deny
            Allow from all
        </Directory>
    
        ErrorLog ${APACHE_LOG_DIR}/error.log
    
        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn
    
        CustomLog ${APACHE_LOG_DIR}/access.log combined
    
        Alias /doc/ "/usr/share/doc/"
        <Directory "/usr/share/doc/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Allow from 127.0.0.0/255.0.0.0 ::1/128
        </Directory>
    </VirtualHost>
    
  3. 然后重新启动 apache

    sudo /etc/init.d/apache2 restart
    

当我http://whitecrm.local在浏览器中尝试时,它指向index.html来自的文件/var/www,而不是我在中的新文件/var/www/whitecrm_local

我检查了apache2.conf文件,发现其中有一行未被注释:

Include sites-enabled/

这里存在什么问题?我遗漏了什么?

答案1

您不应该只是将内容放入sites-enabled。您应该使用a2ensite来启用 Apache 中的站点配置。

语法是a2ensite [site]

相关内容