【发布时间】:2020-04-05 12:20:51
【问题描述】:
我是 Apache 的新手,但我看到一些与此列表类似的问题,希望您能提供帮助。
我只想在我的 Ubuntu 18.04 LTS (Asus VivoBook S15) 下设置一个基本的本地 LAMP 系统来测试一个网站,在我的商业 ISP 主机上使用该版本之前我必须修改该网站。
基本安装顺利(Apache/2.4.29,PHP 7.2),可以通过 url localhost 从 var/www/html 文件夹处理 html 和 php。然后我做了以下设置 public_html 访问:
i) 在 /etc/apache2/apache2.conf 中添加这一行:
ServerName localhost:80
ii) 激活 UserDir 模块 (sudo a2enmod userdir) 并编辑文件 /etc/apache2/mods-enabled/userdir.conf 如下:
<IfModule mod_userdir.c>
UserDir public_html
UserDir disabled root
<Directory /home/*/public_html>
# AllowOverride FileInfo AuthConfig Limit Indexes
AllowOverride All
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Options ExecCGI Indexes MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
Require method GET POST OPTIONS
</Directory>
</IfModule>
iii) 激活默认虚拟用户目录 (sudo a2ensite 000-default.conf) 并编辑文件 /etc/apache2/sites-enabled/000-default.conf 如下:
# Global configuration
ServerName localhost
# without port according to recommendation found on the web
和
#ServerAdmin webmaster@localhost
ServerAdmin john@john-VivoBook
#DocumentRoot /var/www/html
DocumentRoot /home/john/public_html
iv) 在我的主目录 (/home/john) 下创建 public_html 目录,所有权为 john:john,权限为 755(也尝试使用 777),并添加了我的 index.html 和 index.php 文件
v) 重启 Apache (sudo apache2ctl restart)
vi) 将我的 Firefox 浏览器配置为不将 www 添加到 url。
当我尝试访问 URL“localhost”时,我得到一个空白屏幕,而使用“localhost/public_html”、“localhost/public_html/index.html”或“localhost/public_html/index.php”我收到消息:
Not Found
The requested URL was not found on this server.
Apache/2.4.29 (Ubuntu) Server at localhost Port 80
日志文件/var/log/apache2/error.log中没有错误
日志文件 /var/log/apache2/access 日志的尾部说:
127.0.0.1 - - [05/Apr/2020:13:24:44 +0200] "GET /public_html HTTP/1.1" 404 488 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
127.0.0.1 - - [05/Apr/2020:13:26:41 +0200] "GET /public_html/index.html HTTP/1.1" 404 488 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
127.0.0.1 - - [05/Apr/2020:13:27:29 +0200] "GET /public_html/index.php HTTP/1.1" 404 488 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:74.0) Gecko/20100101 Firefox/74.0"
日志文件 /var/log/apache2/other_vhosts_access.log 不存在。
我做错了什么?
谢谢和最好的问候,约翰
【问题讨论】:
-
您应该更新您的问题以指定您的问题和预期结果。
标签: apache ubuntu public-html