I'm facing a problem with my Laravel application. It is deployed on the server and uses nginx
as the main web server.
I am unable to read two files from the path I set in the deployment server, but on the local environment, it is working fine. These two files are confidential, one is .crt
file and second is .pem
file. I placed both of these files in laravel-app/app/Certificates
directory.
laravel-app/app/Certificates/test2-2023_cert.pem
laravel-app/app/Certificates/curl-bundle.crt
The file path in .env
is set like this:
PEM=/Certificates/test2-2023_cert.pem
CRT=/Certificates/curl-bundle.crt
My config/services
file:
<?php
return [
'pay' => [
'pem' => app_path() . env('PEM', ''),
'crt' => app_path() . env('CRT', '')
]
];
My Controller
construct function:
public function __construct()
{
$this->pem = config('services.pay.pem');
$this->crt = config('services.pay.crt');
}
It is returning the following path on server:
/var/www/laravel-app/app/Certificates/test2-2023_cert.pem
/var/www/laravel-app/app/Certificates/curl-bundle.crt
but the server is not loading the file and gives me an error response in the API call. What I'm doing wrong?