请。我在 apache 服务器上禁用了默认主机 (a2dissite 000-default.conf)。我最初为第一个域安装了虚拟主机 1,一切正常。在我为第二个域设置了第二个主机(创建了单独的 www 文件夹/单独的配置)后,标准 a2ensite 第二个域(经过 apache 确认并添加到 sites-available 和 sites-enabled)尝试第二个域后,它仍然重定向到第一个虚拟主机...有人知道哪里出了问题吗?非常感谢...
正在运行:apache、php-fpm、memcached 服务器
第一个虚拟主机配置:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName demo.domain1.com
ServerAlias demo.domain1.com
DocumentRoot /var/www/demo.domain1.com/public_html
<Directory /var/www/demo.domain1.com/public_html>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
<FilesMatch \.php$>
SetHandler "proxy:unix:/run/php/php8.1-fpm.sock|fcgi://localhost/"
</FilesMatch>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =demo.domain1.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
对于 SSL (由 certbot 创建):
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName demo.domain1.com
ServerAlias demo.domain1.com
DocumentRoot /var/www/demo.domain1.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/demo.domain1.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/demo.domain1.com/privkey.pem
</VirtualHost>
</IfModule>
第二位主持人:
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /var/www/domain2.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =domain2.com [OR]
RewriteCond %{SERVER_NAME} =www.domain2.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
对于 SSL(由 certbot 创建):
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin [email protected]
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /var/www/domain2.com/public_html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/domain2.com-0001/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain2.com-0001/privkey.pem
</VirtualHost>
</IfModule>