sites-enabled and sites-available confusion

Hi guys,

How is it I can have a site that appears on site-enabled but doesn't appear in sites-available? Then when I add it to sites-available and try to a2ensite the site, I get an Error which reads: the site is not properly enabled: /etc/apache2/sites-enabled/thewebsite.com is a real file, not touching it.

Apache actually says, "a real file, not touching it".

Not sure what to do.

7 Replies

You might have placed the file in sites-enabled by accident. The best thing I can think of is copy the files from sites-enabled and sites-available elsewhere and disable everything in sites-enabled. After that, make sure that sites-enabled is empty and make sure that the correct files are in sites-available. From there, enable the sites you want and restart apache.

Thanks Piki,

I've got six sites running now which I'd rather not have to disable everything…but if it's as easy as a2ensite to enable them…well, I can do that.

But I'm not clear on how to empty the sites-enabled? Is there a cmd for this?

@mco2669:

Apache actually says, "a real file, not touching it".

I think it wants a link in that directory, not a "real file". Move the file to sites-available and link to it from sites-enabled, then try again.

James

@mco2669:

Thanks Piki,

I've got six sites running now which I'd rather not have to disable everything…but if it's as easy as a2ensite to enable them…well, I can do that.

But I'm not clear on how to empty the sites-enabled? Is there a cmd for this?

I've only seen a2ensite in reference to Debian, so I don't know if Debian has a command to disable sites, but I doubt that would help anyway if the actual files are in sites-enabled.

The first step would to see which files are in sites-enabled, and which are somewhere else and linked to sites-enabled. The first command is: (adjust the directory, I don't know where your sites-enabled and sites-available are)

ls -la /etc/apache/sites-enabled

This will display the file permissions, owner of the files, file size, date, file name, and then where the files are linked to (if any). For the files that do NOT show any links (which will be indicated by an arrow "->" then the file they are linked to), move these files to sites-available (again, adjust for your setup and file names):

mv /etc/apache/sites-enabled/yoursite.com /etc/apache/sites-available

After you do that for all the files that are NOT links, you should be fine and a2ensite should help you re-enable your sites. If you want to be completely certain it's fixed, do:

rm -f /etc/apache/sites-enabled/*

(again, adjust for your setup)

That will remove all the enabled sites, and a2ensite should work to re-enable them. You shouldn't need to do that, but if you want to be completely sure, it wouldn't hurt.

The reason that the files in sites-enabled should link to the files in sites-available is because in most cases, it's pointless to have two copies of the same file, and it's easier to link to the file and have changes take effect as soon as you restart apache rather than having to copy the file every time you need to change it. a2ensite is a script to make it easy to take a file that's already in sites-available and link it to sites-enabled without having to type out the command for creating the link (the command is easy to remember, it can just be a bit lengthy).

Thanks for the explanation Piki. I did what you said and re-enabled them.

Looks to be working fine. Thanks, again.

@Piki:

I've only seen a2ensite in reference to Debian, so I don't know if Debian has a command to disable sites

There is an a2dissite command :)

For modules, there are a2enmod and a2dismod.

Those commands just create symlink from sites/mods-available to sites/mods-enabled (or remove symlink from sites/mods-enabled using a2dissite/mod)

@drpks:

There is an a2dissite command :)

For modules, there are a2enmod and a2dismod.

Those commands just create symlink from sites/mods-available to sites/mods-enabled (or remove symlink from sites/mods-enabled using a2dissite/mod)

Thanks that helped me!

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct