I used to use forge for deploying my laravel application to production. I recently deregisted forge and I wanted to deploy via ssh to ubuntu server on my own.
I did composer update and I pull changes to my server via ssh; but after these my application started to give error 500. I did every thing I searched may be useful such as commands below but nothing worked.
does any one know why am I facing is this error? in local environment every thing works properly and my laravel project worked properly before ssh and composer update.
these are the steps I have go through but nothing worked:
deleting vendor folder and reinstalling composer
changing permisions for bootstrap and also for the whole project :
sudo chgrp -R www-data storage bootstrap/cache
sudo chmod -R ug+rwx storage bootstrap/cache
run composer dump-autoload
php artisan config:cache
composer update and sudo composer update
I also tried these commands but none of them worked:
php artisan view:clear
php artisan config:cache
php artisan cache:clear
php artisan config:clear
I am using laravel 8
my .env file also exists and every thing are set there
when I turn on debug mode the error of the application page is like this:
Target class [hash] does not exist.
please helpme if any one has any experience on this problem.
From russia /ivorycoat
delete vendor
composer update
.env.example copy and create .env
php artisan cache:clear
php artisan config:clear
php artisan key:generate
php artisan serve
So, I imported another project from Bitbucket and tried to launch it using php artisan serve, I always get this error:
[LogicException]
Key path "file:///var/www/html/DesignViewer5/storage/oauth-private.key" does not
exist or is not readable
I don't get this error when I make a project myself, I can't run any other command. I tried 'php artisan key:generate', and got the exact same error.
I tried: composer update, and got this:
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
- Updating spatie/laravel-permission (1.11.1 => 1.12.0) Downloading: 100%
Writing lock file
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postUpdate
> php artisan optimize
[LogicException]
Key path "file:///var/www/html/DesignViewer5/storage/oauth-private.key" doe
s not exist or is not readable
Script php artisan optimize handling the post-update-cmd event returned with error code 1
Anyone knows how to fix it? Thanks!
I think that this is due to Laravel Passport, you should try the following command:
php artisan passport:install
This command will create the encryption keys needed to generate secure
access tokens. In addition, the command will create "personal access"
and "password grant" clients which will be used to generate access
tokens
Source: https://laravel.com/docs/5.4/passport
I had the same problem when I updated the composer.I generated the keys again using php artisan passport:keys and it solved the problem
I found the solution
Solution:
In config/app.php I had to comment these lines:
/*Laravel\Passport\PassportServiceProvider::class,
App\Providers\CodeGrantProvider::class,
Spatie\Permission\PermissionServiceProvider::class,*/
Than you need to migrate the whole database again,
than uncomment this line:
Laravel\Passport\PassportServiceProvider::class,
And run php artisan passport:install my application keys weren't working so I had to do:
php artisan config:clear
php artisan key:generate
php artisan config:clear
And than I could do php artisan serve
Thanks!
so sample if you already install passpord and don't config run this command
php artisan passport:keys
If already doesnt install the passport package you must check the docs of passpord in Laravel docs
Step 1:
Only Run if oauth-private.key and oauth-public.key not exists in
storage folder otherwise skip first step..
php artisan passport:install
Step 2:
Clear configration and generate key
php artisan config:clear
php artisan key:generate
php artisan config:clear
Step 3:
Change permission and owner like that :
sudo chown www-data:www-data storage/oauth-*.key
sudo chmod 600 storage/oauth-*.key
Since /storage/*.key is in .gitignore so if you pull the project, that might be missing the key by running php artisan passport:keys will generate new keys for you.
Run: php artisan passport:install.
If get message like "Encryption keys already exist. Use the --force option to overwrite them."
Then run
Run: php artisan config:clear
Run: php artisan key:generate.
And finally
Run: php artisan config:clear
I have removed this bit: Passport::loadKeysFrom(__DIR__.'/../secrets/oauth');
from App\Providers\AuthServiceProvider and it fixed the issue.
https://laravel.com/docs/8.x/passport#deploying-passport
/**
* Register any authentication / authorization services.
*
* #return void
*/
public function boot()
{
$this->registerPolicies();
Passport::routes();
Passport::loadKeysFrom(__DIR__.'/../secrets/oauth');
}
if you use heroku as deployment,
try add this in composer.json at the script line
"post-install-cmd": [
"php artisan clear-compiled",
"chmod -R 777 storage",
"php artisan passport:keys"
]
and then run this command
php artisan passport:install
php artisan config:clear
php artisan optimize
do this commands
sudo chown www-data:www-data storage/oauth-*.key
php artisan passport:install
php artisan config:clear
php artisan key:generate
php artisan config:clear
Don't do this line until you have keys in a specific location for the file
in AuthServiceProvider.php
//Passport::loadKeysFrom('/secret-keys/oauth');
for my after i run composer install passport is already installed so php artisan passport:install does not help.
try to touch new file (oauth-private.key) to storage dir, then run command
php artisan passport:keys --force
this command 'll force override private key you touched and create "aouth-public.key" file. it 'll work fine
Depending on the environment you are using to deploy. If, for example, you are using a Heroku deploy, you may have to remove the folder containing the keys from gitignore before pushing and then later add it back. This worked for me after following the steps above.
firstly, search in oath-private-key in your application folder. copy
it and go to App/provider folder. create a new folder , secret and
oauth like that
App/Provider/Secret/Oauth and paste your oath-private-key here.
I hope it helps you.
For Windows OS. If you have already installed passport, or you are setting up an existing application and then facing this problem then try "php artisan passport:keys"
I am following this tutorial: http://www.findalltogether.com/tutorial/simple-blog-application-in-laravel-5-part-1-setup-database/ to set up a Blog using Laravel.
In the tutorial, it says to make migrations I've to run php artisan make:migration posts. Where do I run this? I tried bash but received the error: Could not open input file: artisan.
I'm on Windows, using xampp - could this be a reason?
Thank you
You have to go in folder where artisan is located (usally root of project) and with CMD or CONSOLE write php artisan make:migration posts
First Navigate to your project directory from command prompt if you have installed the laravel in your project so there should be artisan available you may find by typing "dir" once you find artisan there you should run your respective command. Moreover once you reached to your project directory for testing purpose you may write this line
" php artisan " (without quotes) and press enter you will see all the list of commands available in artisan.
Thanks
I am trying to setup a deployment script for my Laravel 5 app to use with CodeShip but I am having issues with clearing the application cache during the deployment.
By running
php artisan cache:clear
it does not give any errors and says the cache has been cleared but it hasnt, then when I ssh into the box and try to delete the cache manually it says permission is denied, so I need to use sudo which is not ideal as Id like to have this all to run without my intervention. I know this is a permissions issue but I cannot work out a way around it.
Is there a way I can do this or maybe a slightly different method?
You shouldn't delete cache manually. Try to run these commands:
php artisan cache:clear
php artisan view:clear
php artisan route:clear
php artisan config:clear
composer dump-autoload
Try php artisan config:cache
This will do it all for you.
Hope this helps!
I am new to Laravel. I have never used artisan commands. Now I'm trying to install a bundle, but it says to run this commands: php artisan bundle:install charisma and `php artisan bundle:publish. I don't know how to run these commands and WHERE to run these commands for installation. Can anyone please tell me step by step how and where these commands work.
You should run those commands at the terminal.
Let's suppose you have Laravel installed on documents/projects/test.
cd documents/projects/test
php artisan bundle:install charisma