Created
December 29, 2017 10:17
-
-
Save motsmanish/17719d7e60205463ee0ce77e1340a700 to your computer and use it in GitHub Desktop.
Set Environment variables for Production and Staging server (NGINX, SHELL, CRON, CRONTAB, ENV, CAKEPHP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
######################################## SITUATION ######################################### | |
# Had to set environment variable somewhere in server block or crontab | |
# so different databases are used by the cron function for staging and production environment | |
# and operations are performed based on environment | |
# Tried setting variable in /etc/php/7.0/fpm/pool.d/www.conf, but didnt worked for crons/shells | |
# Also tried setting variable in /etc/environment but no luck for above purpose | |
# I might have missed something in above 2 methods, but below one worked for me. | |
############################################################################################## | |
SHELL=/bin/sh | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin | |
#... After crontab variables ...# | |
# Set environment variables for production | |
APP_ENV=production | |
[email protected] | |
* * * * * www-data cd /var/www/html/example.com/code/bin && ./cake app main >/dev/null 2>&1 | |
# Overwrite the ENVIRONMENT variables for staging | |
APP_ENV=staging | |
[email protected] | |
* * * * * www-data cd /var/www/html/example.com/code/bin && ./cake app main >/dev/null 2>&1 | |
# Done. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment