서버관련

자동(auto)으로 php 파일을 include하기

2011. 2. 9. 10:33

모든 php파일에 include를 추가하지 않고, 자동으로 최상단에
특정 php파일을 include한 효과를 줄 수 있습니다.

php.ini 에

auto_prepend_file = /home/httpd/html/include/auto.php

와 같이 추가해주면 됩니다.

아파치에서는 더욱 유연하게 설정됩니다.

httpd.conf 에
php_value auto_prepend_file = /home/httpd/include/auto.php
와 같이 기술하면 되며,
특정 Directory 만 적용한다면 <Directory> 안에 기술하면 되겠네요.ㅎ


nginx 에서는 아래와 같이 적용합니다.

fastcgi_param  PHP_VALUE "auto_prepend_file=/home/httpd/include/auto.php"


 아쉽게도 저는 lighttpd 를 좋아하는데.  lighttpd.conf에는 지원되지 않네요