호스팅 업체의 php.ini 설정을 넘어서는 방법이 궁금합니다.

nike984의 이미지

현재 cafe24에 홈페이지를 운영하고 있고 CMS 프로그램을 돌리고 있는데
관련 포럼에 보니 php.ini의 register_globals을 off 상태로 세팅하는 것이
안전하다고 해서 어떻게 대처하고 싶은데 호스팅 업체에서 php.ini에 해당 파라미터를
on 상태로 설정해두었더군요. 그걸 어떻게 바꾸긴 힘들 것 같고
이것저것 찾아보니 각 하위 폴더에 새로운 php.ini 파일을 만들어 두면 호스팅 업체에서
설정한 값을 override 할 수 있다고 들었습니다. 그렇게 해주는 스크립트도 있는것 같고요.
근데 제가 지식이 일천하여 잘 못 알아먹겠더군요.
밑에 내용 보고 좀 설명을 해주실 수 있으시면 감사하겠습니다.

포럼에 있는 내용을 아래부분에 첨부했습니다.
=======================================================================================
I have joomla sites hosted at site5, which runs PHP in cgi mode, supposedly for security.
The default php.ini for the server runs with register_globas=off

To secure your apps, this means that you have to have a php.ini file inside of every directory of your application. This is a major pain, but there is a great solution!

A guy there came up with two great scripts that let you take care of the issue:
1) copy your server's default php.ini - if you don't do this you will cause more damage than doing nothing
2) add the custom features you need in this php.ini
3) copy it across your site with script

http://tips-scripts.com/?tip=php_ini
http://tips-scripts.com/?tip=php_ini_copy
http://tips-scripts.com/?tip=php_ini_delete

I did this after a dotproject app was hacked, and realized how register_globals = ON is dangerous, so i went through all apps to do this. Now I do this as a rule for every app.

So the custom settings would be:

; USER MODIFIED PARAMETERS FOLLOW
register_globals = Off
session.use_trans_sid = 0

And make sure you save CHMOD the php.ini to 0600 before you copy it across the site with the script. (I use winscp to edit the file directly from my desktop, or from putty, not sure if 0600 is too restrictive if you use other methods)

송효진의 이미지

.htaccess

php_admin_value register_globals 0

거의 모든 설정값이 이런식으로 가능하지만,
보안상 막아둔것도 몇몇 있습니다.(안된다고 써있고 되는것도 있더군요.)

emerge money

7339989b62a014c4ce6e31b3540bc7b5f06455024f22753f6235c935e8e5의 이미지

register_globals의 경우, 강제로 변수를 unset해주는 방법도 있습니다.

<?php
if (@ini_get('register_globals')) {
foreach ($_REQUEST as $k => $v) {
unset($$k);
}
}
?>