So I recently had a security issue with my website (supposedly because of an outdated version or Livewire), which prompted me to update it. I went from Laravel 10 to Laravel 11, everything works fine locally and when I uploaded it on my shared hosting, it doesn't.
I have a couple of issues, probably linked:
When I go to my homepage, I get this error: "SQLSTATE[HY000] [2002] No such file or directory"
My MySQL server didn't change in the process, credentials in .env file are the same, so I don't really get the issue.
Even weirder: in my public folder, the "logs" folder is generated with an absolute path for the name:
"C:\Users[my name][my website]\storage\logs"
I also have a shared webhosting, but I don't need to put the public directory of the Laravel project inside a specific folder. So no need to change anything with the structure of the project, I just have to point the domain name to the public folder of the Laravel project and it's done.
So I think that it depends what you have to do to get it working on your webhosting.
It's the same webhosting, really I just updated the files. Nothing changed on the server, nothing on the MySQL database, everything stayed the same, I just uploaded the updated version of the site from local (which is working fine) on my server. I didn't have to change anything with the structure too, it's pointing to the public folder as it should.
Sorry if I'm not being clear, English is not my first language and I honestly don't have a clue at what went wrong.
@exoseed Without knowing your codebase or how you’re actually deploying your site to shared hosting, you’re going to need to view your application’s error logs for more information on what’s going wrong. Or alternatively, just do a fresh upload of your codebase. However, be sure to back up anything like user-uploaded files if you’re storing them somewhere like your /storage directory instead of a third-party storage solution like S3.
Yes I did backup user-uploaded files. My process was:
Backup user-uploaded files
Remove everything from server (since I feared some malicious files might be hidden here and there, I'd rather start clean)
I ran npm run build locally and then reupload the entire files to the server, with the correct production .env and reuploading backudep files from step 1
Even weirder: in my public folder, the "logs" folder is generated with an absolute path for the name: "C:\Users[my name][my website]\storage\logs"
Are you developing locally on Windows but deploying to a Linux server? If so, then this is definitely a cache issue: you executed some cache command on your local machine, then copied the compiled cache files to the production server. Linux tries to use your locally configured log path, but doesn't understand the Windows-style path name, hence the weird filename.
Try running php artisan optimize on the production server. That recompiles several caches (config, routes, etc.) using the environment variables of your live server. If that also fails, clear the previous caches first by running php artisan optimize:clear.
Yes, that makes sense. Should have thought of that. Only issue with proceeding with your solution is that I don't think I can run php artisan commands on the production server which is a shared hosting. Is there any workaround?
I'd be really surprised if you couldn't run PHP. How would you even deploy the app without it? How would you run migrations, scheduled tasks, or queue workers?