PHP 설정
***PHP 5.1.x + Apache 2.2*** 설치 방법
설치는 아래 주소 참조.
http://a51.phpweekly.net/#php_apache22
Installing PHP
This part of the tutorial assumes you have Apache2 already installed.
After downloading the two zip files extract the first on (the one WITHOUT "pecl" in it's name) to C:\Server\ (You can choose wahtever folder you like but it's a good idea to have it all in one place.
After extracting it and rename the folder to "php".
Now Extract the second .zip file to C:\Server\php\ext\. Just copy everything.
C:\Server\php and rename the file "php.ini-dist" to "php.ini"
Edit the php.ini:
- Find:
error_reporting = E_ALL & ~E_NOTICE
and change it toerror_reporting = E_ALL
- Find:
display_startup_errors = Off
and change it todisplay_startup_errors = On
- (optional; See Manual)
Find: -
track_errors = Off
and change it totrack_errors = On
- Find:
;arg_separator.output = "&"
and change it toarg_separator.output = "&"
- Find:
register_long_arrays = On
and change it toregister_long_arrays = Off
- (improtant) Magic Quotes are very annoying
Find:magic_quotes_gpc = On
and change it tomagic_quotes_gpc = Off
- (improtant) Extensions (this is needed if you want to use a database... or gd)
Find:extension_dir = "./"
and change it toextension_dir = "C:\Server\php\ext"
It should point to the ext folder. If you've extracted php to another directory the path should be different. - Find:
;extension=php_mbstring.dll
;extension=php_bz2.dll
;extension=php_curl.dll
;extension=php_dba.dll
;extension=php_dbase.dll
;extension=php_exif.dll
;extension=php_fdf.dll
;extension=php_filepro.dll
;extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_ifx.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
;extension=php_mcrypt.dll
;extension=php_mhash.dll
;extension=php_mime_magic.dll
;extension=php_ming.dll
;extension=php_mssql.dll
;extension=php_msql.dll
extension=php_mysql.dll
;extension=php_oci8.dll
;extension=php_openssl.dll
;extension=php_oracle.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll
;extension=php_snmp.dll
;extension=php_sockets.dll
;extension=php_sqlite.dll
;extension=php_sybase_ct.dll
;extension=php_tidy.dll
;extension=php_xmlrpc.dll
;extension=php_xsl.dll
- Note: All extensions as in all that work without additional downloads.
- At the bottom, add:
LoadModule php5_module C:/Server/php/php5apache2.dll
Mind that if you chose to install at a different location the paths should be different.
PHPIniDir C:/Server/php
AddType application/x-httpd-php .php - Find
DirectoryIndex index.html index.html.var
and change it to:DirectoryIndex index.php index.html index.htm index.html.var
Now move to C:\Server\public_html and add a file named "phpinfo.php" with the content:
<?php
phpinfo();
?>
Copy the files shown on the image to C:\Server\Apache2\
그러나 Runs only with PHP 5.1.x with Apache 2.2 할때
# Cannot load php5apache2.dll 에러 발생시 조치 요령
#파일 다운로드 바람.
php5apache2.dll-php5.1.x.zip 5 May '06 14K
apache2handler php5apache2.dll for Apache 2.2.x and PHP 5.1.x
-> p://www.apachelounge.com/download/
#설치 방법
- PHP5.1과 Apache2.2를 사용할때만 쓰기 바람!!!!
- php5apache2.dll 파일을 PHP 설치 폴더에 복사한다.
- httpd.exe.manifest 라는 파일은 아파치 설치 폴더 내에 bin 디렉토리에 복사한다.
- Visual C++ 2005 Redistributable Package 를 설치 한다.
이 패키지는 http://www.microsoft.com/downloads/details.aspx?familyid=32BC1BEE-A3F9-4C13-9C99-220B62A191EE&displaylang=en 에서 다운 로드 받을 수 있으며 이미 .NET framework 2를 설치한 경우라면
생략해도 좋다.
그리고 아파치의 httpd.conf 파일에 다음의 두 줄을 추가한다.
LoadModule php5_module "c:/php/php5apache2.dll"
AddType application/x-httpd-php .php .html
마지막으로 아파치를 재시작한다.
이 파일의 원 저작자는 Steffen이란 사람이다.
갠적으로 무쟈게 고맙게 생각한다.
그리고 다음의 사이트에서 도움을 받을 수 있다.
# binary by: Steffen
# Mail: info@apachelounge.com
# Home: http://www.apachelounge.com/
Warren - http://warren.xsociety.net
If you installed Apache2.2.x you'll have to do this aswell:
PHP's php5apache2.dll was made to work with Apache2.0.x only. You'll need to get the right file and unless you want to compile it yourself you'll have to download it. You'll have to follow the instructions in the readme file that comes with the zipfile. Omit everything after
# Add to your httpd.conf
Do NOT do what is written below that line. You have already done it.
Start Apache by opening the Apache Monitor and clicking start.
If you see messages "Module cannot be found" (you shouldn't) just find the module in php.ini and add a semicolon on the beginning of the line.
If PHP was installed correctly the status bar should show something like this:
Apache/2.0.58 (Win32) PHP/5.1.3
Now visit http://localhost/phpinfo.php (or http://127.0.0.1/phpinfo.php).
If you see information about your PHP install everything should work.
[함수] PHP.INI 내용과 각 옵션의 기능
설정 파일은 총 9개의 항목으로 나누어져 있으며 여기서는 함께 설명하겠습니다.
1. engine - PHP가 아파치 모듈로 설치 되었을 경우 특정 디렉토리에서만 스크립트가 동작하게 합니다.
이것은 아파치 httpd.conf 파일에 아래 항목을 추가합니다.
php_admin_flag engine on(PHP3의 경우 php3_engine on)
2. short_open_tag - php tag 사용여부를 정합니다. XML과 같이 사용할 경우 이 부분은 on으로
해야 합니다.
3. asp_tags - ASP 태그의 사용 여부를 설정합니다.
4. y2k_compliance - y2k 문제에 해당하는 브라우저를 위한 설정입니다.
5. safe_mode - php를 안전 모드로 동작 하게끔 하는 설정입니다.
safe_mode_exec_dir 지시자의 해당 디렉토리에 존재하는 실행 파일이 아닌 경우 실행 되지 않습니다.
(root에 있는 파일만 참조하게 합니다.)
6. safe_mode_exec_dir - 실행 프로그램이 있는 디렉토리 명을 적어 줍니다.
"5번"참고
7. max_execution_time - 스크립트 실행 시간을 초단위로 설정합니다.
8. memory_limit - 스크립트 실행 때 메모리 사용을 설정합니다.
9. error_reporting - 에러 출력을 설정합니다.
에러의 종류
1 - 일반적인 에러 출력(Normal function errors)
2 - 일반적인 에러 출력(Normal warnings)
4 - 문법적인 에러 출력(Parser errors)
8 - 버그의 가능성이 있으며 무시할 수 있는 에러 출력(Notices)
10. display_errors - 에러 상황을 html 양식으로 보여줍니다.
11. log_errors - 여러 가지 에러를 로고 파일에 저장합니다.
12. track_errors - $php_errormsg에 마지막의 에러나 경고 메시지를 저장합니다.
13. warn_plus_overloading - 스크립트에서 문자열 결합사용 때 " . " 연산자를 사용하지만 만약
" + "를 사용했을 경우 경고 메시지 출력 여부를 설정합니다.
14. track_vars - GET, POST, COOKIE 등으로 전달된 변수 값을 각각의 $HTTP_GET_VARS , $HTTP_POST_VARS ,
$HTTP_COOKIE_VARS의 배열 변수로 자동 저장 여부를 설정합니다.
15. magic_quotes_gpc - GET , POST , COOKIE 등으로 전달된 데이터에 ‘ " / 등의 문자가 존재할 경우
자동으로 ()역슬래쉬를 붙일지 여부를 설정합니다. 이것은 각 문자를 스크립트와 구별
해서 인식시키기 위해 필요한 부분입니다.
16. magic_quotes_runtime - 외부 스크립트나 여타 소스로부터 돌아오는 데이터에 대해 ()역슬래쉬를 붙일지
여부를 설정합니다.
17. auto_prepend_file - INCLUDE와 비슷한 부분이고, 스크립트의 처음 부분에 포함될 파일명을 적어 줍니다.
18. auto_append_file - "17번"과 같으며 마지막 부분에 포함될 파일명을 적어 줍니다.
19. include_path - INCLUDE, REQUIRE 문의 파일 경로를 설정합니다.
20. doc_root - 서버의 루트 디렉토리를 설정합니다. 안전 모드로 동작할 경우 해당 디렉토리를 벗어나 다른
쪽으로 접근을 할 수 없습니다.
21. user_dir - 서버의 계정을 가진 일반 유저에 PHP 스크립트의 사용을 허가할 수 있습니다.
22. upload_tmp_dir - 파일이 업로드 될 디렉토리를 설정합니다. 기본적으로 /tmp 디렉토리로 업로드 됩니다.
23. upload_max_filesize - 업로드 할 수 있는 최대 파일 크기를 설정합니다.
24. SMTP - mail( ) 함수의 사용을 위해 현 서버의 DNS , IP를 적어줍니다.
25. sendmail_from - 보내는 메일 주소를 설정할 수 있습니다.
26. sendmail_path - sendmail 서버가 있는 위치를 적어 줍니다.
27. debugger.host - 디버거로 사용하는 호스트 명을 적어 줍니다.
28. debugger.port - 디버거로 사용하는 포트 번호를 적어 줍니다.
29. debugger.enabled - 디버거의 사용 여부를 설정 합니다.
30. session.save_handler - 세션과 해당 데이터를 저장하는 방식을 설정하는 부분입니다. 기본적으로 파일 방식
입니다. 세션 항목은 이 책에 사용되는 회원제 부분에서 사용됩니다.
31. session.save_path - 세션 전달 인수를 정의 하는 부분이며 디폴트인 파일 방식일 경우 해당 파일의 경로를
적어 줍니다.
32. session.name - 쿠키 이름으로 사용되어질 세션 이름을 설정합니다. 디폴트는 PHPSESSID입니다.
33. session.auto_start - 세션 요청 시에 자동 모듈 생성 여부를 설정합니다.
0 - off , 1 - on
34. session.lifetime - 해당 세션이 유지 되는 시간을 설정 합니다.
디폴트의 경우 0이며 사용자의 브라우저가 종료 될 때까지 유지됩니다.
35. session.gc_probability - 해당 세션 값이 제거 될 경우 낭비 되는 시스템 메모리 자원을 반납하는 시점을
설정합니다.
36. session.gc_maxlifetime - 해당 세션의 시스템 메모리 자원 반납을 가질 수 있는 시간을 설정합니다.
php.ini의 magic_quotes_gpc 옵션
흠..
이 옵션이 sql injection에만 문제를 일으키는줄 알았는데
알고보니 include_once 함수에서 php injection을 할때 문제를 일으키는듯 하다.
다른방법을 찾아봐야겠다.. 없으면 그냥 살구 키득~
<!--StartFragment-->; - magic_quotes_gpc = Off [퍼포먼스]
;
; 입력 데이터가 backslash로 이스케이프 되지 않게 되기 때문에
; 이 SQL을 데이타베이스에 보낼 수가 없게 된다.
; 이 설정으로 데이타베이스에 보내고 싶은 경우는
; 그때마다 addslashes() 함수를 사용하도록 한다.