Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve this error on live server for laravel?

I have installed this package success locally composer require spatie/laravel-image-optimizer, but when I tried to install on the live server I got this errors

no@zz607:/var/www/html$  composer require spatie/laravel-image- 
optimizer
Using version ^1.4 for spatie/laravel-image-optimizer
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory

mmap() failed: [12] Cannot allocate memory
PHP Fatal error:  Out of memory (allocated 544395264) (tried to 
allocate 20480 bytes) in 
/usr/share/php/Composer/Repository/ComposerRepository.php on line 321

Fatal error: Out of memory (allocated 544395264) (tried to allocate 
 20480 bytes) in 
 /usr/share/php/Composer/Repository/ComposerRepository.php on line 321

server info enter image description here

like image 897
Mohamed Mostafa Avatar asked Mar 08 '19 19:03

Mohamed Mostafa


People also ask

How do you fix the requested URL was not found on this server in laravel?

Best option is to set /laravel/public as your document root. If you can't do that for whatever reason, you'll need to add a . htaccess file in the laravel directory to rewrite all your requests to the public folder - see here for more info.


1 Answers

You should not call composer require or composer update on production server - you should run it locally, verify that everything works fine, and commit generated composer.lock with your project. Then on production server you need to run only composer install --no-dev - it will install all non-dev dependencies defined in lock file. composer install is much faster and uses fraction of RAM required by composer require or composer update, so it should work fine even on server with low memory. It also gives you more control on version of libraries installed on production server, so you can test app more reliable.

like image 166
rob006 Avatar answered Sep 29 '22 14:09

rob006