简体   繁体   English

Laravel虚拟主机显示公共内容而不是应用程序

[英]Laravel virtual host shows content of public instead of the application

I have a laravel 5.4 application in a server, and I get this result when I try to test my app. 我在服务器上有一个laravel 5.4应用程序,当我尝试测试我的应用程序时会得到此结果。

在此处输入图片说明

My virtual host file 我的虚拟主机文件

<VirtualHost *:80>
ServerName plataformafoodif.cl
DocumentRoot "/var/www/html/Plataforma-FoodIf/public"
ServerAlias www.plataformafoodif.cl
 <Directory "/var/www/html/Plataforma-FoodIf/public">
   Options All
   AllowOverride All
   Allow from all
 </Directory>
</VirtualHost>

My index.php file 我的index.php文件

<?php

 require __DIR__.'/../bootstrap/autoload.php';
 $app = require_once __DIR__.'/../bootstrap/app.php';

My .htaccess file 我的.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>

My hosts file 我的主机文件

# Generated by SolusVM
127.0.0.1       localhost localhost.localdomain
::1     localhost localhost.localdomain
# 168.232.167.108       FRESBOX.CL
168.232.167.108 plataformafoodif.cl

Also on my .env I have 在我的.env上我也有

APP_ENV=local
APP_DEBUG=true
APP_KEY=someRandomKey
APP_LOG_LEVE=debug
APP_URL=http://168.232.167.108

Any help would be really appreciated, I have spent many hours trying to fix this 任何帮助将不胜感激,我花了很多时间试图解决这个问题

Hi there can you try this:- 嗨,您可以尝试以下方法:

<VirtualHost *:80>
ServerName plataformafoodif.cl
DocumentRoot "/var/www/html/Plataforma-FoodIf/public"
ServerAlias www.plataformafoodif.cl
 <Directory "/var/www/html/Plataforma-FoodIf">
   Options All
   AllowOverride All
   Allow from all
 </Directory>
</VirtualHost>

and also you have to configure the apache2.config file. 并且您还必须配置apache2.config文件。

<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>

You will find the above code in your apache2.conf file where you add your path to the third directory. 您将在apache2.conf文件中找到上面的代码,在其中将路径添加到第三个目录。

And then reload the apache server. 然后重新加载apache服务器。 I hope this helps your problem. 我希望这可以解决您的问题。

In the end it was this 最后是这个

<IfModule dir_module>
   DirectoryIndex index.html
</IfModule>

I've changed to index.php to match my file on public and i also added the php module line 我已更改为index.php以匹配我的公开文件,并且还添加了php模块行

LoadModule php7_module modules/libphp7.so

Thanks your all your help 谢谢您的全力帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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