我有 Apache 2在我的 Raspberry Pi 上安装了 PHP,当我请求 index.php 时它加载正常,但是当我尝试请求任何子文件夹或任何其他文件时(strandsort.cs在此示例 - 也可以是 anything.txt,只是不是要解析的 HTML/PHP),我得到 403 access denied,但是当我请求应该解析的文件时(i2.php) 我得到一个空白页。
可能还值得注意的是,phpmyadmin 似乎工作正常。
我配置的配置是:
/etc/apache2/sites-enabled/000-default
并将AllowOverride设置为ALL。
这是错误:
PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0, referer: http://raspberryIP/
PHP Fatal error: Unknown: Failed opening required '/var/www/i2.php' (include_path='.:/usr/share/php$ http://raspberryIP/
其中“RaspberryIP”是设备的 IP 地址。
最佳答案
错误是:
PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0, referer: http://raspberryIP/
PHP Fatal error: Unknown: Failed opening required '/var/www/i2.php' (include_path='.:/usr/share/php$ http://raspberryIP/
所以这似乎是文件 /var/www/i2.php 的权限问题。哪个用户拥有该文件? Apache 能够读取该文件吗?如果从命令行运行此命令,输出是什么:
ls -la /var/www/i2.php
此外,Apache 错误日志说了什么?它们应该位于:
/var/log/apache2/access.log
/var/log/apache2/error.log
您可以像这样使用 tail 跟踪他们的输出:
sudo tail -f -n 200 /var/log/apache2/access.log
sudo tail -f -n 200 /var/log/apache2/error.log
这些路径基于标准的 Ubuntu 12.04 安装,但对于 CentOS 和您在 Raspberry PI 中使用的任何 Debian 变体应该是相同的。
如您所知,此问题并非 Raspberry PI 设置所特有,而是真正的标准 Linux Apache 服务问题。因此,用于成熟服务器的调试技术也可以在这里发挥作用。
此外,您的/etc/apache2/sites-available/default 文件的内容是什么?那是 /etc/apache2/sites-enabled/000-default 只是一个符号链接(symbolic link)的真实文件。默认的 Apache default 文件可能会造成混淆并且包含大量冗余命令。这是我在 Ubuntu 中设置 Apache 时喜欢使用的精简版本:
<VirtualHost *:80>
DocumentRoot /var/www
CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel warn
</VirtualHost>
注意这里没有AllowOverride All。 AllowOverride 的全部目的是允许解析 .htaccess 文件,在这个阶段这不应该成为一个因素。如果您觉得需要,可以像这样将其添加到此配置中:
<VirtualHost *:80>
DocumentRoot /var/www
CustomLog ${APACHE_LOG_DIR}/access.log combined
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
LogLevel warn
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
编辑: 原发布者发布了 ls -la 输出,如下所示:
-rw------- 1 pi www-data 21 May 1 14:10 /var/www/i2.php
这似乎是正确的,但我建议至少尝试调整权限,以便所有人都可以像这样读取该文件:
sudo chmod a+r /var/www/i2.php
此外,在 Apache access.log 中——原始发帖者也在评论中提供——它说:
[Sun May 04 18:00:02 2014] [error] [client 127.0.0.1] PHP Fatal error: Unknown: Failed opening required '/var/www/i2.php' (include_path='.:/usr/share/php:/usr/share/pear') in Unknown on line 0
这让我觉得 i2.php 中的 PHP 编码有错误?你能检查那里的内容吗?也许只是创建一个简单的 PHP 文件,其中包含以下内容以查看会发生什么:
<?php
echo "Hello world!";
?>
总而言之,如果您像这样调整整个 /var/www/ 目录的权限,也许会更好。
sudo chmod -R 755 /var/www/
755 将为所有者应用读取、写入和执行权限,并为组和其他人应用读取和执行权限。 -R 标志表示这应该在整个 /var/www/ 目录和子文件夹中递归。
另一项编辑:查看原始发布者的 access.log 似乎可能存在与 .htaccess 直接相关的权限问题>:
[Sun May 04 17:46:10 2014] [crit] [client 192.168.1.2] (13)Permission denied: /var/www/js/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun May 04 17:46:11 2014] [crit] [client 192.168.1.2] (13)Permission denied: /var/www/js/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun May 04 17:46:11 2014] [crit] [client 192.168.1.2] (13)Permission denied: /var/www/js/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun May 04 17:46:11 2014] [crit] [client 192.168.1.2] (13)Permission denied: /var/www/js/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun May 04 17:46:12 2014] [crit] [client 192.168.1.2] (13)Permission denied: /var/www/js/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun May 04 17:46:12 2014] [crit] [client 192.168.1.2] (13)Permission denied: /var/www/js/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
[Sun May 04 17:46:12 2014] [crit] [client 192.168.1.2] (13)Permission denied: /var/www/js/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
因此,虽然对 /var/www/ 进行全面的权限更改解决了这个问题,但也许权限问题是基于 /var/www/js/.htaccess甚至是父级 /var/www/js/ 目录?我指出这一点的原因是像 sudo chmod -R 755/var/www/ 这样的全面权限更改可以解决问题,但有时最好知道确切的问题出在哪里,这样你对真正发生的事情感到困惑。
关于php - Apache 无法在 Raspberry Pi 上打开页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23458424/
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
使用带有Rails插件的vim,您可以创建一个迁移文件,然后一次性打开该文件吗?textmate也可以这样吗? 最佳答案 你可以使用rails.vim然后做类似的事情::Rgeneratemigratonadd_foo_to_bar插件将打开迁移生成的文件,这正是您想要的。我不能代表textmate。 关于ruby-使用VimRails,您可以创建一个新的迁移文件并一次性打开它吗?,我们在StackOverflow上找到一个类似的问题: https://sta
我对最新版本的Rails有疑问。我创建了一个新应用程序(railsnewMyProject),但我没有脚本/生成,只有脚本/rails,当我输入ruby./script/railsgeneratepluginmy_plugin"Couldnotfindgeneratorplugin.".你知道如何生成插件模板吗?没有这个命令可以创建插件吗?PS:我正在使用Rails3.2.1和ruby1.8.7[universal-darwin11.0] 最佳答案 随着Rails3.2.0的发布,插件生成器已经被移除。查看变更日志here.现在
我尝试运行2.x应用程序。我使用rvm并为此应用程序设置其他版本的ruby:$rvmuseree-1.8.7-head我尝试运行服务器,然后出现很多错误:$script/serverNOTE:Gem.source_indexisdeprecated,useSpecification.Itwillberemovedonorafter2011-11-01.Gem.source_indexcalledfrom/Users/serg/rails_projects_terminal/work_proj/spohelp/config/../vendor/rails/railties/lib/r
我正在尝试在我的centos服务器上安装therubyracer,但遇到了麻烦。$geminstalltherubyracerBuildingnativeextensions.Thiscouldtakeawhile...ERROR:Errorinstallingtherubyracer:ERROR:Failedtobuildgemnativeextension./usr/local/rvm/rubies/ruby-1.9.3-p125/bin/rubyextconf.rbcheckingformain()in-lpthread...yescheckingforv8.h...no***e
我花了三天的时间用头撞墙,试图弄清楚为什么简单的“rake”不能通过我的规范文件。如果您遇到这种情况:任何文件夹路径中都不要有空格!。严重地。事实上,从现在开始,您命名的任何内容都没有空格。这是我的控制台输出:(在/Users/*****/Desktop/LearningRuby/learn_ruby)$rake/Users/*******/Desktop/LearningRuby/learn_ruby/00_hello/hello_spec.rb:116:in`require':cannotloadsuchfile--hello(LoadError) 最佳
我在pry中定义了一个函数:to_s,但我无法调用它。这个方法去哪里了,怎么调用?pry(main)>defto_spry(main)*'hello'pry(main)*endpry(main)>to_s=>"main"我的ruby版本是2.1.2看了一些答案和搜索后,我认为我得到了正确的答案:这个方法用在什么地方?在irb或pry中定义方法时,会转到Object.instance_methods[1]pry(main)>defto_s[1]pry(main)*'hello'[1]pry(main)*end=>:to_s[2]pry(main)>defhello[2]pry(main)
我使用的是Firefox版本36.0.1和Selenium-Webdrivergem版本2.45.0。我能够创建Firefox实例,但无法使用脚本继续进行进一步的操作无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055)错误。有人能帮帮我吗? 最佳答案 我遇到了同样的问题。降级到firefoxv33后一切正常。您可以找到旧版本here 关于ruby-无法在60秒内获得稳定的Firefox连接(127.0.0.1:7055),我们在StackOverflow上找到一个类
当我尝试安装Ruby时遇到此错误。我试过查看this和this但无济于事➜~brewinstallrubyWarning:YouareusingOSX10.12.Wedonotprovidesupportforthispre-releaseversion.Youmayencounterbuildfailuresorotherbreakages.Pleasecreatepull-requestsinsteadoffilingissues.==>Installingdependenciesforruby:readline,libyaml,makedepend==>Installingrub
GivenIamadumbprogrammerandIamusingrspecandIamusingsporkandIwanttodebug...mmm...let'ssaaay,aspecforPhone.那么,我应该把“require'ruby-debug'”行放在哪里,以便在phone_spec.rb的特定点停止处理?(我所要求的只是一个大而粗的箭头,即使是一个有挑战性的程序员也能看到:-3)我已经尝试了很多位置,除非我没有正确测试它们,否则会发生一些奇怪的事情:在spec_helper.rb中的以下位置:require'rubygems'require'spork'