如何在cPanel共享主机上上传laravel项目? [英] How do I upload a laravel project on cPanel shared hosting?

查看:47
本文介绍了如何在cPanel共享主机上上传laravel项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用cPanel上传我的网站的简单订阅页面.我将文件上传到 public_html ,将文件从 public 文件夹中移出并修改了 index.php ,使其指向应用程序.我用来为该应用程序编写代码的PHP版本是 7.3 ,但是我必须在主机中选择7.2版本,因为这是最新版本.

加载网站时,出现此错误此页面无法正常运行,bazzaar.net当前无法处理此请求.HTTP错误500"

当我从index.php文件中删除所有内容并添加页面加载的简单回显时.

我真的需要这个.错误日志如下:

堆栈跟踪:

 #0/home3/bazzaar/public_html/vendor/symfony/http-foundation/Response.php(198):Symfony \ Component \ HttpFoundation \ Response-> setStatusCode(500)#1/home3/bazzaar/public_html/vendor/symfony/http-foundation/Response.php(214):Symfony\Component\HttpFoundation\Response->__construct('<!doctype html> ...',500,大批)#2/home3/bazzaar/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(328):Symfony\Component\HttpFoundation\Response::create('<!doctype html>..',500,数组)#3/home3/bazzaar/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(305):Illuminate\Foundation\Exceptions\Handler->convertExceptionToResponse(Object(Symfony\Component\Er in/home3/bazzaar/public_html/vendor/symfony/http-foundation/Response.php,第450行 

我的 .htacess文件

suPHP_ConfigPath/opt/php72/lib

选项-MultiViews-索引

  RewriteEngine开启#处理授权标头RewriteCond%{HTTP:Authorization}.RewriteRule.*-[E = HTTP_AUTHORIZATION:%{HTTP:Authorization}]#如果不是文件夹,则重定向尾部斜杠...RewriteCond%{REQUEST_FILENAME}!-dRewriteCond%{REQUEST_URI}(.+)/$RewriteRule ^%1 [L,R = 301]#发送请求到前端控制器...RewriteCond%{REQUEST_FILENAME}!-dRewriteCond%{REQUEST_FILENAME}!-fRewriteRule ^ index.php [L] 

#默认使用PHP72

解决方案

假定cpanel没有其他网站,并且您的laravel项目应该是默认项目.

  1. 压缩整个Laravel项目并将数据库导出到sql
  2. 登录cPanel并导航到文件管理器"
  3. 确保您位于根文件夹中,然后单击上传"
  4. 选择您的zip文件,然后等待上传完成
  5. 解压缩上传的文件
  6. 将公共内容移动到 public_html 文件夹
  7. 返回Cpanel并导航至数据库
  8. 创建数据库并添加(如果不存在则创建)数据库用户
  9. 单击您的新数据库,然后单击导入"
  10. 选择导出的SQL文件
  11. 尝试使用域名url访问您的laravel网站

该网站可能会提供更多详细信息

When I remove everything from the index.php file and add a simple echo the page loads.

I really need HELP with this. the error logs are below:

Stack trace:

#0 /home3/bazzaar/public_html/vendor/symfony/http-foundation/Response.php(198): Symfony\Component\HttpFoundation\Response->setStatusCode(500)
#1 /home3/bazzaar/public_html/vendor/symfony/http-foundation/Response.php(214): Symfony\Component\HttpFoundation\Response->__construct('<!doctype html>...', 500, Array)
#2 /home3/bazzaar/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(328): Symfony\Component\HttpFoundation\Response::create('<!doctype html>...', 500, Array)
#3 /home3/bazzaar/public_html/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php(305): Illuminate\Foundation\Exceptions\Handler->convertExceptionToResponse(Object(Symfony\Component\Er in /home3/bazzaar/public_html/vendor/symfony/http-foundation/Response.php on line 450

my .htacess file

suPHP_ConfigPath /opt/php72/lib

Options -MultiViews -Indexes

RewriteEngine On

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]

# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Use PHP72 as default

解决方案

Assuming the cpanel has no other website and your laravel project is supposed to be the default project.

  1. Zip your entire Laravel project and export your DB to sql
  2. Login to cPanel and navigate to File Manager
  3. Ensure you're in the root folder, then click "Upload"
  4. Select your zip file and wait for upload to complete
  5. Unzip the uploaded file
  6. Move the content of public to public_html folder
  7. Go back to Cpanel and navigate to Databases
  8. Created a database and add (create if non exist) a DB user
  9. Click on your fresh DB, and click "Import"
  10. Select your exported SQL file
  11. Try to access your laravel website using the domain url

This website might provide more details https://dev.to/asapabedi/deploying-laravel-5-applications-on-shared-hosting-without-the-use-of-ssh--16a6

这篇关于如何在cPanel共享主机上上传laravel项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆