简体   繁体   English

使用IP地址作为服务器名称的虚拟主机子域?

[英]Virtual host subdomain with a IP address as the server name?

So I have a virtual host setup that is working but it is an internal server so we have no domain name for it. 因此,我有一个正在运行的虚拟主机设置,但它是一个内部服务器,因此我们没有域名。 So under my server name I just have the IP Address and it works fine, however now I need to setup a subdomain and apache doesn't seem to be cooperating. 因此,在我的服务器名称下,我只有IP地址,并且可以正常工作,但是现在我需要设置一个子域,而apache似乎并没有合作。 Below essentially what I am trying to do but with the IP address removed. 下面基本上是我想做的事,但删除了IP地址。 Any idea how this can be done? 知道如何做到这一点吗?

<VirtualHost *:80>
  ServerName 111.111.111.111
  DocumentRoot "/var/www/laravel/public"
  <Directory "/var/www/laravel/public">
    AllowOverride all
  </Directory>
</VirtualHost>

<VirtualHost *:80>
  ServerName payment.111.111.111.11
  DocumentRoot "/var/www/html"
  <Directory "/var/www/html">
    AllowOverride all
  </Directory>
</VirtualHost>

A good way to achieve this is by using a different port: 一个好的方法是使用不同的端口:

<VirtualHost *:80>
  ServerName 111.111.111.111
  DocumentRoot "/var/www/laravel/public"
  <Directory "/var/www/laravel/public/">
    AllowOverride all
  </Directory>
</VirtualHost>

Listen 8000

<VirtualHost *:8000>
  ServerName 111.111.111.111
  DocumentRoot "/var/www/html"
  <Directory "/var/www/html/">
    AllowOverride all
  </Directory>
</VirtualHost>

I set the port 8000 as an example, in order to avoid side effects by using "reserved ports" you might check this list , so you can choose any unassigned one. 我以端口8000为例,为了避免使用“保留端口”的副作用 ,您可以检查此列表 ,因此可以选择任何未分配的端口。

Don't forget to add the 别忘了添加

Listen 8000 听8000

directive so the webserver attends for connections on that specific port, and also, it is convenient to add the trailing backslash within the tag: 指令,以便Web服务器在该特定端口上参与连接,并且,在标记内添加尾随反斜杠也很方便:

<Directory "/var/www/html/">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM