如何在AWS免费套餐上安装Laravel? [英] How to install Laravel on AWS free tier?

查看:57
本文介绍了如何在AWS免费套餐上安装Laravel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力在AWS免费套餐Ubuntu实例上安装Laravel.由于内存限制,它卡在Composer安装上.

I am struggling to install Laravel on the AWS free tier Ubuntu instance. It gets stucks on the Composer installation due to a memory limit.

我最初运行以下命令:

sudo apt update && sudo apt upgrade

sudo apt install php7.2-common php7.2-cli php7.2-gd php7.2-mysql php7.2-curl php7.2-intl php7.2-mbstring php7.2-bcmath php7.2-imap php7.2-xml php7.2-zip

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

composer --version

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

我在实例中将存储限制设置为30gb.我试图找到一个解决方案,每个人都建议将Composer限制设置为 =-1 .它仍然无法解决我的问题.

I set the storage limit to 30gb in the instance. I tried to find a solution and everybody suggested to set the Composer limit to =-1. It still didn't resolve my issue.

使用Composer安装软件包时出现此错误:

I got this error when installing packages with Composer:

composer updating dependencies (including require-dev) killed

我试图找到这样的内存限制:

I tried to find the memory limit like this:

 php -r "echo ini_get('memory_limit').PHP_EOL;"  

显示为-1.

我还获得了以下内存信息:

I also got this memory information:

显示内存限制为128M.这是我的问题吗?如果是,那我该如何增加内存?

It showed the memory limit as 128M. Is my issue due to this? If yes, then how can I increase the memory?

我只是想知道我们可以在免费层上安装带有Composer的Laravel.我对此事并不清楚,还是其他配置问题?

I just wanted to know that can we install Laravel with Composer on the free tier. I am not understanding everything clearly on this matter or is it any other configuration issue?

推荐答案

是的,我们可以.

我在 AWS上使用t2.micro Ubuntu 18.04(30GB)(不需要30GB,但我使用了现有的)验证了这一点.

I verified that on AWS using t2.micro Ubuntu 18.04 with 30GB (don't need 30GB, but I used what you have).

对于 laravel 安装,使用了以下命令:

For laravel installation, the following command was used:

composer global require laravel/installer

还出现了内存错误:

The following exception is caused by a lack of memory or swap, or not having swap configured
Check https://getcomposer.org/doc/articles/troubleshooting.md#proc-open-fork-failed-errors for details

In Process.php line 344:

  proc_open(): fork failed - Cannot allocate memory  

根据该消息,我通过遵循

Based on the message, I added 1GB of swap by following these steps.

一旦设置了交换,我将再次执行 laravel 安装命令,这一次它可以工作.

Once the swap was setup, I executed laravel installation command again and this time it worked.

我通过生成标准的 blog 项目测试了新安装的 laravel :

I tested newly installed laravel by generating its standard blog project:

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

该命令有效:

Installing laravel/laravel (v7.12.0)
  - Installing laravel/laravel (v7.12.0): Loading from cache
Created project in blog
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 92 installs, 0 updates, 0 removals
#
# not shown
#
Package manifest generated successfully.
> @php artisan key:generate --ansi
Application key set successfully.

希望这会有所帮助.

p.s.还需要安装 php 和各种 php 扩展.

p.s. Installing php and various php extensions were also required.

这篇关于如何在AWS免费套餐上安装Laravel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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