I'm creating a server in amazon and I'm having an error that I can not solve.
the image of my error:
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.
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');
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
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
Related
I have a Laravel/Homestead project that is finally working locally. Now I'm trying to port it over to HostGator and can't get it running due to titled error. I've tried all the suggested solutions to no avail. Including:
composer require laravel/laravel
composer dump-autoload
composer install --no-scripts
composer update
composer update --no-scripts
Nothing works. Same error. If this is a clue, I also tried
php artisan clear-compiled
and get response of
Could not open input file: artisan
I'm about ready to give up on Laravel/Homestead. I've spent countless hours on this framework with nothing but problems to show for it. Would not recommend it to anybody.
You can see the error yourself here:
http://www.tekknow.net/MedAverter/medaverter/
Any suggestions before I throw in the towel?
For the artisan file, the artisan file is not required through includes, you have it in your root project, which is created when you create your Laravel project. Here is the file.
So you need to have that file in your project.
For the missing class, you try to require laravel/laravel but that is not the correct dependency. Again that github repo is a shell for a project, to have Laravel features you need to base of laravel/laravel and include laravel/framework.
Hope this clears up some confusing and can get you on the right track. Secondly you shouldn't port it over, but simply cloning your project and running composer install should be sufficient.
The problem turned out to be two issues.
1. The wrong version of PHP was running. If I ssh'ed into the hostgator server and did
php -v
It showed PHP 5.6.30 even though I had selected Php 7.1 in the cPanel PHP Selector. If I did
tekknow.net/phpinfo.php
it would say I was using 7.1. Called up HostGator tech support and they were able to change it to PHP 7.3.13.
Now if I do:
php artisan clear cache
I no longer get the error about
Parse error: syntax error, unexpected '?' in
/home1/sl1k7f3j/public_html/medaverter/bootstrap/app.php on line 15
which was an error caused by a version of php that doesn't support the ?? operator.
The second problem was a lack of memory issue. If I did
composer update
It would start to work but would fail in about 30 seconds with
Fatal error: Out of memory (allocated 709623808) (tried to allocate
34187559 bytes) in
phar:///opt/cpanel/composer/bin/composer/src/Composer/Json/JsonFile.php
on line 270
The HostGator tech rep could not figure out why that was happening but I got around that issue by manually uploading my local vendor folder to the host server.
Now when I go to http://tekknow.net/medaverter/ it works!
Nowhere on the internet have I seen anyone have this issue, but I pretty much can't change or add any config/package/vendor without restarting my entire Linux server.
Some simple examples:
For Intervention image, I set the driver to Imagick in config/image, in the controller itself Image::configure(['driver' => 'imagick']), AND in the vendor file itself (/vendor/intervention/image/src/...). No matter what, it continued to try to use GD until I restarted the entire server.
I installed the CloudConvert package with Composer, and added it to providers and facades. Nothing at all worked until a total reboot.
Before anyone asks, I've tried:
php artisan cache:clear
php artisan config:cache
deleting the whole cache folder
composer dump-autoload
composer install
composer update
All of the above did nothing at all. I still need to reboot everything. Does this sound familiar to anyone?
Error:
Updating vlucas/phpdotenv (v2.4.0 => v2.5.1): 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
Currently the AWS Instance RAM: 2GB
Though we have fixed the issue by upgrading RAM from 2GB => 4GB but I have few doubts as increasing RAM this should not be the solution for a small site.
Could you please check the following points:
1) What is the recommended memory required by Laravel for updating the packages (composar.phar update)?
2) Does laravel use SWAP memory as well while composer update?
I had the same problem and never found the reason. You could run composer update --profile or even composer update --profile -vvv to have a detailed list of what's going on under the hood. The first one will show you how much memory is used.
It shouldn't be over 600Mb. But still you will run out of memory. As the laravel app goes into maintenance mode, it shouldn't add to it. You could run in a second shell the command top -ac and see what happens there.
The hosting company couldn't help me either as they blamed it on me lol.
But there is a way around. Upload the composer.lock only and on the production server run composer install --no-dev. It will give you a warning about outdated packages. Answer 'yes' and your prod server will be updated without a glitch. This command runs the laravel composer.json scripts commands too and updates the composer.json package versions..
Ideally, composer update is only run on your development environment, when you push your code in AWS server, the command you must use is composer install (which doesn't use too much memory).
If you want to know the difference between update or install, refer to this link: What are the differences between composer update and composer install?
I am trying to install Symfony on CentOS Linux wih PHP 5.6 and cPanel installed.
When I run composer require symfony/assetic-bundle , once adding bundle to the AppKernelphp, symfony (app/console too) stops working and keeps logging this error:
[10-Jun-2016 22:00:57 UTC] PHP Fatal error: Class 'Symfony\Bundle\AsseticBundle\AsseticBundle' not found in /home/avid24/public_html/app/AppKernel.php on line 19
After checking the vendor directory, turns out that composer has downloaded a single compressed file with a random name, I could extract it with unzip. but problem still exists!
This environment works properly on windows and I could easily update symfony and its components using composer.
Any help? Anyone with the same experience ?
Well, I eventually figured out the problem!
I enabled suhosin extension which prevents the composer and other similar command prompt php scripts from a proper execution.
As a temporary solution I copied php.ini and disabled unnecessary extensions and put it next to my project and call composer this way
$php -c ../composer-php.ini ~/composer ......
I'll create a script to make the life easier
I didn't find any resource which describes coexistence of composer and suhosin extension, so I'm not sure if this is the ultimate solution but the root cause is identified.
If anybody makes workaround this subject I'd be more than happy to know about it.
I actually wanted to follow up on this question, but I guess It's better to start a new question.
I installed a fresh copy of my own laravel(5.0), and I tried running php artisan route:list, which works.
Now I have downloaded the compressed repository of a project I want to deploy on a shared hosting enviorment, but when I run php artisan route:list nothing happens.(No error message, nothing). Using this method for hosting the application
The actual problem is php artisan migrate, which also outputs nothing!
Is there a good method for troubleshooting this ?
Could you provide me we some points of failure that I can check ?
Worth mentioning:
I'm no Laravel developer and I have limited time reading up on it.
As LittleFinger suggested, it's possible that artisan is not actually yet installed. When deploying from a repo, Laravel's packages of which the entire framework core is composed, are not included. You should run composer install to install the packages. If you don't have composer installed that can be difficult on shared hosting, but it's usually possible to install it.
You will need to run composer install before you run composer update. Running composer update is not required, unless you want to update to the newest versions of your packages which are allowed by the rules in your composer.json file. This should be done with care in a production environment as new versions of packages could break your app.
Once you've installed the packages, you'll need to set your environment variables (database credentials etc.) by copying the .env.example file to .env and editing it. Once you've done this you'll be able to run php artisan key:generate to generate an encryption key.
After this, your app should work (assuming you've pointed a domain to the /public directory).
I am facing the same issue when I try to run
php artisan migrate or php artisan cache:clear
nothing happen just a blank screen no success no error see the screenshot
after debugging I found a message in error_log in root directory which says.
Fatal Error: Allowed Memory Size
after increasing the memory php artisan commands works fine