I am facing Token mismatch exception in Laravel 5.4 on live server. On my local machine running Windows XAMPP, the application works fine. When I deployed it to live machine running CENTOS 7 and LAMP stack, I see a redirecting to myhostname.com/login at the top left corner of the browser and then lands on an error page showing:
token mismatch exception on line 68 of VerifyCsrfToken.php.
I had this same problem and what i did was:
First in your .env file remove: SESSION_DOMAIN
And in set session driver like: SESSION_DRIVER=file (if your want it to save to a file)
then do: php artisan cache:clear
then `php artisan config:clear
that worked for me.
Try to clear config cache on the server with :
artisan cache:config
You will need to clear config cache also if you edited config/app.php for some reason.
In addition there is an other possible reason : you copied not only the application but also the cache/session files when you deployed your application to production. Basically everything in the storage folder should be ignored on deployment.
Run this command
php artisan config:clear
Verify .env file
delete current .env file and create new .env file from .env.example
verify that config/session.php has is correct or not modified.
You can check the file permission as well of storage directory
Related
I'm building a Laravel 9 app using Docker.
I'm just starting, so I merely updated the APP_URL variable in the .env (from "http://localhost" to "http://mydomain.local").
After this, I ran the following commands:
php artisan cache:clear
php artisan config:clear
php artisan route:clear
composer dump-autoload
and I restarted the Docker container of the app.
Yet, when I access http://mydomain.local in my browser, the app doesn't load. It still loads properly when I user http://localhost as originally configured.
What am I missing?
This is because you probably didnt edit the vhost..
Just changing the APP_URL in the .env file doesnt change how the browser resolves a domain name.
See this thread to learn how to edit a vhost file: WAMP Server virtual hosts configuration
I have deployed laravel project to shared hosting but it returns HTTP error 500.
I will shortly describe to you all steps I have done and if there is mistake pls help :)
So here we go...
-I have run composer install --optimize-autoloader --no-dev
-I have run PHP artisan config:cache then PHP artisan config:clear
-After that I have run npm run prod and exported refreshed database with seeded admin acc
-In cPanel I have created database (from .env) and a username and his password (and added all that to .env)
Also, I have connected that admin acc and database successfully :)
-Then I have imported refreshed database in DB that I have just made on cPanel
-All files from the public folder I have uploaded to public_html
-And all folders and files (except public) I have created a new folder in the root and uploaded the rest of the project there
-After that, I went back to public_html/index.php and changed the path of 2 lines:
1. require DIR
2. $app = require_once
So instead of
require __DIR__.'/../vendor/autoload.php
I have put
require __DIR__.'/../folder_name_where_rest_of_app_is/vendor/autoload.php
And, same is done for $app line ...
Saved latest changes and then I have tried to refresh the site and it just throws HTTP Error 500
PS: Also I have added these lines
APP_ENV=production
APP_DEBUG=false
And on APP_URL is the copied URL from the browser...
If anywhere you can see any mistakes please tell me :)
try this
php artisan optimize:clear
composer dump-autoload
There are many possibilities.
To debug, limit access with something like HTTP basic auth or IP access control and turn on APP_DEBUG.
Check the log files in storage/logs/ and the web server logs.
Make sure the environment has an encryption key set. If not run:
php artisan key:generate
I uploaded all laravel project on server, its working fine on local but getting error on server, even database configuration and key is configured in env. file. even i renamed .env.example file as .env too but got same error.
Error is
"Whoops, looks like something went wrong."
my error log is here:
[2017-11-06 15:19:07] local.ERROR: exception 'RuntimeException' with
message 'The only supported ciphers are AES-128-CBC and AES-256-CBC
with the correct key lengths.' in
/home/rndspot5/public_html/dev/lea/vendor/laravel/framework/src/Illuminate/Encryption/Encrypter.php:43
Judging from your error, you need to run php artisan key:generate this will update your key of which in turn will rectify your error.
You will need to either SSH into your public_html folder if you have host permission to do so. Alternatively, you can ask your host provider to either:
Grant you SSH access
Perform this action for you.
You can then run: php artisan config:clear once the new key has been generated.
If you are on shared hosting you can use these steps
Open your .env file, copy APP_KEY to somewhere else as a backup
Run php artisan key:generate from console
Copy the new APP_KEY and upload it to the .env file on your (shared) server
Move the old key back to development
I resolved this issue, by adding web app url in .env and Config/App.php and now its working :) thanks all of you for sharing such a value able knowledge that will help me, may be later.
hi there is problem with me I had made complete admin panel using laravel backpack. after uploading on domain its creating the problem when adding deleting or editing operation performs. Error is token mismatching in backpack crud system. please tell the problem with my project
I think you have issue with storage folder permission check this out Laravel Installation Docs
Directory Permissions
After installing Laravel, you may need to configure some permissions.
Directories within the storage and the bootstrap/cache directories
should be writable by your web server or Laravel will not run. If you
are using the Homestead virtual machine, these permissions should
already be set.
Another possible issue is that your variables in .env are not correct
APP_URL=http://localhost //Change this to your url
APP_ENV=local //Change this to production
After you check these things you can do this
Delete all files in app/storage/ files : cache/, sessions/, and views/
Or you can do it by using this commands if you have SSH access to the server
php artisan cache:clear
php artisan view:clear
php artisan route:clear
I have been working on a laravel5 project on a computer , but now I want to continue on an other, but don't know how :(
I'm using wampserver and the project is in the "www" folder, this is the error I'm getting when trying to open the project: " Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request"
Your error message is very vague, so it is hard to pinpoint the cause. I assume you just copy pasted all of the project files
Try these steps:
Make sure you copy all of the project files including the hidden ones(.env).
Prepare your destination computer as in http://laravel.com/docs/
Check you have all the necessary PHP extensions available in php.ini as in above link requirements. Also, watch your PHP version!
Install composer https://getcomposer.org/doc/00-intro.md
When copied, go to your destination folder and run composer install.
Run php artisan key:generate from the command line.
Run php artisan cache:clear from command line
http://php.net/manual/en/install.windows.commandline.php
Make sure your webserver is serving pages from project/public folder.
If laravel is failing, check the log file to see the cause
your_project/storage/logs/laravel.log
Copy the project folder and navigate terminal/cmd
just run following commands.
Create database and place the same name at .env file in laravel project folder
1. composer install
2. php artisan key:generate
3. php artisan cache:clear
4. php artisan migrate
UPDATE: If you're getting
Whoops, looks like something went wrong
in app/config/app.php, set debugging as true with:
'debug' => env('APP_DEBUG', true)'
If you're getting the error
No supported encrypter found. The cipher and/or key length are invalid
for some people it worked to do cp .env.example .env before (2).
You would also have to create new storage link, because Laravel uses absolute path inside it.
php artisan storage:link
https://stackoverflow.com/a/32722141/3982831 Please follow this to resolve your problems. All people forget about permissions on folders.
After you have done as Ademord answer, you might need to use refresh to your WAMP, XAMP or any other development stack you are using. I had the same issue plus changes were not reflecting in the front end. For example new routes in the web.php were not updating.