简体   繁体   中英

Configure Apache2 for Laravel 5.1

I use ubuntu server and I install apache2.

I write at laravel.conf:

<VirtualHost *:80>
    ServerName localhost

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/public

    <Directory /var/www/html>
        AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

then I restart Apache2. and wont work...

I also at /html folder create .htaccess:

<IfModule mod_rewrite.c>
RewriteEngine On

RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

also: at /pubic folder I add .htaccess:

 <IfModule mod_rewrite.c>
        <IfModule mod_negotiation.c>
            Options -MultiViews
        </IfModule>

        RewriteEngine On

        # Redirect Trailing Slashes If Not A Folder...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)/$ /$1 [L,R=301]

        # Handle Front Controller...
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
    </IfModule>

and now view folder work... so when I go at: /auth/login everything is fine I see DOMhtml but when I try to click on login after that show me 500 error: 在此处输入图片说明

How I can solve my problem? What is a problem with Apache2 ? How to properly configured them?

Do not change .htaccess . Try this:

<VirtualHost *:80>
    ServerName netracuni.com

    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html/public

    <Directory /var/www/html/public>
        AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Also, set write permissions on storage directory:

chmod -R 775 storage

Restart Apache.

http://laravel-recipes.com/recipes/25/creating-an-apache-virtualhost

If id doens't work, what error does it return?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM