Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

With Apache 2 running on windows or other Linux distros (eg Centos) you can show a list of virtual hosts by typing httpd -S at the command line. You get a nice listing of virtual hosts and where they are defined. Debian doesn't seem to support this with the equivalent apache2 -S command, spitting out this error:

apache2: bad user name ${APACHE_RUN_USER}

At first I thought there was a problem with apache env vars but apparently everything works OK. However, I still would like to be able to see a list of all my vhosts. Any ideas how I can do this easily?

share|improve this question

3 Answers 3

up vote 9 down vote accepted

For Debian/Ubuntu use the following:

apache2ctl -S
share|improve this answer
    
This apprears to work exactly how I need, thanks very much. –  Xoundboy Sep 30 '11 at 14:07
    
apachectl -S works for centOS –  pahan Dec 14 '11 at 5:56

You don't have the username and group environment variables defined. Try APACHE_RUN_USER=www-data APACHE_RUN_GROUP=www-data apache2 -S

(replace www-data with the username/group apache is running of)

share|improve this answer

You'll want to make sure that the correct information has been set in /etc/apache2/envvars - this file is read by the apache2 command to know which user should be running the Apache httpd.

See more information in apache2: bad user name ${APACHE_RUN_USER} at the Ubuntu forums.

share|improve this answer
    
I've checked envvars - it's fine. Like I said there are no problems with envvars - the problem is that this build of apache on debian clearly isn't able to report vhosts using the apache2 -S command like it always has been able to in the past. Now I'm looking for an alternative way to dump virtual hosts. –  Xoundboy Sep 30 '11 at 11:32
    
Actually, that file isn't read by apache2, it's read by the apache2ctl and init scripts. You'll need to source it yourself if you are running the server binary by hand (execute . /etc/apache2/envvars in the same shell first) –  DerfK Sep 30 '11 at 11:59
    
@DerfK You're right. It's read by /etc/init.d/apache2 - not the binary itself. I got confused. –  fiskfisk Sep 30 '11 at 19:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.