Laravel - Forbidden You don't have permission to access / on this server

前端 未结 24 1524
灰色年华
灰色年华 2020-11-30 02:02

My laravel installation was working fine yesterday but today I get the following error:

Forbidden

You don\'t have permission to access / on this server.

Ad         


        
相关标签:
24条回答
  • 2020-11-30 02:26

    In my case, this error was due to internal links in the server, PHP wasn't able to access those folders unless the proper option for that was added to .htaccess.

    Add the following line after RewriteEngine On:

    Options +FollowSymLinks
    
    0 讨论(0)
  • 2020-11-30 02:27

    For my case was encountering this issue with Laravel 6.x and managed to sort it out by installing an SSL Certificate. Tried playing around with .htaccess but never worked. I'm using the default Laravel 6.x .htaccess file which has the following contents

    <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews -Indexes
        </IfModule>
    
        RewriteEngine On
    
        # Handle Authorization Header
        RewriteCond %{HTTP:Authorization} .
        RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
    
        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_URI} (.+)/$
        RewriteRule ^ %1 [L,R=301]
    
        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </IfModule>
    
    0 讨论(0)
  • 2020-11-30 02:30

    Check your virtual host configuration. For Ubuntu you could find it at /etc/apache2/sites-available/yourlaravel.conf It should be like this:

    <VirtualHost *:80>
    ServerName yourlaravel.com
    DocumentRoot "/path/to/your/laravel/project/public"
    ServerAlias *.yourlaravel.com
    
    <Directory "/path/to/your/laravel/project/public">
        AllowOverride All
        Require all granted
    </Directory>
    

    The key line is Require all granted inside <Directory>.

    Hope it helps!

    0 讨论(0)
  • 2020-11-30 02:33

    In your VirtualHost write the DocumentRoot to point to your Laravel Application in your home directories. In addition you must add the Directory shown below, with your own path:

    <Directory /home/john/Laravel_Projects/links/public/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
        Require all granted
    </Directory>
    

    The second step, you must go to your Laravel Project and run the following command.

    sudo chmod -R 777 storage bootstrap/cache
    

    At the end restart your apache2:

    sudo service apache2 restart
    
    0 讨论(0)
  • 2020-11-30 02:33

    First, update your Virtual Host configuration;

    <VirtualHost *:80>
        ServerName example.com
        DocumentRoot /var/www/html/example-project/public
        <Directory /var/www/html/example-project/public/>
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
    

    Then, change both permission and ownership of the asset as illustrated below.

    $ sudo chgrp -R www-data /var/www/html/example-project
    $ sudo chmod -R 775 /var/www/html/example-project
    
    0 讨论(0)
  • 2020-11-30 02:33

    The problem is the location of the index file (index.php).You must create a symbolic link in the root of the project to public/index.php with the command "ln-s public/index.php index.php"

    0 讨论(0)
提交回复
热议问题