[英]Laravel 5.1 on apache2 wont to start
我將laravel文件添加到/var/www/html/laravel3
laravel3文件夾中,之后我更改了apache2.conf文件:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/laravel3
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
...
但是當我嘗試http://mywebsite.com時,我得到了:
未找到
在此服務器上找不到請求的URL / auth / login。
我也從/ laravel3文件夾中刪除.htaccess文件
現在做什么?
在apache2中,我有:
<Directory />
Options FollowSymLinks
AllowOverride None
Require all denied
</Directory>
<Directory /usr/share>
AllowOverride None
Require all granted
</Directory>
<Directory /var/www/html>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
在sites-available / laravel.conf中,我有:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName bedbids.com
DocumentRoot "/var/www/html/laravel3/public"
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory "/var/www/html/laravel3/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
不要刪除.htaccess
文件,它會將請求重寫為index.php
。
對於您的apache配置, DocumentRoot
應該指向公共目錄,並且您應該設置AllowOverride All
,否則htaccess將被忽略。
這應該為您工作:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/laravel3/public
<Directory /var/www/html/laravel3/public/>
AllowOverride All
</Directory>
...
更改之后,重新啟動apache,它應該已啟動並正在運行。
您應該將Apache指向Laravel根目錄內的public
目錄,例如:
DocumentRoot "/var/www/html/laravel3/public"
<Directory "/var/www/html/laravel3/public">
另外,您不應編輯或刪除.htaccess
。
進行這些更改之后,請不要忘記重啟Apache。
更新
原始.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]
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.