简体   繁体   English

与作曲家共享主机上的 Laravel 安装

[英]laravel installation on shared hosting with composer

I'm trying to learn Laravel and follow the instructions in their tutorial to install the framework on my shared hosting.我正在尝试学习 Laravel 并按照他们的教程中的说明在我的共享主机上安装框架。 I've disabled the secure-http option in composer but it still won't download the framework.我在 composer 中禁用了 secure-http 选项,但它仍然不会下载框架。

Called:调用:

composer global require "laravel/installer"

Response:回复:

Changed current directory to /home/sledzko/.composer
Warning: Accessing packagist.org over http which is an insecure protocol.

[LogicException]                                                              
Composer repositories that have providers can not load the complete list of packages, use getProviderNames instead.

What can I do to download the framework using composer?如何使用 composer 下载框架?

Most of the shared hosting is not supported terminal/command access, that why it is not possible to install Laravel using composer on shared hosting.大多数共享主机不支持终端/命令访问,这就是为什么不能在共享主机上使用 composer 安装 Laravel。

But there is a way to use Laravel in shared hosting, you can install/setup Laravel project on a local machine and after that upload project (all directory structure and files) on your shared hosting.但是有一种方法可以在共享主机中使用 Laravel,您可以在本地机器上安装/设置 Laravel 项目,然后在共享主机上上传项目(所有目录结构和文件)。 Only need to adjust public directory and bootstrap path in the index.php file.只需要在 index.php 文件中调整 public 目录和 bootstrap 路径即可。

Upload all files is in public folder in your shared hosting www/public_html folder, and all other folder structure in the separate folder.上传所有文件位于共享主机 www/public_html 文件夹的 public 文件夹中,所有其他文件夹结构位于单独的文件夹中。 After that go to your index.php file in www/public_html folder and update below two linew with your path laravel folder path.之后转到 www/public_html 文件夹中的 index.php 文件,并使用您的路径 laravel 文件夹路径更新下面的两行。

require DIR .'/../bootstrap/autoload.php';需要目录.'/../bootstrap/autoload.php'; $app = require_once DIR .'/../bootstrap/app.php'; $app = require_once DIR .'/../bootstrap/app.php';

  1. Install package locally using Composer.使用 Composer 在本地安装包。 The package folder will be created in the vendor path.包文件夹将在vendor路径中创建。

  2. Copy vendor/packagename folder and paste it into your host's vendor path.复制vendor/packagename文件夹并将其粘贴到主机的vendor路径中。

  3. Replace your host vendor/composer folder with your local vendor/composer folder.将您的主机vendor/composer文件夹替换为您的本地vendor/composer文件夹。
  4. Replace your host composer.json with your local composer.json将您的主机composer.json替换为您本地的composer.json

please try:请尝试:

composer create-project laravel/laravel --prefer-dist YOUR_PROJECT_NAME

This will help you to download the stable version on your machine!这将帮助您在您的机器上下载稳定版本!

If you use SiteGround you will be a lucky man, just must request access do ssh (over cpanel), and then run your composer command on terminal.如果您使用SiteGround,您将是一个幸运的人,只需请求访问 do ssh(通过 cpanel),然后在终端上运行您的composer命令。

SiteGround servers already have composer globally installed. SiteGround服务器已经全局安装了Composer

BUT... you you want to do it on hard way, access you shell on Siteground and run:但是......你想以艰难的方式做到这一点,在 Siteground 上访问你的 shell 并运行:

 wget https://getcomposer.org/composer.phar -O ${HOME}/composer.phar
 echo "alias composer=\"/usr/local/php72/bin/php-cli ${HOME}/composer.phar \"" >> ${HOME}/.bashrc
 source ${HOME}/.bashrc
 composer --version

Just pay attention on php72 version, it's uses PHP 7.2.只关注 php72 版本,它使用的是 PHP 7.2。 If you want or need another one do a ls /usr/local/ to see all versions.如果您想要或需要另一个,请执行ls /usr/local/以查看所有版本。

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

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