如何在Centos Apache上使用不同的端口运行同一个域上的两个网站

mklgxw1f  于 2023-01-31  发布在  Apache
关注(0)|答案(1)|浏览(184)

我已经有了一个运行在443端口上的网站。我正在使用带有Apache的CentOS 7环境。
因此,定义域为:https://www.example.com
现在,我有一个网站,并希望运行此网站上相同的不同端口,如444。所以,这个网站的最终网址应该是:
http://www.example.com:444
要在端口443上运行第一个网站,我做了以下事情:

**步骤1:**在“/etc/httpd/sites-available/website1.conf”中创建了一个配置文件。此文件包含以下代码:

<VirtualHost *:443> 
      ServerName server-ip 
      ServerAlias server-ip 
      DocumentRoot "/opt/lampp/htdocs/website1/" 
      DirectoryIndex index.html index.php 
     <Directory "/opt/lampp/htdocs/live/"> 
       Options Indexes FollowSymLinks Includes ExecCGI 
       DirectoryIndex index.php index.html 
       AllowOverride All
       Order allow,deny 
       Allow from all 
     </Directory> 
</VirtualHost>

**步骤2:**启用此虚拟主机文件,以便Apache知道此虚拟主机。
**第3步:**转到主机文件“/etc/host”,并根据提到的server-ip创建此虚拟主机的条目:

我的服务器-IPwww.example.com
所以,以上所有的事情都在工作,我的网站运行在域www.example.com.
现在,我已经创建了另一个虚拟主机具有相同的域名,但不同的端口号如下:

**步骤1:**在“/etc/httpd/sites-available/website2.conf”下创建.conf文件。此文件包含以下代码:

<VirtualHost *:444> 
      ServerName same-server-ip 
      ServerAlias same-server-ip 
      DocumentRoot "/opt/lampp/htdocs/website2/" 
      DirectoryIndex index.html index.php 
     <Directory "/opt/lampp/htdocs/live/"> 
       Options Indexes FollowSymLinks Includes ExecCGI 
       DirectoryIndex index.php index.html 
       AllowOverride All
       Order allow,deny 
       Allow from all 
     </Directory> 
</VirtualHost>

**步骤2:**启用此新网站。
**第3步:**在/etc/http/conf/httpd.conf的.conf文件中添加此端口号,就在此行的下面:

Listen 80  
Listen 444

**步骤4:**之后,重新启动Apache。

现在,当我点击网址:www.example.com:444,服务器将我重定向到第一个网站www.example.com。
我想不出我错过了什么,有没有人能帮我一下?

guz6ccqo

guz6ccqo1#

遇到了类似的问题,所以我决定回复,即使它已经有一段时间以来,这是张贴。
由于这是重定向,它的一个迹象,一切都工作正常,但你有一个重定向命令在您的html。
你必须检查你的html meta标记的重定向命令,它看起来像这样

相关问题