Estou usando o Debian tenho servidor com nome canônico (definido em /etc/hostname
e em DNS reverso) server.example.com
root@server:~# uname -a
Linux server.example.com 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1 (2015-05-24) x86_64 GNU/Linux
Apache/2.4.10 (Debian) Server at server.example.com Port 80
Agora eu instalei o apache2 e fiz algumas configurações básicas. Em seguida, adicionei o VirtualHosts a /etc/apache2/sites-available
com links simbólicos em sites-enabled
. Tudo está funcionando bem, exceto VirtualHost
com ServerName server.example.com
. Quando tento acessar esse URI no explorer, recebo conteúdo do host virutal padrão (sem ServerName
especificado). Se eu alterar o ServerName de server.example.com.conf
para algo diferente (como test.example.com
) e recarregar a configuração do apache, posso obter o URI sem problemas. Eu gostaria de saber o que está errado em ter o ServerName
do VirtualHost como nome canônico da máquina.
Além disso, server.example.com.conf
tem DocumentRoot /var/www/subs/server
, que contém a pasta index.html
e munin
. O VirtualHost padrão tem DocumentRoot /var/www/html
, que não possui uma pasta munin
. No entanto, quando tento acessar http://server.example.com/munin
, posso entrar em /var/www/subs/server/munin
, enquanto http://server.example.com/index.html
me traz /var/www/html/index.html
.
Por último, quando coloco Redirect 404 /
no VirtualHost padrão, recebo 404
quando tento acessar os dois http://server.example.com/
e http://server.example.com/munin
Configuração adicionada de VirtualHosts
/etc/apache2/sites-available/forum.example.com.conf
:
# Working subdomain configuration
<VirtualHost *:80>
ServerName forum.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/subs/forum
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/apache2/sites-available/server.example.com.conf
:
# Not working server.example.com configuration
<VirtualHost *:80>
ServerName server.example.com
ServerAdmin [email protected]
DocumentRoot /var/www/subs/server
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
/etc/apache2/sites-available/default.conf
:
# Default VirtualHost configuration
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html
#Redirect 404 /
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
root@server:~# apache2ctl -t
Syntax OK
Adicionada ousadia de root@server:~# apache2 -S
[Tue Aug 11 11:07:32.705684 2015] [core:warn] [pid 20215] AH00111: Config variable ${APACHE_LOCK_DIR} is not defined
[Tue Aug 11 11:07:32.706119 2015] [core:warn] [pid 20215] AH00111: Config variable ${APACHE_PID_FILE} is not defined
[Tue Aug 11 11:07:32.706250 2015] [core:warn] [pid 20215] AH00111: Config variable ${APACHE_RUN_USER} is not defined
[Tue Aug 11 11:07:32.706406 2015] [core:warn] [pid 20215] AH00111: Config variable ${APACHE_RUN_GROUP} is not defined
[Tue Aug 11 11:07:32.706566 2015] [core:warn] [pid 20215] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
(... repeating few more times)
[Tue Aug 11 11:07:32.744292 2015] [core:warn] [pid 20215] AH00111: Config variable ${APACHE_LOG_DIR} is not defined
AH00526: Syntax error on line 74 of /etc/apache2/apache2.conf:
Invalid Mutex directory in argument file:${APACHE_LOCK_DIR}
Enquanto,
/etc/apache2/apache2.conf:74:Mutex file:${APACHE_LOCK_DIR} default
/etc/apache2/envvars:21:export APACHE_LOCK_DIR=/var/lock/apache2$SUFFIX
Depois de executar /etc/apache2/envvar
, obtenho isso executando apache2 -S
VirtualHost configuration:
*:80 is a NameVirtualHost
default server server.example.com (/etc/apache2/sites-enabled/default.conf:1)
port 80 namevhost server.example.com (/etc/apache2/sites-enabled/default.conf:1)
port 80 namevhost download.example.com (/etc/apache2/sites-enabled/download.example.com.conf:1)
port 80 namevhost example.com (/etc/apache2/sites-enabled/example.com.conf:1)
alias www.example.com
port 80 namevhost forum.example.com (/etc/apache2/sites-enabled/forum.example.com.conf:1)
port 80 namevhost forumold.example.com (/etc/apache2/sites-enabled/forumold.example.com.conf:1)
port 80 namevhost forumtest.example.com (/etc/apache2/sites-enabled/forumtest.example.com.conf:1)
port 80 namevhost mail.example.com (/etc/apache2/sites-enabled/mail.example.com.conf:1)
port 80 namevhost ro.example.com (/etc/apache2/sites-enabled/ro.example.com.conf:1)
port 80 namevhost server.example.com (/etc/apache2/sites-enabled/server.example.com.conf:1)
port 80 namevhost anotherexample.com (/etc/apache2/sites-enabled/anotherexample.com.conf:1)
alias www.anotherexample.com
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33