Linux system variables cannot be access through PHP/Apache. You could set a variable in the Apache Vhost of your site via SetEnv and grab it in Laravel.
You could do
- Apache:
SetEnv DB_Pass dbpassword123
in your Vhost
- Nginx:
fastcgi_param DB_Pass dbpassword123
Example Apache Vhost:
<VirtualHost example.com:80>
ServerAdmin root@mpj.local.dev
DocumentRoot /var/www/html
ServerName mpj.local.dev
SetEnv DB_Pass dbpassword123
<Directory /var/www/html>
AllowOverride All
Require all granted
</Directory>
ErrorLog "/var/log/apache2/error_log"
CustomLog "/var/log/apache2/access_log" common
</VirtualHost>
and fetch the variable DB_Pass
in Laravel with
$dbPass = env('DB_Pass');