IP and Apache Virtual Hosts

I have this web server that has the IP address xxx.xxx.xx.x, I also have a website that I want to publish, but I don’t have a domain for my site yet.

So, in my file httpd-vhosts.conf, I have this parameter:

<VirtualHost xxx.xxx.xx.x>
  ServerName xxx.xxx.xx.x
  DocumentRoot "C:\Sites\mysite"
</VirtualHost>

And since I don’t have a domain, I really want to use the IP address to access my site, but I tried this and it does not work. I think you need to set the server name to ServerName, as the header says.

Are there any ways to make my site publicly available through my IP address, if so, how can I do this?

+3
source share
3 answers

Try

NameVirtualHost *:80

<VirtualHost *:80>
  DocumentRoot C:\Sites\mysite
  ServerName xx.xx.xx.xx
</VirtualHost>

Remember to restart apache,

Listen xx.xx.xx.xx:80
+4

- , . DocumentRoot . , Apache IP- (Listen 0.0.0.0:80.)

, :

telnet xx.xx.xx.xx 80
GET /

, - - .

0

This is not a programming issue.

But anyway

Set VirtualHost to *, not a specific IP address. I do not think you need the server name.

-1
source

Source: https://habr.com/ru/post/1734066/


All Articles