WebFaction
Community site: login faq

Hello,

Fresh webfaction user here, and have a question about how to use Environment Variables in a PHP app running on WebFaction. My reason for this is to make setting up development/staging/production variables easier.

So how would I go about setting an environment variable for use in PHP (eg. using getenv('production'); etc... )

Note that this is for an Environment variables access from the PHP interpreter, not from the ssh bash shell.

Normally on my VPS I would just configure this in the Apache envvars conf file and then reboot the server and presto.

Thanks

asked 02 Feb '12, 02:29

Jive
312
accept rate: 0%


Hi,

You can do this by creating a php.ini in your app's directory and using an auto_prepend_file as shown here: http://docs.webfaction.com/software/php.html#id8

permanent link

answered 02 Feb '12, 02:36

neeravk
1.5k3412
accept rate: 41%

Thanks, my googling didn't bring up that documentaion, a good find. Though it doesn't seem like the cleanest solution but atleast it works.

(02 Feb '12, 02:40) Jive
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×265
×11
×1

question asked: 02 Feb '12, 02:29

question was seen: 4,618 times

last updated: 02 Feb '12, 02:40

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2020 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM