简体   繁体   English

Laravel项目在不运行php artisan的情况下无法在Ubuntu 16.04上运行

[英]Laravel project doesn't run while not running php artisan serve on Ubuntu 16.04

I've a strange problem. 我有一个奇怪的问题。 My laravel project in v5.1 runs successfully after running php artisan serve command in terminal at localhost:8000. 在本地主机:8000的终端中运行php artisan serve命令后,我的v5.1中的laravel项目成功运行。 But the project doesn't run when I access the project with localhost/myproject/public from my browser and shows a blank page. 但是,当我从浏览器使用localhost / myproject / public访问该项目并显示空白页面时,该项目无法运行。 I also tried creating virutal host and access the project from virutual host but without any success. 我还尝试创建虚拟主机并从虚拟主机访问项目,但没有成功。

Can anyone help me how to solve this issue? 谁能帮我解决这个问题?

-Move your project to 'htdocs' or 'www' root folder. -将您的项目移至“ htdocs”或“ www”根文件夹。 -Open public folder and open index.php file and edit these lines : -打开公共文件夹并打开index.php文件,然后编辑以下几行:

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

to these: 这些:

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

so index be able to find 'autoload.php' 这样索引就可以找到“ autoload.php”

and save these edits. 并保存这些修改。 -Now move all files from public folder to 'htdocs' folder. -现在将所有文件从公用文件夹移动到“ htdocs”文件夹。 -run your project in browser whit ' http://localhost ' or ' http://127.0.0.1 ' 在浏览器“ http:// localhost ”或“ http://127.0.0.1 ”中运行项目

I had same problem on Ubuntu 16.04. 我在Ubuntu 16.04上遇到了同样的问题。 solved it by doing : 通过执行以下操作解决了该问题:

  1. Set AllowOverride to All as follows in your default conf file or virtual host conf file AllowOverride All Order allow,deny allow from all 在默认的conf文件或虚拟主机conf文件中,将AllowOverride设置为All,如下所示:AllowOverride All Order allow,deny allow from all

  2. sudo service apache2 restart sudo服务apache2重新启动

You may need to also do sudo a2enmod rewrite to enable module rewrite. 您可能还需要执行sudo a2enmod rewrite以启用模块重写。

Hope this will help you. 希望这会帮助你。

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

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