title: How do I create environment variables to protect my Google Maps API Key(or any other secret value) for my website?
body: <p>I am learning to code my own website using Bootstrap and have easily placed a map on my page using a Google map API-key and script from Google Developers:</p>
  
  <pre><code>&lt;script async defer
    src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&amp;callback=initMap"&gt;
  &lt;/script&gt;
  </code></pre>
  
  <p>Ideally I would have something like:(i.e. I have tried this): </p>
  
  <p><code>Html: &lt;script src="map-value-pair.php"&gt;&lt;/script&gt;&lt;/script&gt;&lt;script async defer src="$MapURL"&gt;&lt;/script&gt; 
  PHP: &lt;?php $MapURL="maps.googleapis.com/..." ?&gt;</code></p>
  
  <p>So obviously this doesn't hide the URL it prints to the html.</p>
  
  <p>I am not convinced anyone actually tries to hide this key for a basic purpose like mine because the http referrer restriction on Google Developers is sufficient. But, after trying many different approaches to obfuscate the key I have decided I would like to learn to create environment variable to hide values. I think it could be useful and I would like to extend my server-side knowledge. Google best practices also suggests to "store them in environment variables or in files outside of your application's source tree".</p>
  
  <p>I have found a related stack: <a href="https://stackoverflow.com/questions/1364858/what-steps-should-i-take-to-protect-my-google-maps-api-key/35990677">What steps should I take to protect my Google Maps API Key?</a>
  In that stack a related link was given to hackernoon.com (limited links in first post) My hosting service uses cPanel and provides this apache environment variables tutorial: <a href="https://documentation.cpanel.net/display/EA/Environment+Variables" rel="nofollow noreferrer">documentation.cpanel.net...</a></p>
  
  <p>I am having problems finding material to start myself off. Right now I have two potential action plans:</p>
  
  <ol>
  <li>enable ssh on cpanel>follow cPanel tutorial noted above>figure out how to access variable in html</li>
  </ol>
  
  <p>or</p>
  
  <ol start="2">
  <li>enable ssh on cpanel>install node.js somehow>follow something like this on <a href="https://www.twilio.com/blog/2017/08/working-with-environment-variables-in-node-js.html" rel="nofollow noreferrer">twilio</a>>figure out how to access variable in html</li>
  </ol>
  
  <p>Any help or suggestions appreciated. Best case scenario some edits to my action plan with a couple links to check out. I just need some sort of confidence to move forward with one of these plans.</p>
  
  <p>P.S. Woo first post!</p>
  
  <p>EDIT:  Minor cleanup of question. Added ideally script.</p>