- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
在你问之前,我试着寻找类似的问题,没有一个是我的问题。
我是新手,我在运行raspbian的raspi上安装了apache2、php5和mysql5。
根据需要,我将index.html
放在/var/www/html
中,当我单独键入pi的ip或后跟/index.html
时,index.html
会正确运行其代码,并且所有元素都会出现。
问题:此外,我把我的js和css文件放在同一个文件夹中,还有一些照片要显示。
浏览器完全读取html,但不加载由此链接的js和css文件,也不加载图像。把文件放在子文件夹中也没有帮助。
当我输入ip,然后输入/style.css
(链接css文件的名称)时,我得到一个403禁止。错误日志还显示:
file permissions deny server access: /var/www/html/photo.jpg, referer: http://192.168.178.120/
access to /images/dark.jpg denied because search permissions are missing on a component of the path, referer: http://192.168.178.120/
index.html
以外的文件。
最佳答案
根据ls
的结果,apache无法访问您的文件。
简短回答:
运行以下两个命令:find /var/www/html -type f -exec chmod 644 {} \;
find /var/www/html -type d -exec chmod 755 {} \;
更长的解释:
pi@raspberrypi:~ $ ls -l /var/www/html
total 2976
-rw------- 1 pi pi 60146 Jul 23 22:11 bnw.jpg
-rw------- 1 pi pi 202851 Jul 23 22:11 color.jpg
-rw------- 1 pi pi 617185 Jul 23 21:27 dark.jpg
-rw------- 1 pi pi 2028727 Jul 23 22:11 effect.jpg
drwx------ 2 pi pi 4096 Jul 23 21:33 images
-rw------- 1 pi pi 2238 Jul 23 22:11 index.css
-rw-r--r-- 1 pi root 1261 Jul 23 22:11 index.html
-rw------- 1 pi pi 108397 Jul 23 22:11 photo.jpg
-rw------- 1 pi pi 538 Jul 23 22:11 script.js
-rw------- 1 pi pi 2238 Jul 23 21:33 style.css
d: indicates a directory
r: means the file/directory is readable
w: means the file/directory is writable
x: means the file/directory is executable
-: means none of the above apply
drwxrwxrwx
^^^ apply to all users on the system
^^^--- apply to all users in the group that owns the file
^^^------ apply to the user that owns the file
pi pi
是指文件的所有者:组
pi
中的用户
pi
。您的
index.html
文件是一个例外,因为它属于
root
组。
www-data
的身份运行。这在不同的系统中有所不同,但这是最常见的。这意味着为了让apache能够访问一个文件,它必须对
www-data
用户或
www-data
组(或两者)可用。
www-data
和组
pi
所有(index.html除外,它归组
pi
所有)。由于apache不是这个用户,而且很可能不在这两个组中的任何一个组中,这意味着必须正确设置“系统上所有用户”的文件权限,以便apache能够访问该文件。
root
设置为对系统上的所有用户都可读:
-rw-r--r-- 1 pi root 1261 Jul 23 22:11 index.html
^^^ all users on the system may read from this file, but may not write and may not execute the file
^^^--- all users in the group "root" may read from this file, but may not write and may not execute the file
^^^------ the user "pi" may read from and write to this file, but may not execute the file
index.html
目录,只能由“pi”用户访问:
-rw------- 1 pi pi 2028727 Jul 23 22:11 effect.jpg
^^^ all users on the system may not read from, write to or execute this file
^^^--- all users in the group "pi" may not read from, write to or execute this file
^^^------ the user "pi" may read from and write to this file, but may not execute it
images
对apache可用,您需要将文件权限更改为:
-rw----r-- 1 pi pi 2028727 Jul 23 22:11 effect.jpg
^^^ all users on the system (including Apache) may read from this file
effect.jpg
命令。有两种方法可以取消该权限:
chmod
chmod o+r effect.jpg
chmod 604 effect.jpg
表示“将'r'权限添加到'other users'类别”(您可以使用
chmod o+r
或
u+r
更改用户或组权限)。
g+r
表示“将用户的权限设置为6,将组设置为0,将其他用户的权限设置为4”,其中数字是权限的二进制和:1(可执行)、2(可写)、4(可读)。
drwx------ 2 pi pi 4096 Jul 23 21:33 images
drwx---r-x 2 pi pi 4096 Jul 23 21:33 images
^^^ all users on the system may read from this directory and execute it
chmod 604
(其他用户,添加可读和可执行权限)
chmod o+rx images
(设置读取(4)+写入(2)+所有者执行(1)和读取(4)+所有其他用户执行(1)
chmod 705 images
(
604
)和文件夹
-rw----r--
(
705
),不如提供它们
drwx---r-x
(
644
)和
-rw-r--r--
(
755
)。如果您工作的环境中需要多个开发人员能够修改文件,那么他们应该在同一个用户组中,最佳做法是授予该组与所有者相同的权限,因此
drwxr-xr-x
(
644
)和
-rw-rw-r--
(
775
)。
drwxrwxr-x
命令执行批更新。
find
将列出给定文件夹(包括子文件夹)的全部内容,然后可以对其进行筛选或执行操作。
find
find /var/www/html -type f
或任何常规文件子文件夹中的所有条目。
/var/www/html
find /var/www/html -type d
或任何子文件夹中作为目录的所有条目。
/var/www/html
告诉
-exec
在找到的每个文件/文件夹上自动执行特定命令:
find
find /var/www/html -type f -exec chmod 644 {} \;
是一个占位符,其中
{}
将放置每个文件名。需要
find
来通知
\;
不会为
find
命令提供更多参数,因此我们可以选择为
-exec
本身添加其他参数。
find
find /var/www/html -type d -exec chmod 755 {} \;
中的所有文件和文件夹。请记住,每次在该文件夹中创建新文件时,都需要检查权限并在必要时修复它。
关于html - Apache不允许加载除index.html之外的其他文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45269674/
在流处理方面,Apache Beam和Apache Kafka之间有什么区别? 我也试图掌握技术和程序上的差异。 请通过您的经验报告来帮助我理解。 最佳答案 Beam是一种API,它以一种统一的方式使
有点n00b的问题。 如果我使用 Apache Ignite 进行消息传递和事件处理,是否还需要使用 Kafka? 与 Ignite 相比,Kafka 基本上会给我哪些(如果有的话)额外功能? 提前致
Apache MetaModel 是一个数据访问框架,它为发现、探索和查询不同类型的数据源提供了一个通用接口(interface)。 Apache Drill 是一种无架构的 SQL 查询引擎,它通过
Tomcat是一个广泛使用的java web服务器,而Apache也是一个web服务器,它们在实际项目使用中有什么不同? 经过一些研究,我有了一个简单的想法,比如, Apache Tomcat Ja
既然简单地使用 Apache 就足以运行许多 Web 应用程序,那么人们何时以及为什么除了 Apache 之外还使用 Tomcat? 最佳答案 Apache Tomcat是一个网络服务器和 Java
我在某个 VPS( friend 的带 cPanel 的 apache 服务器)上有一个帐户,我在那里有一个 public_html 目录。我们有大约 5-6 个网站: /home/myusernam
我目前正在尝试将模块加载到 Apache,使用 cmake 构建。该模块称为 mod_mapcache。它已成功构建并正确安装在/usr/lib/apache2/modules directroy 中
我对 url 中的问号有疑问。 例如:我有 url test.com/controller/action/part_1%3Fpart_2 (其中 %3F 是 url 编码的问号),并使用此重写规则:R
在同一台机器上,Apache 在端口 80 上运行,Tomcat 在端口 8080 上运行。 Apache 包括 html;css;js;文件并调用 tomcat 服务。 基本上 exampledom
Apache 1 和 Apache 2 的分支有什么区别? 使用一种或另一种的优点和缺点? 似乎 Apache 2 的缺点之一是使用大量内存,但也许它处理请求的速度更快? 最有趣的是 Apache 作
实际上,我们正在使用 Apache 网络服务器来托管我们的 REST-API。 脚本是用 Lua 编写的,并使用 mod-lua 映射。 例如来自 httpd.conf 的实际片段: [...] Lu
我在 apache 上的 ubuntu 中有一个虚拟主机,这不是我的主要配置,我有另一个网页作为我的主要网页,所以我想使用虚拟主机在同一个 IP 上设置这个。 urologyexpert.mx 是我的
我使用 Apache camel 已经很长时间了,发现它是满足各种系统集成相关业务需求的绝佳解决方案。但是几年前我遇到了 Apache Nifi 解决方案。经过一番谷歌搜索后,我发现虽然 Nifi 可
由于两者都是一次处理事件的流框架,这两种技术/流框架之间的核心架构差异是什么? 此外,在哪些特定用例中,一个比另一个更合适? 最佳答案 正如您所提到的,两者都是实时内存计算的流式平台。但是当您仔细观察
apache 文件(如 httpd.conf 和虚拟主机)中使用的语言名称是什么,例如 # Ensure that Apache listens on port 80 Listen 80 D
作为我学习过程的一部分,我认为如果我扩展更多关于 apache 的知识会很好。我有几个问题,虽然我知道有些内容可能需要相当冗长的解释,但我希望您能提供一个概述,以便我知道去哪里寻找。 (最好引用 mo
关闭。这个问题是opinion-based .它目前不接受答案。 想改善这个问题吗?更新问题,以便可以通过 editing this post 用事实和引文回答问题. 4 个月前关闭。 Improve
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引起辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the he
这个问题在这里已经有了答案: Difference Between Apache Kafka and Camel (Broker vs Integration) (4 个回答) 3年前关闭。 据我所知
我有 2 个使用相同规则的子域,如下所示: RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond
我是一名优秀的程序员,十分优秀!