简体   繁体   English

家用Apache Web服务器-最后的障碍

[英]Home apache web server - final hurdle

Ok, so bit of noob question - having one of those days. 好的,有点菜鸟的问题-那些日子之一。

I have set up a home apache web server on Ubuntu. 我已经在Ubuntu上设置了一个家用apache网络服务器。 I have configured vhosts as I want to host multiple websites. 我已经配置了虚拟主机,因为我想托管多个网站。 These work fine in the local browser, eg 这些可以在本地浏览器中正常工作,例如

http://site1
http://site2

both display their various contents. 都显示其各种内容。

For the server side of things, I've configured port forwarding on my router to send all port 80 requests to the server IP. 对于服务器方面,我已经在路由器上配置了端口转发,以将所有端口80请求发送到服务器IP。

When I go to an external browser and type in my servers external IP address I get the standard apache "It works!" 当我使用外部浏览器并输入服务器的外部IP地址时,我得到标准的Apache“有效!” message. 信息。 When I type in ipaddress/site1 I get 404. The site1 is not in the standard apache default directory, I have it in home/username/Sites/site1 folder and httpd.conf file knows this. 当我输入ipaddress / site1时,我得到404。site1不在标准的apache默认目录中,我将它放在home / username / Sites / site1文件夹中,并且httpd.conf文件知道这一点。

How is it I can access these site1 and site2 sites externally? 如何从外部访问这些site1和site2网站?

Cheers 干杯

Just as you would do in your local browser. 就像在本地浏览器中一样。 So typing in http://site1 would lead you to the first site. 因此,输入http://site1会将您带到第一个站点。 This is based on an assumption though, which is that you put the http://site1 address in your /etc/hosts file. 不过,这是基于一个假设,即您将http://site1地址放在/ etc / hosts文件中。 When your computer looks up an URL, it first checks the hosts file (and your case will find the correct IP address there) and next will ask a global mechanism for the address. 当您的计算机查找URL时,它将首先检查主机文件(您的案例将在其中找到正确的IP地址),然后将询问用于该地址的全局机制。

The reason why it doesnt find anything at "ipaddress/site1" is because of the vhosts configuration. 它在“ ipaddress / site1”上找不到任何内容的原因是由于vhosts配置。 This teel Apache serve the content of a folder somewhere on your server as a separate hostname, eg http://site1 . 这条Apache将服务器上某个文件夹的内容作为单独的主机名提供,例如http://site1 If you're requesting "ipadress/site1", you're actually telling Apache to look in the folder "site1" in its first root it encounters in your Vhost configuration. 如果您请求“ ipadress / site1”,则实际上是在告诉Apache在您的Vhost配置中遇到的第一个根目录中查找“ site1”文件夹。

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

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