Laravel 应用程序上传到服务器后不起作用
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/37259103/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Laravel Application is not working after uploading to the server
提问by Kutumb Kutumb
My laravel Application was working perfect on the local server. But After I uploaded it to my server it is not working. The directory structure of my application is shown in the following image:
我的 Laravel 应用程序在本地服务器上运行良好。但是在我将其上传到我的服务器后,它无法正常工作。我的应用程序的目录结构如下图所示:
And I am getting the following problem. It is automatically redirected to loopback address showing nothing
Here is my php version in the server
这是我在服务器中的 php 版本
回答by Alexey Mezenin
Make sure you have correct web server configuration. You should point web server to a public
directory and restart it.
确保您有正确的 Web 服务器配置。您应该将 Web 服务器指向一个public
目录并重新启动它。
Also, make sure you've set correct permissions on a storage
directory:
另外,请确保您对storage
目录设置了正确的权限:
chmod -R 775 storage
And try to clear all cache:
并尝试清除所有缓存:
php artisan cache:clear
php artisan route:clear
php artisan config:clear
php artisan view:clear
php artisan clear-compiled
回答by ThomasK
I had trouble with this also. What you have to do is put the "public" folder in your "www" directory (or the appropriate public_html folder if you use a virtual machine). Next you have to put the WHOLE application in your var folder in a directory of your choice, lets call it "MySuperCoolFolder". Finally, you have to modify the index.php file. More specifically, these two lines.
我也遇到了这个问题。您需要做的是将“public”文件夹放在您的“www”目录(如果您使用虚拟机,则放在适当的public_html文件夹中)。接下来,您必须将整个应用程序放在您选择的目录中的 var 文件夹中,我们称之为“MySuperCoolFolder”。最后,您必须修改 index.php 文件。更具体地说,这两行。
require __DIR__.'/../bootstrap/autoload.php';
to
到
require __DIR__.'/../MySuperCoolFolder/bootstrap/autoload.php';
and
和
$app = require_once __DIR__.'/../bootstrap/app.php';
to
到
$app = require_once __DIR__.'/../MySuperCoolFolder/bootstrap/app.php';
And that should do it. If it does not work. Go to the documentation and use the .htaccess file they provide. That did the trick for me.
那应该这样做。如果它不起作用。转到文档并使用他们提供的 .htaccess 文件。那对我有用。
Best of Luck!
祝你好运!
参考:https: //medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e#.nvinp0r3e
回答by Mark Walker
Try visiting http://127.0.0.1/Workshop/public_html
尝试访问http://127.0.0.1/Workshop/public_html
There is no index.php or .htaccess in the Workshop folder. These would normally be inside public but looks like you have public_html instead
Workshop 文件夹中没有 index.php 或 .htaccess。这些通常在 public 内,但看起来你有 public_html
回答by Hamza Awan
If you are placing the the Laravel app inside the public_html
or inside a subfolder, you have to set some rules for the .htaccess.
Please refer to this answer:
如果您将 Laravel 应用程序放置在public_html
子文件夹内或子文件夹内,则必须为“.htaccess.
请参阅此答案”设置一些规则:
https://stackoverflow.com/a/30497841/7801507
https://stackoverflow.com/a/30497841/7801507
If you want to install the web app on the root of the server, please place all the content of the application in the root directory and rename the public folder to the public_html
or www
or web
, whatever is the public folder of your domain.
如果您想在服务器的根目录上安装 web 应用程序,请将应用程序的所有内容放在根目录中,并将公共文件夹重命名为public_html
orwww
或web
,无论您域的公共文件夹是什么。