Site does not exist error for a2ensite

后端 未结 10 1776
心在旅途
心在旅途 2020-12-12 10:04

I have cmsplus.dev under /etc/apache2/sites-available with the following code,


    ServerAdmin master@serv         


        
相关标签:
10条回答
  • 2020-12-12 10:12

    Try like this..

    NameVirtualHost *:80
    <VirtualHost *:80>
        ServerAdmin master@server.com
        ServerName www.cmsplus.dev
        ServerAlias cmsplus.dev
    
        DocumentRoot /var/www/cmsplus.dev/public
    
        LogLevel warn
        ErrorLog /var/www/cmsplus.dev/log/error.log
        CustomLog /var/www/cmsplus.dev/log/access.log combined
    </VirtualHost>
    

    and add entry in /etc/hosts

    127.0.0.1 www.cmsplus.dev
    

    restart apache..

    0 讨论(0)
  • 2020-12-12 10:14

    I realise that's not the case here but it might help someone.

    Double-check you didn't create the conf file in /etc/apache2/sites-enabled by mistake. You get the same error.

    0 讨论(0)
  • 2020-12-12 10:16

    Solved the issue by adding .conf extension to site configuration files.

    Apache a2ensite results in:

    Error! Site Does Not Exist

    Problem; If you found the error while trying to enable a site using:

    sudo a2ensite example.com
    

    but it returns:

    Error: example.com does not exist

    a2ensite is simply a Perl script that only works with filenames ending .conf

    Therefore, I have to rename my setting file for example.com to example.com.conf as might be achieved as follows:

    mv /etc/apache2/sites-available/example.com /etc/apache2/sites-available/example.com.conf
    

    Success

    0 讨论(0)
  • 2020-12-12 10:19

    You probably updated your Ubuntu installation and one of the updates included the upgrade of Apache to version 2.4.x

    In Apache 2.4.x the vhost configuration files, located in the /etc/apache2/sites-available directory, must have the .conf extension.

    Using terminal (mv command), rename all your existing configuration files and add the .conf extension to all of them.

    mv /etc/apache2/sites-available/cmsplus.dev /etc/apache2/sites-available/cmsplus.dev.conf
    

    If you get a "Permission denied" error, then add "sudo " in front of your terminal commands.

    You do not need to make any other changes to the configuration files.

    Enable the vhost(s):

    a2ensite cmsplus.dev.conf
    

    And then reload Apache:

    service apache2 reload
    

    Your sites should be up and running now.


    UPDATE: As mentioned here, a Linux distribution that you installed changed the configuration to Include *.conf only. Therefore it has nothing to do with Apache 2.2 or 2.4

    0 讨论(0)
  • 2020-12-12 10:19

    In my case with Ubuntu 14.04.3 and Apache 2.4.7, the problem was that I copied site1.conf to make site2.conf available, and by copying, something happend and I could not a2ensite site2.conf with the error described in thread.

    The solution for me, was to rename site2.conf to site2 and then again rename site2 to site2.conf. After that I was able to a2ensite site2.conf.

    0 讨论(0)
  • 2020-12-12 10:26

    I have just upgraded the Ubuntu Server version from 12.04 LTS to 14.04 LTS.

    Indeed, as said above, the .conf extension to Apache 2.4.x is needed to the websites vhost files that resides on sites-available directory.

    Before read this question I did not have a clue what was going on with the server.

    Pretty nice solution.

    Just summarizing I did the following steps on Terminal:

    1) Access sites-enabled folder

    $ cd /etc/apache2/sites-enabled
    

    2) Because the command a2dissite will not work with deprecated files (without .conf) remove the old website files that was published

    $ sudo rm <my-old-website-without-.conf>
    

    3) Rename the website vhost files changing its extension adding .conf to the end

    $ sudo mv /etc/apache2/sites-available/mywebsite /etc/apache2/sites-available/mywebsite.conf
    

    4) Republish the new and correct vhost file

    $ sudo a2ensite mywebsite.conf
    

    5) Check the website on browser and have fun! :)

    0 讨论(0)
提交回复
热议问题