php – 403 – Ubuntu 14.04上的权限被拒绝错误 – apache2
这个问题已被多次询问,我已经完成了大部分解决方案,但仍然没有运气.
我正在尝试在新安装的Ubuntu 14.04 LTS版本上创建虚拟主机,由于某种原因我收到以下错误. You don't have permission to access / on this server. 这就是我到目前为止所做的. >在/etc/apache2/sites-available/om.conf中创建了以下虚拟主机 <VirtualHost *:80> ServerAdmin root@localhost ServerName om.localhost.com ServerAlias www.om.localhost.com DocumentRoot "/home/jay/Projects/om/public" <Directory "/home/jay/Projects/om/public"> Options Indexes FollowSymLinks Order allow,deny Allow from all AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> >使用以下命令启用主机 sudo a2ensite om 127.0.0.1 localhost >使用以下命令设置项目目录的权限. sudo chown -R www-data:www-data om >启用重写模块 ???sudo a2enmod重写 >重启apache2 ??sudo service apache2 restart 但我仍然得到同样的错误. 任何人都可以指出我做错了什么? 该项目基于Zend Framework 1.12并使用以下.htaccess文件. SetEnv APPLICATION_ENV "development" RewriteEngine On # The following rule tells Apache that if the requested filename # exists,simply serve it. RewriteCond %{REQUEST_FILENAME} -s [OR] RewriteCond %{REQUEST_FILENAME} -l [OR] RewriteCond %{REQUEST_FILENAME} -d RewriteRule ^.*$- [NC,L] # The following rewrites all other queries to index.php. The # condition ensures that if you are using Apache aliases to do # mass virtual hosting,the base path will be prepended to # allow proper resolution of the index.php file; it will work # in non-aliased environments as well,providing a safe,one-size # fits all solution. RewriteCond %{REQUEST_URI}::$1 ^(/.+)(.+)::$ RewriteRule ^(.*)$- [E=BASE:%1] RewriteRule ^(.*)$%{ENV:BASE}index.php [NC,L] 解决方法
检查您在整个文件路径上的权限.检查Projects文件夹并确保它是755.给它所有者和www-data组不会有什么坏处.如果您有任何.htaccess文件,请确保它们被分配644而不是755.
您也在混合Apache版本指令.由于您使用的是Ubuntu 14.04,因此您可能正在运行2.4.所以你需要删除这些指令. Order allow,deny Allow from all 对于2.4,您只需要要求全部授予. 另外,我会添加一个DirectoryIndex指令,以确保它正在寻找索引文件.如果它不识别一个,它将尝试列出目录并且索引关闭也将导致403禁止错误.要求全部授予后,将其放入目录标记中的vhost中. DirectoryIndex index.php 在某些情况下,SELinux也是令人讨厌的并且也会导致许可问题.如果所有其他方法都失败并且您启用了SELinux,则暂时禁用它以查看它是否修复了您的问题. getenforce 这将告诉你它是否执行. setenforce 0 这将设置为允许,然后您可以测试加载网站.这将是暂时的,无法承受重启.但是你可以使它永久化. 您可以使用chcon命令更改安全上下文.例如 chcon -R --reference=/home/jay/Projects /home/jay/Projects/om/public 随时重新加载/重启apache以进行任何apache配置更改.希望这里的内容有助于解决您的13权限被拒绝问题. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |