3

I'm creating a server in amazon and I'm having an error that I can not solve.

the image of my error:

enter image description here

For those who do not know the command, it just runs a script for creating tables in the database. I do not understand how a simple routine for creating 50 tables in the database can consume as much resource.

The error occurs when I try to run the command: php artisan migrate I have 50 migrations, but I do not believe the problem is the amount of migrations.

For hours I've been looking for a solution on google, but I can not find. I already tried: memory_limit = 128M in the php.ini file and did not solve the problem

On my local machine everything works perfect. I am using a t2micro (free) machine from amazon aws.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Renato Souza de Oliveira
  • 4,236
  • 4
  • 20
  • 31
  • 1
    Open `system monitor` and go to the `resources` tab, re-run PHP and monitor the resources how much is used/you have? – Spoody Jan 14 '18 at 23:51
  • 1
    Try this, it works for me. Check the most voted answer: https://stackoverflow.com/questions/18116261/php-composer-update-cannot-allocate-memory-error-using-laravel-4 – Laerte Jan 14 '18 at 23:54
  • @MehdiBounya Thanks for the answer. I am accessing the server via ssh through the terminal. Can I access the system monitor through the terminal? And the error occurs when I execute the command: php artisan migrate. Will the terminal be able to capture what is consuming memory in the execution of the script? – Renato Souza de Oliveira Jan 14 '18 at 23:57
  • @Laerte I will test. What I do not understand is how a simple command to create the database tables can consume as much resource. I believe there is something wrong that I need to find out. – Renato Souza de Oliveira Jan 15 '18 at 00:00
  • 1
    How do other commands work for you like php artisan route:list ? – Dom DaFonte Jan 15 '18 at 00:01
  • @Dom I tried running the command php artisan route:list and presented the same error. I had not tested other commands before. it seems to me that they are all commands. – Renato Souza de Oliveira Jan 15 '18 at 00:04
  • 1
    @RenatoSouzadeOliveira this seems to flag an issue with your installation as my answer indicates. I’ve had this issue before and I had to recreate my Laravel classes using the commands specified below. I had to stop my nginx mysql and other php-Fpm to give composer the server resources to finish the auto load. Once done it ran fine. – Dom DaFonte Jan 15 '18 at 00:49
  • 1
    Why not try it on a medium or large instance type to see how it behaves? – Rodrigo Murillo Jan 15 '18 at 03:37
  • I moved your solution to a community wiki answer. – Cœur Mar 06 '18 at 14:29

3 Answers3

1

Do you have 'swap' enabled in your aws? and what's your PHP version? because there's a same bug in PHP "5.4.11", and also what's composer version?

I first want to say increase your memory limit from php.ini and check the time limit:

memory_limit =  2 GB ?
set_time_limit(0);
ini_set('memory_limit', '20000M');
Ihab Shoully
  • 2,311
  • 1
  • 20
  • 22
1

Solution by OP.

What was causing the problem was a connection drive for mysql. With this command everything worked:

apt-get install php7.0-mysql
Cœur
  • 37,241
  • 25
  • 195
  • 267
0

Sounds like you have an issue with your laravel installation. This is hard to diagnose without being local to the machine, but try the following commands to clear the cache from composer and laravel:

dump-autoload laravel installation. This regenerates the list of all classes that need to be included in the project

composer dump-autoload

Clear your laravel Installation's cache.

php artisan cache:clear
Dom DaFonte
  • 1,619
  • 14
  • 31
  • 2
    This seems unlikely - I'd expect an error along the lines of "Could not load class XXX" if this were a problem. Are you aware of something that would be stored in the cache that could cause a memory leak? – HPierce Jan 15 '18 at 00:18
  • @HPierce Something I installed today was the laravel broadcast . The broadcast uses the redis. But I did not even install the redis on amazon server. Does the simple fact of being referenced in the laravel compositor already consume memory? – Renato Souza de Oliveira Jan 15 '18 at 00:24
  • 1
    If you can't even run php artisan route:list then it means your installation has an issue. I have 2 databases (one of those databases is 20GB in size) a python application, and 2 web servers hosts on my t2.micro without issue. try running php in interactive mode (php -a) and run a command like phpinfo() in the php command prompt. If that works, then I'd suspect an issue with your laravel installation. – Dom DaFonte Jan 15 '18 at 00:31
  • @RenatoSouzadeOliveira, have you tried the commands I offered? Did they help? – Dom DaFonte Jan 15 '18 at 00:37