Hi @richb201, sorry for the delay on getting back to you.
I put the required variables in /opt/bitnami/php/etc/php-fpm.conf. Here is
the new version. I modified the keys in this email (for security).
When I do type env at the CLI command, I do not see the the two env
That is because the environment variables you added are only available to applications running with PHP-FPM, e.g. WordPress.
If you want an environment variable to be available in your command-line interface, you need to add them to
Then, after you logout and login again, the environment variable should be present.
Well, I am back to environment variables. I set credentials via the credentials at /home/.aws/bitnami/ but it is not working. So I am back to setting the environment variables. The are two I need to set. What file do I put them in? And how to set them? env['access_key']=xxx?
It seems you have installed AWS's cloud tools (for the "aws" command). If that is the case, you should refer to the official documentation: https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html
They refer to
~/.aws/credentials for storing the credentials, so you should be using
I have aws support also looking at this. It seems that my php app, running as user bitnami(?) appears as user AmazonLightsailInstanceRole to dynamodb, instead of me (again, am I user bitnami?). I was not aware that my php app had an owner. How can I confirm who is the "owner" of my app? As I said, "aws configure list" in the cli shows my correct credentials. I wasn't aware that there was anything other than my credentials needed to interact with dynamodb. If I hard code them into my php code, it works fine, although that is a security hole. What to do? It seems to be a problem with the /.aws/bitnami/credentials file, although the "aws configure list" shows them correctly.
If you need to specify the credentials for your PHP application as environment variables, please modify the files below depending on how your PHP app is running:
- If it is running with PHP-FPM (default Lightsail configuration): Add the environment variable to
/opt/bitnami/php/etc/php-fpm.conf as mentioned previously.
- If it is running with mod_php: Add the environment variable to
/opt/bitnami/apache2/bin/envvars as mentioned in the post you linked.
Note that you will not be able to see the value of the environment variables in your CLI. In order to do that, you will have to edit
If you want to test that your PHP application can access the AWS credentials, I suggest you create a sample PHP program for printing the access id:
<?php echo 'MYVAR='.getenv('MYVAR');
When you access your page's envtest.php, you should get something like:
$ curl http://localhost/kk.php
IMPORTANT: Before changing the environment variable, you need to restart PHP-FPM or Apache, depending if you are using PHP-FPM or not, respectively:
$ sudo /opt/bitnami/ctlscript.sh restart apache
NOTE: We're supposing your application is using the default configuration for apps, which runs at
If that is not the case, you may want to make sure the
/opt/bitnami/apps/APPNAME/conf/php-fpm/php-settings.conf has the environment variable set instead.
Hope it works!