P
P
Pavel Bykov2018-08-01 23:45:35
Apache HTTP Server
Pavel Bykov, 2018-08-01 23:45:35

How can I host apache websites through virtualbox?

I have a virtualBox and it has LAMP on it. In apache configs I added the following config

<VirtualHost *:80>
    ServerName test-site.dev
    DocumentRoot /home/user/sites/test-site

    ErrorLog /home/user/logs/test-site/error.log
    CustomLog /home/user/logs/test-site/error.log combined
</VirtualHost>

And then I wrote the following in hosts on the virtual machine itself.
127.0.0.1 test-site.dev
That is, I indicated that the request should be accepted by the virtual machine and thus process the request through apache.
Then I indicated in windows, in the hosts file, the following value.
192.168.1.26 test-site.dev
That is, I indicate here that this request should be transferred to my virtual machine.
It seems that everything is logically so, but for some reason when I drive this domain into the browser, it does not connect .... In the virtual machine itself, if you try to register ping test-site.dev, then it gives packets. What could be my problem?
Moreover, if I just type in 192.168.1.26 in the browser, then I get a standard apache page.
PS In the folder I have site files (index.html), I have already checked all the paths 10 times and everything is correct.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Pavel Bykov, 2018-08-04
@mafof

I solved the problem, the result:
On the mac os operating system it works without any complaints, just add a line to the hosts and everything works.
For some reason, the .dev domain does not work on windows, when I changed it to .com, everything worked.

E
Ezhyg, 2018-08-02
@Ezhyg

It is very likely that you misunderstand the principles of work, which is why you use the wrong words.
No. This entry is just an entry in a kind of "database of names" (the same hosts file), that is, consider it an analogue of DNS. That is, for the computer to apply for a match between the digital address and the corresponding text address, not to the configured DNS server (by default), but to receive a response from itself.
And it's not like that. As in the first case, there is simply a recognition (resolution) of a name to an address (resolve).
Yes, this will give the machines (both real and virtual) an understanding of the address where the packets will "go", but this is not a "transfer" at all.
But in general, there is a suspicion that the network of the machine in the virtual box is simply not configured correctly. Try switching the network to the "Network Bridge", so you will make the virtual machine a real network node, with its full address, without any forwarding, nats and other things.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question