LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (https://www.linuxquestions.org/questions/debian-26/)
-   -   apache2 on debian, DocumentRoot confusion (https://www.linuxquestions.org/questions/debian-26/apache2-on-debian-documentroot-confusion-535728/)

andrews-mark 03-08-2007 12:03 PM

apache2 on debian, DocumentRoot confusion
 
I'm running debian sarge. I recently moved to using apache2 from the old apache. I apt installed apache2 from dotdeb.org repositories.

As I understand it, to set DocumentRoot the file /etc/apache2/sites-available/default must be edited.

The first time I set the document root, everything was fine.

I subsequently decided to change the root location from e.g. /home/andrews/oldroot to /home/andrews/newroot

Easy, I thought. Edited /etc/apache2/sites-available/default to point to newroot, deleted oldroot, and tried to restart apache2 using
Code:

apache2ctl restart
trouble followed

Code:

centurian> apache2ctl restart
Syntax error on line 1 of /etc/apache2/conf.d/testdefault:
DocumentRoot must be a directory


the offending file, had one line

Code:

centurian> cat /etc/apache2/conf.d/testdefault
DocumentRoot /home/andrews/oldroot/


Now, if I recreate an empty dir at /home/andrews/oldroot/, or if I did not delete it in the first place, the apache2ctl restart works fine, and my DocumentRoot for apache2 is the correct newroot dir. The file /etc/apache2/conf.d/testdefault still lists oldroot as DocumentRoot, however.

I am confused. Should I be editing /etc/apache2/conf.d/testdefault also to reflect the change in /etc/apache2/sites-available/default? That doesn't seem right. Presumably, the change is made once and then on restart it rewrites the other files.

The problem is not major, as I can easily get around it by having an empty dir called oldroot hanging around. However, I would guess I am missing something here.

thanks,
Mark

Dutch Master 03-09-2007 09:14 PM

No, you should leave the default file just that: default values. Create a new file, in the sites-available folder, containing your new document-root. Then create a sym-link from the sites-enabled folder to your new file.

andrews-mark 03-10-2007 05:17 AM

thank you Dutch Master,

I did as instructed. I reverted the file /etc/apache2/sites-available/default back to what it was originally, and created a new file in etc/apache2/sites-available/ and created a symlink to this. I restarted apache2 and everything was fine. However, the file /etc/apache2/conf.d/testdefault still lists oldroot as DocumentRoot. If I delete the oldroot dir (which is empty), I get complaints. So I just deleted /etc/apache2/conf.d/testdefault and after that there was no more complaints upon restart.

Seems to work fine, but I'm not sure I did what I was proper.

I guess I'll just see what happens.

thanks again
mark


All times are GMT -5. The time now is 03:13 PM.