[英]Production.rb not reading environment variables in production
I'm using this action mailer setup for a production application 我正在将这个动作邮件设置用于生产应用程序
config.action_mailer.smtp_settings = {
address: 'smtp.gmail.com',
port: 587,
domain: 'example.com',
user_name: ENV['EMAIL'],
password: ENV['EMAIL_PASSWORD'],
authentication: 'login',
enable_starttls_auto: true
}
On my DigitalOcean droplet (Ubuntu 14.04) I ran 在我的DigitalOcean小滴(Ubuntu 14.04)上,我跑了
export EMAIL="email"
export EMAIL_PASSWORD="password"
However, It's not working. 但是,它不起作用。 I also tried adding them to my
.bashrc
file and that didn't work either. 我也尝试将它们添加到我的
.bashrc
文件中,但也没有用。
I know that other posts might suggest using something like the figaro gem or dotenv, however, I wouldn't really know how to use those gems in my situation. 我知道其他帖子可能会建议使用Figaro gem或dotenv之类的东西,但是,我真的不知道如何在我的情况下使用这些gems。 This application is for a client who wants to use
smtp
for sending emails. 此应用程序适用于想要使用
smtp
发送电子邮件的客户端。 I wouldn't be able to get their credentials and store them on my local machine. 我将无法获取他们的凭据并将其存储在本地计算机上。 Luckily, It's very easy to access the server on DigitalOcean because it has a built-in ssh feature on the website that allows you to access the droplets.
幸运的是,在DigitalOcean上访问服务器非常容易,因为它在网站上具有内置的ssh功能,使您可以访问Droplet。
This means that they would have to manually enter in the lines export EMAIL="theiremailgoeshere"
and the same for the password. 这意味着他们将必须在
export EMAIL="theiremailgoeshere"
行中手动输入密码。 But as stated, this isn't working for some reason 但是如前所述,由于某种原因,这没有用
Any help is appreaciated, thank you so much! 感谢您的帮助,非常感谢!
I don't know if this will help but I'm using a Digital Ocean droplet to host my website. 我不知道这是否有帮助,但是我使用的是Digital Ocean小程序来托管我的网站。 I have an Ubuntu (14.04) image running on it and I'm using Nginx and Passenger.
我正在运行一个Ubuntu(14.04)映像,并且正在使用Nginx和Passenger。
Env vars from ~/.bashrc
are only set for programs that are opened using the bash shell. ~/.bashrc
中的Env vars只为使用bash shell打开的程序设置。 Also there is a problem if you are ssh'ing into the system as one user and your the web server is running as a separate lesser privileged user. 如果您以一个用户的身份进入系统,并且您的Web服务器以单独的低特权用户身份运行,那么也会出现问题。
You can set system wide env vars in Ubuntu in /etc/environment
and /etc/profile.d/*.sh
. 您可以在Ubuntu的
/etc/environment
和/etc/profile.d/*.sh
设置系统范围的 /etc/environment
变量 。 These ENV vars will be set for all users and all shells opened - and even programs opened from the GUI. 这些ENV变量将为所有用户和所有打开的shell(甚至从GUI打开的程序)设置。
However I would recommend you use a more specific key to like MYAPP_EMAIL
avoid potential conflicts. 但是,我建议您使用更特定的密钥,例如
MYAPP_EMAIL
避免潜在的冲突。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.