简体   繁体   English

在共享主机中设置Laravel

[英]Setup laravel in shared hosting

I'm trying to setup laravel (5.4.12) in shared hosting. 我正在尝试在共享托管中设置laravel(5.4.12)。 Following this tutorial I had deleted my public_html and created soft-link for public_html to public folder of laravel project. 在学习完本教程之后,我删除了public_html并创建了public_html到laravel项目public文件夹的软链接。 I had successfully setup laravel (5.3.29) following the same tutorial for my previous project. 我已经按照上一个项目的相同教程成功设置了laravel(5.3.29)。 But this time when I try to open base url it downloads index.php file of public directory of laravel folder. 但是,这一次,当我尝试打开基本URL它下载index.php laravel文件夹的公共目录中的文件。 Can anyone help me out. 谁能帮我吗。

You can do it without deleting public_html folder. 您可以执行此操作而无需删除public_html文件夹。

for routing to public forlder just add these lines to .htaccess files 路由到公共平台,只需将这些行添加到.htaccess文件中

RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L]

Normally PHP files are downloaded when the web server isn't configured to serve PHP files. 通常,如果未将Web服务器配置为提供PHP文件,则会下载PHP文件。 Sounds like you need to talk to your hosting provider. 听起来您需要与托管服务提供商联系。

Finally found the solution. 终于找到了解决方案。 The issue was with PHP version. 问题出在PHP版本。 I had selected PHP version 7.1.0RC4 ,I changed it to 7.0.12 and the problem is gone. 我选择了PHP版本7.1.0RC4 ,将其更改为7.0.12 ,问题不再存在。

Laravel 5 setup without artisan serve command 没有工匠服务命令的Laravel 5设置

  • Rename the server.php in the your Laravel root folder to index.php 将您Laravel根文件夹中的server.php重命名为index.php

  • copy the .htaccess file from /public directory to your Laravel root folder. 将.htaccess文件从/ public目录复制到Laravel根文件夹。

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

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