找不到Ubuntu Apache2本地虚拟主机url [英] Ubuntu Apache2 local virtual hosts url not found

查看:97
本文介绍了找不到Ubuntu Apache2本地虚拟主机url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ubuntu 16.10上的LAMP堆栈为用于不同站点的虚拟主机和基于名称的虚拟主机的单用户开发设置笔记本电脑,以用于多个站点的单用户开发.我尝试了各种配置设置组合,但是无法从浏览器加载网站,我得到在此服务器上找不到所请求的URL".以下是相关配置文件中的相关代码段:

I am setting up my laptop for single-user development of multiple sites using the LAMP stack on Ubuntu 16.10 with virtual hosts for the different sites, and name-based virtual hosts. I have tried various combinations of config settings, but I cannot load a site from the Browser, I get "the requested URL was not found on this server." Here are relevant code snippets from relevant config files:

Ports.conf:

Ports.conf:

听8000

apache2.conf:

apache2.conf:

NameVirtualHost *:8000
ServerName localhost
...

.../sites-enabled/000-default.conf:

.../sites-enabled/000-default.conf:

<VirtualHost *:8000>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
...

.../sites-enabled/abc.conf:

.../sites-enabled/abc.conf:

<VirtualHost *:8000>
ServerName abc
ServerAdmin admin@abc.com
ServerAlias www.abc.com abc.com
DocumentRoot /var/www/abc

.../sites-enabled/pbnat.conf:

.../sites-enabled/pbnat.conf:

<VirtualHost *:8000>
ServerName pbnat
ServerAdmin admin@pbnat.com
ServerAlias pbnat.com pbn.com
DocumentRoot /var/www/pbnat/public
...

/etc/hosts

/etc/hosts

127.0.0.1   localhost
127.0.1.1   Lenovo-y2-11
127.0.0.1   abc
127.0.0.1   pbnat

Dir结构:

/var/www/
   |-- abc/
       |- index.html
   |-- html/
       |- index.html
   |-- pbnat/
       |-- public/
           |- index.html

/var/www/上的权限:

Permissions on /var/www/:

drwxr-xr-x 2 www-data julie 4096 Jan  8 16:53 abc
drwxrwxr-x 2 root     root  4096 Dec 31 00:02 html
drwxrwxr-x 3 www-data pbnat 4096 Jan  6 22:32 pbnat

/var/www/abc/上的权限:

Permissions on /var/www/abc/:

-rw-r--r-- 1 www-data julie 139 Jan  8 16:53 index.html

/var/www/html/上的权限:

Permissions on /var/www/html/:

-rwxrwxr-x 1 root root 11321 Dec 31 00:02 index.html

/var/www/pbnat/上的权限:

Permissions on /var/www/pbnat/:

drwxrwxr-x 2 www-data pbnat 4096 Jan  7 00:00 public

浏览器URL测试和结果:

Browser URL tests and results:

file:///var/www/abc/index.html-成功!abc虚拟主机正在运行!

file:///var/www/abc/index.html - Success! The abc virtual host is working!

file:///var/www/pbnat/public/index.html-成功!pbnat虚拟主机正在运行!

file:///var/www/pbnat/public/index.html - Success! The pbnat virtual host is working!

localhost –无法访问站点;本地主机拒绝连接.

localhost – site can’t be reached; localhost refused to connect.

localhost:8000 – Apache2 Ubuntu默认页面

localhost:8000 – Apache2 Ubuntu default page

localhost:8000/abc-在此服务器上找不到请求的URL/abc.

localhost:8000/abc - The requested URL /abc was not found on this server.

localhost:8000/abc.com-在此服务器上找不到请求的URL/abc.com.

localhost:8000/abc.com - The requested URL /abc.com was not found on this server.

  • 然后我在用于新站点的主机文件中将IP更改为127.0.0.2,但将localhost保留为127.0.0.1并尝试:

127.0.0.2:8000-Apache2 Ubuntu默认页面

127.0.0.2:8000 - Apache2 Ubuntu default page

127.0.0.2:8000/abc –在此服务器上找不到请求的URL/abc.

127.0.0.2:8000/abc – The requested URL /abc was not found on this server.

错误日志显示没有异常,访问日志显示HTTP状态代码404,以及第二个代码495或496;即使我输入127.0.0.2:8000/abc

Error log shows nothing unusual, Access log shows HTTP status code of 404, along with a second code of 495 or 496; also it lists 127.0.0.1 in the first column of the log even if I enter 127.0.0.2:8000/abc

很久以前就去了.非常感谢.

Been going at this quite some time. Help much appreciated.

推荐答案

问题在于浏览器中如何输入URL.它应该是:abc:8000不是:本地主机:8000/abc

The problem was based in how the URL is entered in the browser. It should be: abc:8000 Not: localhost:8000/abc

这篇关于找不到Ubuntu Apache2本地虚拟主机url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆