Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the .env file into the remote host server

Quick question how to get the .env conf file into the server. I have three settings file in my project base, development, production. I think testing and staging is an overkill

It is encouraged to put .env in .gitignore file. so it won't be included in version control. in Heroku, it is easy to set the environment variable in the settings tab. what about other hosting services without such a feature? since I push to my repository and pull from the server, How I am I suppose to get the API keys stored in the .env since it will ignore it (it's in gitignore) file? should I create in the server? or is there a way it is done? Newbie question I know.

like image 761
Martins Avatar asked Jun 29 '19 13:06

Martins


People also ask

How do I add an env file to my server?

You should put your . env file in . gitignore and create . env file on server manually - either by connecting to server (SSH) and creating file or transfer file using one of secure transfer protocols (SCP, SFTP).

Where do I put an .env file?

You can create an. env file in the application's root directory that contains key/value pairs defining the project's required environment variables.

How do I set up an .env file?

You can create a . env file in the root directory of the application, which contains key/value pairs defining the needed environment variables for your project. This . env file is then read by the dotenv library and appended to process.


1 Answers

You are correct. You should put your .env file in .gitignore and create .env file on server manually - either by connecting to server (SSH) and creating file or transfer file using one of secure transfer protocols (SCP, SFTP).

like image 99
kostans3k Avatar answered Oct 12 '22 12:10

kostans3k