Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6093963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:37:20+00:00 2026-05-23T12:37:20+00:00

I don’t like storing sitewide crypto keys and DB access information under document_root, so

  • 0

I don’t like storing sitewide crypto keys and DB access information under document_root, so I was using Apache’s SetEnv and php.ini files under conf.d to separate these from the codebase. The big question is, which one is better? Inside environment variables under apache vhost files (SetEnv SITEKEY 'oinkoink!') or inside conf.d/xxx.ini files (db_pass="oink?")? Maybe something else?

PROS n CONS:

SetEnv:

+Stored outside DOCUMENT_ROOT

+Only the given vhost has access

-Visible with PHPINFO() – Hacker needs direct access/upload exploit to files

get_cfg_var:

+Stored outside DOCUMENT_ROOT

+Not visible with PHPINFO()

-(VERY BAD) All the defined ini variables are included, so each vhost can query them via (ini_get_all), so not usable in a shared vhost environment

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T12:37:20+00:00Added an answer on May 23, 2026 at 12:37 pm

    As long as *.ini and SetEnv are outside of the web root (document root) it doesn’t matter either way. Just choose whichever you prefer. I like SetEnv, but it’s really just personal preference. It makes more sense to me to use SetEnv since the variables are put into _SERVER. With the .ini, I think it makes more sense to leave it for initialization settings specific to how the code works.

    Not storing under the document root is a good idea to prevent access to possibly secure data.

    Note that phpinfo() will list any server variables that are set, so be very careful about that.

    Finally, if you are including files, make sure that you don’t allow gratuitous ../../ set by the user somehow or they will have access to potentially secure files (even including /etc/passwd!)

    I think your main question is “how secure.” Well, this probably about as secure as you can get without causing major headaches. The php code has access to these variables, so if you print them out they are easily visible, so it depends on how secure your code base is. It might be possible to use LDAP with MySQL, but that sounds like a huge pain.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I don't want PHP errors to display /html, but I want them to display
Don't think that I'm mad, I understand how php works! That being said. I
Don't know a whole lot about streams. Why does the first version work using
I don't know if this has been asked before, but what i'd like to
I don't like Jackson. I want to use ajax but with Google Gson. So
I don't have much PHP experience and I want to know how to best
don't know if this is possible.. I'm using sqlite3 schema: CREATE TABLE docs (id
Don't want to sort the entries. using this does not preserve the order as
I don't know how, bug I've arrived to a tree like this: X1--X2--(a lot
Don't you hate it when you have class Foobar { public: Something& getSomething(int index)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.