Site does not exist error for a2ensite

后端 未结 10 1777
心在旅途
心在旅途 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:30

    Worked after I added .conf to the configuration file

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

    I just had the same problem. I'd say it has nothing to do with the apache.conf.

    a2ensite must have changed - line 532 is the line that enforces the .conf suffix:

    else {
        $dir    = 'sites';
        $sffx   = '.conf';
        $reload = 'reload';
    }
    

    If you change it to:

    else {
        $dir    = 'sites';
        #$sffx   = '.conf';
        $sffx   = '';
        $reload = 'reload';
    }
    

    ...it will work without any suffix.

    Of course you wouldn't want to change the a2ensite script, but changing the conf file's suffix is the correct way.

    It's probably just a way of enforcing the ".conf"-suffix.

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

    There's another good way, just edit the file apache2.conf theres a line at the end

    IncludeOptional sites-enabled/*.conf

    just remove the .conf at the end, like this

    IncludeOptional sites-enabled/*

    and restart the server.

    (I tried this only in the Ubuntu 13.10, when I updated it.)

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

    So .. quickest way is rename site config names ending in ".conf"

    mv /etc/apache2/sites-available/mysite /etc/apache2/sites-available/mysite.conf
    
    a2ensite mysite.conf
    

    other notes on previous comments:

    • IncludeOptional wasn't introduced until apache 2.36 - making change above followed by restart on 2.2 will leave your server down!

    • also, version 2.2 a2ensite can't be hacked as described

    as well, since your sites-available file is actually a configuration file, it should be named that way anyway..


    In general do not restart services (webservers are one type of service):

    • folks can't find them if they are not running! Think linux not MS Windows..

    Servers can run for many years - live update, reload config, etc.

    The cloud doesn't mean you have to restart to load a configuration file.

    • When changing configuration of a service use "reload" not "restart".

    • restart stops the service then starts service - if there is a any problem in your change to the config, the service will not restart.

    • reload will give an error but the service never shuts down giving you a chance to fix the config error which could only be bad syntax.

    debian or ubunto [service-name for this thread is apache2]

    service {service-name} {start} {stop} {reload} ..
    

    other os's left as an excersize for the reader.

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