在我的linux mint 18.2系统运行apache 2.4上搜索laravel 5.4的过去3天一直在搜索。当apache服务器启动并且我在浏览器中手动键入localhost时,它会显示laravel的默认主页,但是当我尝试通过括号中的实时预览访问它时(实时预览基本URL:http://localhost作为我的laravel项目专业位于/ var / www / html /)但是它会抛出与我的apache配置中的错误相对应的内部服务器错误。所以我在这里提出了我的.htaccess文件,000-default.conf文件在启用了site的目录中apache2和apache2.conf文件: 一件重要的事情:我在/ var / www / html /
下获得了我的项目文件夹1. 000-default.conf(sites-enabled)
<VirtualHost *:80>
ServerName localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/pro/public
<Directory /var/www/html/pro/public>
Options Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
2. apache2.conf
Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf
Include ports.conf
<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>
AccessFileName .htaccess
<FilesMatch "^\.ht">
Require all denied
</FilesMatch>
IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf
Include /etc/phpmyadmin/apache.conf
3 .htaccess (/var/www/html/pro/public/.htaccess)
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
RewriteEngine On
RewriteBase /var/www/html/pro/public/
# 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>
先谢谢你!
答案 0 :(得分:0)
尝试在laravel中为存储和引导文件夹提供读/写权限。如果可以,还可以设置虚拟主机。请参阅here。
答案 1 :(得分:0)
你的所有路线都可以在index.php之后使用,我的意思是如果你的路线的网址是abc,那么它将以http://localhost/index.php/abc
打开。现在您无需更改.htacesss文件中的任何内容。
转到项目根目录并提供读写执行权限,以便laravel能够将文件缓存在 bootstrap / cache 目录中,并能够在存储/中创建日志文件记录目录。
sudo chmod -R 777 bootstrap/cache
sudo chmod -R 777 storage/logs
如果你的项目之后也没有运行,那么有时你也需要同意这个权限。
sudo chmod -R 777 vendor/ storage/
之后运行这三个命令
sudo a2ensite 000-default.conf
sudo a2enmod rewrite
sudo service apache2 restart
您的路线应在localhost之后提供。
希望这会有所帮助:)