禁止您在此服务器*问。Centos 6 / Laravel 4。

时间:2022-12-19 16:51:43

i got a problem after i finish to set up LAMP and installed my laravel 4 application. Everything seem went well, when i go on my ip address url, it show me the first page of my application correctly, but all the rest of the page throw me an 404 error The requested URL was not found on this server.

我在安装完laravel 4应用程序后遇到了一个问题。一切似乎都进行得很顺利,当我打开我的ip地址url时,它正确地显示了我的应用程序的第一页,但是页面的其余部分向我抛出一个404错误,请求的url在这个服务器上没有找到。

So I added to my httpd.conf (under the virtual host of my project) - AllowOverride All Order allow,deny

所以我添加了httpd。conf(在我的项目的虚拟主机下)- AllowOverride所有Order allow,deny

<VirtualHost *:80>
        ServerName VPS-IP-ADDRESS
        DocumentRoot /var/www/html/nextmatch/public_html/public/

       <Directory /var/www/html/nextmatch/public_html/public/>
         AllowOverride all
         Order allow,deny
          <IfModule mod_rewrite.c>
          Options -MultiViews
          RewriteEngine On
          RewriteCond %{REQUEST_FILENAME} !-f
         RewriteRule ^ index.php [L]
       </IfModule>
</Directory>
</VirtualHost>

And now when i try to navigate instead the 404 error i got Forbidden You don't have permission to access this server. I set up with chmod 775 -R path/laravel/ and the folder storage with 777 but still i got the same error any suggest please? I cannot figure out to this problem i'm getting crazy! Thank you for any help.

现在,当我试图导航404错误时,我被禁止了你没有访问这个服务器的权限。我设置了chmod 775 -R路径/laravel/和文件夹存储为777,但我还是得到了相同的错误提示?我搞不懂这个问题,我快疯了!谢谢你的帮助。

5 个解决方案

#1


12  

The webserver starts as a daemon (service) under a particular user. That user is defined in httpd.conf. By default that user will be apache. Don't confuse the apache user with the httpd process. The latter is a webserver daemon and the former is the user under which it is going to run. If the folder you created belongs to root or a user other than the one defined in httpd.conf then apache won't be able to access it. The way to identify this problem is to go to the folder and do ls -l. If the user define in httpd.conf is apache then in order for it to access the folder, you should see:

web服务器以特定用户下的守护进程(服务)启动。该用户在httpd.conf中定义。默认情况下,用户将是apache。不要将apache用户与httpd进程混淆。后者是一个webserver守护进程,前者是它将要运行的用户。如果您创建的文件夹属于root或用户,而不是httpd中定义的用户。conf那么apache将无法访问它。识别这个问题的方法是进入文件夹并执行ls -l。如果用户在httpd中定义。conf是apache,为了让它访问文件夹,您应该看到:

drwxr-xr-x.  2 apache apache    4096 Jan  8  2013 public_folder

Note, it says 'apache apache', meaning it belongs to the apache user and group. If you created it via root then you will probably see:

注意,它是“apache apache apache apache”,意思是它属于apache用户和组。如果您通过root创建它,那么您可能会看到:

drwxr-xr-x.  2 root root    4096 Jan  8  2013 public_folder

The apache user cannot access the folder defined by root. To solve this problem run the command:

apache用户无法访问root定义的文件夹。要解决这个问题,运行以下命令:

chown -R apache:apache myfolder

The -R option is recursive, so it will update ownership for ALL folders and files within that folder to the apache user.

-R选项是递归的,因此它会将该文件夹内所有文件夹和文件的所有权更新给apache用户。

If your ownership if fine, then trying 'temporarily' turning off selinux. On centos you do:

如果你的所有权没问题,那么尝试“暂时”关闭selinux。在centos你该怎么做:

setenforce 0

Which will turn off selinux till the next restart. Ideally, you will want to leave selinux on for additional security and set a valid context for your apache files and folders.

它将关闭selinux直到下一次重新启动。理想情况下,您希望为附加安全性保留selinux,并为apache文件和文件夹设置有效上下文。

If turning off selinux does work, then you probably have the wrong security context for your files and folders. run the following command to restore your security contexts:

如果关闭selinux确实有效,那么您的文件和文件夹可能有错误的安全上下文。运行以下命令来恢复您的安全上下文:

restorecon -R -v /var/www/

#2


8  

If you're using CentOS it could be an issue with selinux. Check to see if selinux is enabled with 'sestatus'. If it is enabled, you can check to see if that is the issue (temporarily) using 'sudo setenforce 0'. If apache can serve the site, then you just need to change the context of the files recursively using 'sudo chcon -R -t httpd_sys_content_t' (you can check the existing context using 'ls -Z'.

如果你使用CentOS,它可能是一个关于selinux的问题。检查selinux是否启用“sestatus”。如果启用了它,您可以检查这是否是使用“sudo setenforce 0”的问题(暂时)。如果apache可以为站点提供服务,那么只需使用“sudo chcon -R -t httpd_sys_content_t”递归地更改文件的上下文(可以使用“ls -Z”检查现有上下文)。

Selinux may not be the issue, but it's worth checking on.

Selinux可能不是问题,但它值得检查。

#3


5  

try this inside the folder:

在文件夹中试试这个:

chcon -R -t httpd_sys_content_t *

#4


2  

chcon -R -t httpd_sys_content_t *

did the trick for me.

这是我的诡计。

#5


0  

from php5.conf in /etc/apache2/mods-available

php5。在/etc/apache2/mods-available相依

# Running PHP scripts in user directories is disabled by default
# 
# To re-enable PHP in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
#<IfModule mod_userdir.c>
#    <Directory /home/*/public_html>
#        php_admin_value engine Off
#    </Directory>
#</IfModule>

#1


12  

The webserver starts as a daemon (service) under a particular user. That user is defined in httpd.conf. By default that user will be apache. Don't confuse the apache user with the httpd process. The latter is a webserver daemon and the former is the user under which it is going to run. If the folder you created belongs to root or a user other than the one defined in httpd.conf then apache won't be able to access it. The way to identify this problem is to go to the folder and do ls -l. If the user define in httpd.conf is apache then in order for it to access the folder, you should see:

web服务器以特定用户下的守护进程(服务)启动。该用户在httpd.conf中定义。默认情况下,用户将是apache。不要将apache用户与httpd进程混淆。后者是一个webserver守护进程,前者是它将要运行的用户。如果您创建的文件夹属于root或用户,而不是httpd中定义的用户。conf那么apache将无法访问它。识别这个问题的方法是进入文件夹并执行ls -l。如果用户在httpd中定义。conf是apache,为了让它访问文件夹,您应该看到:

drwxr-xr-x.  2 apache apache    4096 Jan  8  2013 public_folder

Note, it says 'apache apache', meaning it belongs to the apache user and group. If you created it via root then you will probably see:

注意,它是“apache apache apache apache”,意思是它属于apache用户和组。如果您通过root创建它,那么您可能会看到:

drwxr-xr-x.  2 root root    4096 Jan  8  2013 public_folder

The apache user cannot access the folder defined by root. To solve this problem run the command:

apache用户无法访问root定义的文件夹。要解决这个问题,运行以下命令:

chown -R apache:apache myfolder

The -R option is recursive, so it will update ownership for ALL folders and files within that folder to the apache user.

-R选项是递归的,因此它会将该文件夹内所有文件夹和文件的所有权更新给apache用户。

If your ownership if fine, then trying 'temporarily' turning off selinux. On centos you do:

如果你的所有权没问题,那么尝试“暂时”关闭selinux。在centos你该怎么做:

setenforce 0

Which will turn off selinux till the next restart. Ideally, you will want to leave selinux on for additional security and set a valid context for your apache files and folders.

它将关闭selinux直到下一次重新启动。理想情况下,您希望为附加安全性保留selinux,并为apache文件和文件夹设置有效上下文。

If turning off selinux does work, then you probably have the wrong security context for your files and folders. run the following command to restore your security contexts:

如果关闭selinux确实有效,那么您的文件和文件夹可能有错误的安全上下文。运行以下命令来恢复您的安全上下文:

restorecon -R -v /var/www/

#2


8  

If you're using CentOS it could be an issue with selinux. Check to see if selinux is enabled with 'sestatus'. If it is enabled, you can check to see if that is the issue (temporarily) using 'sudo setenforce 0'. If apache can serve the site, then you just need to change the context of the files recursively using 'sudo chcon -R -t httpd_sys_content_t' (you can check the existing context using 'ls -Z'.

如果你使用CentOS,它可能是一个关于selinux的问题。检查selinux是否启用“sestatus”。如果启用了它,您可以检查这是否是使用“sudo setenforce 0”的问题(暂时)。如果apache可以为站点提供服务,那么只需使用“sudo chcon -R -t httpd_sys_content_t”递归地更改文件的上下文(可以使用“ls -Z”检查现有上下文)。

Selinux may not be the issue, but it's worth checking on.

Selinux可能不是问题,但它值得检查。

#3


5  

try this inside the folder:

在文件夹中试试这个:

chcon -R -t httpd_sys_content_t *

#4


2  

chcon -R -t httpd_sys_content_t *

did the trick for me.

这是我的诡计。

#5


0  

from php5.conf in /etc/apache2/mods-available

php5。在/etc/apache2/mods-available相依

# Running PHP scripts in user directories is disabled by default
# 
# To re-enable PHP in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
#<IfModule mod_userdir.c>
#    <Directory /home/*/public_html>
#        php_admin_value engine Off
#    </Directory>
#</IfModule>