# Setting RAILS\_ENV before running script/server in the comma

**URL:** <https://www.ruby-forum.com/t/setting-rails-env-before-running-script-server-in-the-comma/65518>\
**Category:** Rails\
**Created:** [February 10, 2006, 8:07pm UTC](https://www.ruby-forum.com/t/setting-rails-env-before-running-script-server-in-the-comma/65518 "2006-02-10T20:07:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fozbaca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f0a364/32.png) [@fozbaca](https://www.ruby-forum.com/u/fozbaca)\
**Post date:** [February 10, 2006, 8:07pm UTC](https://www.ruby-forum.com/t/setting-rails-env-before-running-script-server-in-the-comma/65518/1 "2006-02-10T20:07:33Z")

</div>

I want to set an environment variable before running a script

for example setting

ENV[‘RAILS\_ENV’] = production

in the command line before running script/server so that it would  
start in production mode.

Is there a way to do this from the command line so that I don’t have  
to modify the file?

Thanks,

Brian

–

> **[Salesforce: The Customer Company](https://www.salesforce.com)**
>
> Personalize every experience along the customer journey with the Customer 360. Unify marketing, sales, service, commerce, and IT on the world's #1 CRM.

---

<div class="post-metadata">

**Author:** ![fozbaca](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/f/f0a364/32.png) [@fozbaca](https://www.ruby-forum.com/u/fozbaca)\
**Post date:** [February 10, 2006, 8:15pm UTC](https://www.ruby-forum.com/t/setting-rails-env-before-running-script-server-in-the-comma/65518/2 "2006-02-10T20:15:10Z")

</div>

Hi !

2006/2/10, Brian L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> ENV[‘RAILS\_ENV’] = production

If that is all you want to do, script/server has an option to do just  
that:

script/server -e production

On the other hand, if you want to set other environment variables, you  
might want to create a launcher script:

#!/bin/sh  
export SOME\_VAR=123  
export VAR2=/var/db/root

cd /var/www/app1  
script/server -e production

If you’re on Windows, the same can be done, albeit slightly differently.

Hope that helps !
