Understanding Virtual Host Settings for Apache

Asked 2 years ago, Updated 2 years ago, 55 views

Configure apache virtual host settings
Appache Development Environment at example.com /var/www/html/example
was able to access .

cannot access localhost.
You can access 192.168.33.10.
The /etc/httpd/conf.d/localhost.conf file contains:

<VirtualHost*:80>
ServerName localhost
DocumentRoot/var/www/html/
<Directory"/var/www/html/">
AllowOverride All
Options FollowSymlinks-Indexes
</Directory>
ErrorLog logs/local-error_log
CustomLog logs/local-access_log combined env=!no_log
</VirtualHost>

The local machine's Windows hosts file contains the following:

192.168.33.10 localhost

Sorry for the rudimentary question, but
I couldn't find any information even after searching, so I asked you a question.
Thank you for your cooperation.

I would like to add the following.

The environment we are running this time is
Build centos6 in virtualbox on windows 10
This is the situation where apache 2.2.15 is included.

apache

2022-09-30 19:49

2 Answers

Since localhost is generally the name for the loopback address (127.0.0.1), localhost on Windows 10 is Windows 10 and localhost on CentOS 6 is CentOS 6.

In your environment, when accessing localhost on Windows 10, I think you want to connect to CentOS 6, but it's not the normal way to use it, so you should think about something else.

For example, it would be better to set the Centos6 side hostname and write it in the Windows 10 side hosts file, or connect with the Centos6 IP address instead of the hostname.

By the way, name resolution includes hosts files and DNS references, but how to resolve names varies from application to application.In particular, browsers may be cached independently, so if there is no problem, I think it would be better to access them with an IP address.


2022-09-30 19:49

Remove the "/" at the end.
After that, will Apache restart and change?

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

I thought about it a little bit, but the server running Apache and
Is the Windows you're actually looking at something else?
localhost refers to yourself, so if you want to show a different server, you should choose a different virtual domain.
hosts I don't know which is stronger, but
Basically, localhost looks at yourself like 127.0.0.1 or ::1, so
If it doesn't work, try something other than localhost.

localhost was referenced to a different IP in hosts.
ping sent to a different IP, so it seems that hosts can be overwritten.
We tested to see if we could connect to a server that we built with VirtualBox.
Some browsers call themselves localhost.

  • IE:OK
  • FireFox:OK
  • Chrome:NG
  • Opera:NG

Also, I tested the Apache configuration, but it seems to be working.
However, one typo was found: Options-FollowSymlinks-Indexes does not contain "-"

<VirtualHost*:80>
    DocumentRoot/var/www/html
    ServerName localhost

    <Directory"/var/www/html">
        AllowOverride All
        Options - FollowSymlinks - Indexes
    </Directory>
    ErrorLog logs/local-error_log
    CustomLog logs/local-access_log combined env=!no_log
</VirtualHost>


2022-09-30 19:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.