PHP를 Apache Dynamic Shared Object (DSO)로 컴파일 하기 ====================================================== 경고사항: 일부 플랫폼에서 DSO 버젼의 Apache/PHP가 불안하다는 보고가 있습니다. 만약 이런 증상이 나타난다면 PHP를 INSTALL 파일에서 설명한 대로 static 형태로 컴파일해 보기 바란다. 또한 만약 여러분이 Apache 1.3.4 버젼을 사용하고 있지 않다면 포기하고 static 형태로 컴파일하기 바란다. 그렇지 않다면 Apache를 업그레이드하도록 한다. 이 파일의 내용: 방식 1: APXS 방식 METHOD 2: --with-shared-apache 방식 문제 해결 방식 1: APXS 방식 ----------------- 이 방식은 PHP를 이미 컴파일/실행되고 있는 Apache 서버에 추가하는 가장 깨끗한 방법이다. 여러분의 서버는 mod_so를 포함하도록 만들어져 있어야 한다.("httpd -l"로 확인할 수 있다.) 또한,'apxs' Perl 스크립트가 설치되어 있고, 원하는 서버 setup을 할 수 있도록 설정되어 있어야 한다. 아래의 Step 1 대로 하면 원하는 서버 setup을 할 수 있다. Step 1: 우선 Apache를 만든다. 이때 반드시 mod_so를 enable시켜야 한다. 다음과 같이 하면 된다. : cd apache-1.3.x ./configure --prefix=/some/path --enable-shared=max make make install Apache 설정 옵션에 대한 자세한 내용은 Apache 배포본에 있는 README.configure 파일을 참조하자. 이제 /some/path/bin/apxs가 어느 디렉토리에 있는가를 확인해 둔다. step 2로 넘어가면 'apxs' 프로그램이 어느 위치에 있는가를 알아야 한다. Step 2: PHP를 만든다. cd php-3.0.x ./configure --with-apxs=/some/path/bin/apxs \ --with-config-file-path=/some/path make make install 물론 여러분이 원하는 모든 옵션을 줄 수 있다. 자세한 옵션의 리스트를 원하면 ./configure --help 명령을 내려본다. Step 3: /some/path/conf/httpd.conf 파일을 편집하여 다음과 같은 라인을 포함 하도록 한다. : AddType application/x-httpd-php3 .php3 물론 원하는 다른 옵션들도 httpd.conf에 설정하도록 한다. 또한 php3.ini-dist 파일도 /some/path/php3.ini로 복사해 두고 원하는 설정을 하도록 한다. Step 4: 서버를 Start/Restart : /some/path/bin/apachectl start or /some/path/bin/apachectl restart or /some/path/bin/apachectl graceful 방식 2: --with-shared-apache 방식 --------------------------------- 이 방식은 위의 방식에 배해 그렇게 깨끗하지 않다. 그러나 여러분이 여러가지 이유로 apxs 방식을 사용하지 못할 경우 유용하게 사용할 수 있다. apxs 방식이 Apache setup에서 'make install'하여 나온 결과 파일만이 필요한데 반해서 이 방식은 PHP를 컴파일하기 위해 완전한 Apache source tree 전체가 필요하다. Step 1: Apache의 ./configure 프로그램을 최소한 한번 실행한다. 전체적인 컴파일을 할 필요는 없고, Apache ./configure 프로그램이 만들어 내는 일부 헤더 파일이 필요하기 때문이다. 이 때 Apache ./configure로 넘겨주는 옵션들은 아무 의미가 없다. Step 2: 이제 PHP를 설정하고, Apache 소스 트리가 어디에 있는가를 가르쳐 준다. 다음과 같은 방식으로 하면 된다. ./configure --with-shared-apache=/some/path/to/src/of/apache-1.3.X \ --with-config-file-path=/some/path make make install 만약 다른 PHP 옵션을 지정해 주려면, 마찬가지로 configure 라인에 추가해 주면 된다. ./configure --help 명력으로 자세한 옵션을 확인하자. Step 3: Apache 만들기 Apache src tree 디렉토리로 이동하여 다음과 같이 실행한다. ./configure --prefix=/some/path \ --activate-module=src/modules/php3/libphp3.a \ --enable-shared=php3 make make install 이미 이전에 만든 Apache가 설치되어 있다면, 이 경우에도 'make install'을 하면 된다. 하지만 --prefix 디렉토리를 다른 임시 디렉토리로 설정하여 만들어진 파일들을 살펴 보는 것을 추천한다. 특히 PHP 모듈을 load하는 httpd.conf의 내용을 잘 살펴보자. 그외에 해야 할 일은 php3에 대한 AddType 라인의 코멘트(첫번째 칸의 #)를 지우는 것이다. 예를 들어 다음과 같이 만든다. : AddType application/x-httpd-php3 .php3 문제 해결 --------- If you are compiling PHP with support for a whole whack of modules and want to load the whole mess dynamically, you may find yourself getting the following error: ld: fatal: too many symbols require `small' PIC references: have 2077, maximum 2048 -- recompile some modules -K PIC. This should not happen on any Intel platforms, but I ran across it on a Sun Sparc box running Solaris. The message which comes from the linker is assuming I am using the native Sun C compiler I guess and suggests I use "-K PIC". This may be correct if you are using that compiler. For gcc the way to fix it is to edit the PHP Makefile and near the top find the line that says: CFLAGS_SHLIB = -fpic and change the "-fpic" to "-fPIC". I would imagine that this would slow things down a bit though and you might want to consider doing a static build instead.