Я видел это несколько раз, но, на удивление, у меня не сработало ни одно решение:
Что бы я ни делал, secondwebsite.com продолжает показывать firstwebsite.com. Кто-нибудь знает, что может быть причиной этого?
Вот мой "/ etc / apache2 / sites-available / default"
<VirtualHost *:80>
ServerAdmin admin@gmail.com
ServerName firstwebsite.com
ServerAlias www.firstwebsite.com
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /static /home/user/firstwebsite/firstwebsite/static
<Directory /home/user/firstwebsite/firstwebsite/static>
Order allow,deny
Allow from all
</Directory>
Alias /media /home/user/firstwebsite/firstwebsite/site_media/media
<Directory /home/user/firstwebsite/firstwebsite/site_media/media>
Order allow,deny
Allow from all
</Directory>
<Directory /home/user/firstwebsite/firstwebsite>
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess firstwebsite
WSGIProcessGroup firstwebsite
WSGIScriptAlias / /home/user/firstwebsite/firstwebsite/wsgi.py
</VirtualHost>
Мой "/etc/apache2/sites-available/com.secondwebsite.conf"
<VirtualHost *:80>
ServerAdmin admin@gmail.com
ServerName secondwebsite.com
ServerAlias www.secondwebsite.com
DocumentRoot /var/www/secondwebsite/public_html
ErrorLog ${APACHE_LOG_DIR}/secondwebsite_error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Мой "/etc/apache2/ports.conf"
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default
# This is also true if you have upgraded from before 2.2.9-3 (i.e. from
# Debian etch). See /usr/share/doc/apache2.2-common/NEWS.Debian.gz and
# README.Debian.gz
NameVirtualHost *:80
Listen 80
<IfModule mod_ssl.c>
# If you add NameVirtualHost *:443 here, you will also have to change
# the VirtualHost statement in /etc/apache2/sites-available/default-ssl
# to <VirtualHost *:443>
# Server Name Indication for SSL named virtual hosts is currently not
# supported by MSIE on Windows XP.
Listen 443
</IfModule>
<IfModule mod_gnutls.c>
Listen 443
</IfModule>
Результат sudo / usr / sbin / apache2ctl -S
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server firstwebsite.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost firstwebsite.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost secondwebsite.com (/etc/apache2/sites-enabled/com.secondwebsite.conf:1)
Syntax OK
Псевдоним вашего сервера, похоже, не работает, поскольку он не сообщается командой /usr/sbin/apache2ctl -S
как это должно быть похоже на
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server firstwebsite.com (/etc/apache2/sites-enabled/000-default:1)
port 80 namevhost firstwebsite.com (/etc/apache2/sites-enabled/000-default:1)
alias www.firstwebsite.com
port 80 namevhost secondwebsite.com (/etc/apache2/sites-enabled/com.secondwebsite.conf:1)
alias www.secondwebsite.com
Syntax OK
Также укажите свою версию Apache.
Также нет конфигурации "Каталог" для / var / www / secondwebsite / public_html на вашем втором виртуальном хосте. Попробуйте поставить одну.
Что касается моего опыта, это может произойти в следующей ситуации:
firstsite.com имеет dns 1.2.3.4 и ip в vhost 1.2.3.4 или *
secondsite.com имеет dns 1.2.3.4, а ip в vhost - 1.2.3.5.
И 1.2.3.4, и 1.2.3.5 являются IP-адресами проблемного сервера, и apache прослушивает оба IP-адреса.
НО, что касается нескольких предоставленных вами журналов и деталей, трудно найти, так ли это на самом деле.