【发布时间】:2018-05-20 13:33:27
【问题描述】:
我想让多个域访问同一个 EC2 实例。所有人都将拥有相同的IP。我已将多个 vhost 文件设置为 domain1.com 和 domain2.com。我在任何 htaccess 文件或 vhost 文件中都没有任何特别之处。我通过 GoDaddy 拥有域,它们指向 EC2 IP。我遇到的问题是域 1 和 2 都进入同一个文件夹并在浏览器中显示相同的 index.html。
根据https://help.ubuntu.com/lts/serverguide/httpd.html,我看到 httpd.conf 不再存在,我在 apache2.conf 中看不到任何幽灵。
(你可以看到我尝试过的注释掉的东西)
* 不使用 rout 53,我不想使用它,除非我也有*
虚拟主机文件:
(域 1)
#SSLStaplingCache shmcb:/tmp/stapling_cache(128000)
SSLStaplingCache shmcb:${APACHE_RUN_DIR}/ssl_stapling_cache(128000)
<VirtualHost *:80>
ServerAdmin me@localhost
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLUseStapling on
RewriteEngine on
#RewriteRule domain1.com\/$ http://domain1.com [NC]
RewriteCond %{SERVER_NAME} =domain1.com [OR]
RewriteCond %{SERVER_NAME} =domain1.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
(域 2)
<VirtualHost *:80>
ServerAdmin me@gmail.com
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /var/www/html/domain2.com
# ServerPath "/domain2.com/"
# RewriteEngine On
# RewriteRule "^(/domain2.com/.*)" "/html/domain2.com$1"
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/html/domain2.com>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
#RewriteEngine on
#RewriteRule domain2.com\/$ http://domain2.com/index.php [NC]
</VirtualHost>
default-ssl.conf 文件:
<IfModule mod_ssl.c>
<VirtualHost _default_:443>
ServerAdmin me8@gmail.com
ServerName domain1.com
DocumentRoot /var/www/html/domain1.com
****************编辑****************
apache2 -v
Server version: Apache/2.4.18 (Ubuntu)
Server built: 2017-09-18T15:09:02
sudo apachectl configtest
Syntax OK
我已经完成了对 vhost 文件的“sudo a2ensite”命令并在它们之后重新启动了 apache
********** 编辑 ****************
在主机中:
127.0.0.1 localhost
127.0.1.1 domain1.com
127.0.1.2 domain2.com
【问题讨论】:
标签: amazon-ec2 apache2 lamp vhosts