When I upgrade to apache 2.2, this:
AddType application/x-httpd-php .php5
AddType application/x-httpd-php .php42
AddType application/x-httpd-php .php4
AddType application/x-httpd-php .php3
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtm
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php .asp
...does not worked for me, so I did this:
<FilesMatch "\.(php*|phtm|phtml|asp|aspx)$">
SetHandler application/x-httpd-php
</FilesMatch>
Another interesting point with Apache 2.2 is following.
Let suppose we installed PHP as module. But for some directory, we need to use PHP as CGI (probably because of custom configuration). This can be done using:
<FilesMatch "\.(php*|phtm|phtml|asp|aspx)$">
SetHandler none
</FilesMatch>
AddType application/x-httpd-php-custom .php
Action application/x-httpd-php-custom /cgi-bin/php-huge
Note type must be different than "application/x-httpd-php" and also you need to deactivate the handler on sertain extention. You can do mixed configuration:
<FilesMatch "\.(php)$">
SetHandler none
</FilesMatch>
AddType application/x-httpd-php-custom .php
Action application/x-httpd-php-custom /cgi-bin/php-huge
in such case files like *.php5 and so on will be parsed via module, but *.php will go to php-huge executable.
유닉스 시스템 아파치 2.0
이 섹션은 유닉스 시스템 아파치 2.0에 특화된 PHP 설치에 관한 정보와 힌트를 담고 있습니다.
제품 환경에서 아파치 2 쓰레드 MPM 사용을 권하지 않습니다. prefork MPM을 사용하거나, Apache 1을 사용하십시오. 이유는 관련 FAQ 아파치2 쓰레드 MPM 사용하기를 읽어보십시오.
아파치 2.0 서버에 대한 이해를 위하여 » 아파치 문서를 살펴보길 권합니다.
Note: PHP와 아파치 2.0.x 호환 노트
다음 버전의 PHP가 최신 버전의 아파치 2.0.x에서 작동합니다:
- » http://www.php.net/downloads.php에서 받을 수 있는 PHP 4.3.0 이후.
- 최신 안정 개발 버전. 소스 코드를 » http://snaps.php.net/php5-latest.tar.gz에서 얻거나 윈도우 바이너리를 » http://snaps.php.net/win32/php5-win32-latest.zip에서 얻을 수 있습니다.
- 릴리즈 예정 버전을 » http://qa.php.net/에서 받을 수 있습니다.
- 언제든지 » 익명 CVS를 통해서 PHP를 받을 수 있습니다.
위 PHP 버전은 아파치 2.0.40 이후에 호환됩니다.
아파치 2.0 SAPI 지원은 PHP 4.2.0부터 시작했습니다. PHP 4.2.3은 아파치 2.0.39에서 작동하며, PHP 4.2.3과 다른 아파치 버전을 사용하지 마십시오. 그러나, 권장하는 설정은 최신 버전의 아파치2와 PHP 4.3.0 이후를 사용하는 것입니다.
언급한 모든 PHP 버전은 아파치 1.3.x에서 잘 동작합니다.
최신 버전의 » 아파치 2.0과 위에서 언급한 위치에서 적합한 PHP 버전을 내려받습니다. 이 빠른 가이드는 아파치 2.0과 PHP를 시작하는 기본적인 내용만 다루고 있습니다. 자세한 정보는 » 아파치 문서를 읽으십시오. 지시가 틀리지 않기 위해서, 여기에서 버전 번호는 제거했습니다. 'NN'을 적합한 값으로 변경해야 합니다.
Example #1 설치 안내 (아파치 2 공유 모듈 버전)
1. gzip -d httpd-2_0_NN.tar.gz
2. tar xvf httpd-2_0_NN.tar
3. gunzip php-NN.tar.gz
4. tar -xvf php-NN.tar
5. cd httpd-2_0_NN
6. ./configure --enable-so
7. make
8. make install
이제 /usr/local/apache2 아래 모듈 적재 지원과 표준 MPM
prefork로 설정한 아파치 2.0.NN이 존재합니다.
설치를 테스트하려면 일반적인 아파치 서버 시작 절차를
사용합니다. 즉:
/usr/local/apache2/bin/apachectl start
그리고 PHP 설정을 위하여 서버를 중단합니다:
/usr/local/apache2/bin/apachectl stop.
9. cd ../php-NN
10. 이제, PHP를 설정합니다. 여기에서 확장을 활성화 하는 등,
PHP를 다양한 다양한 옵션으로 커스터마이즈합니다.
./configure --help 를 실행하여 가능한 옵션 목록을 확인할 수 있습니다.
예제에서는 아파치 2와 MySQL 지원으로 간단히 설정합니다. 실제 apxs
경로는 다를 수 있습니다. 시스템에 따라서 apxs2로 존재하는 경우도
있습니다.
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
11. make
12. make install
설치 후에 설정 옵션을 바꾸려면, 마지막 세 단계만
반복하면 됩니다. 그리고 새 모듈이 효과를 발휘하도록
아파치를 재시작하면 됩니다. 아파치를 다시 컴파일할
필요는 없습니다.
특별히 언급이 없는 한, 'make install'은 PEAR, phpize 같은 다양한
PHP 도구, PHP CLI 등을 함께 설치합니다.
13. php.ini 설치
cp php.ini-dist /usr/local/lib/php.ini
PHP 옵션을 설정하기 위하여 .ini 파일을 수정할 수 있습니다. php.ini를
다른 위치에 놓으려면, 10번째 단계에서 --with-config-file-paht=/some/path
를 사용합니다.
php.ini-recommended를 선택한다면, 안에서 변경 목록을 읽어서,
어떤 PHP 행동에 영향을 주는지 확인하십시오.
14. httpd.conf를 수정하여 PHP 모듈을 적재합니다. LoadModule
구문 우측에서는 시스템의 PHP 모듈 경로를 가르켜야 합니다.
위에서 make install이 이미 이를 추가했을 수도 있지만,
꼭 확인해보십시오.
For PHP 4:
LoadModule php4_module modules/libphp4.so
For PHP 5:
LoadModule php5_module modules/libphp5.so
15. 어떠한 확장자를 PHP로 해석할지 아파치에 알려줍니다. 예를 들어,
아파치가 .php 파일을 PHP로 해석하게 합시다. 단순히 아파치
AddType 지시어를 사용하는 대신, exploit.php.jpg 등의 파일이
업로드되어 PHP로 실행되는 것을 막습니다. 이 예제를 사용하여,
PHP로 해석할 어떠한 확장자라도 단순히 추가할 수 있습니다.
예시를 위해 .phtml을 추가하겠습니다.
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
또는, .php, .php2, .php3, .php4, .php6, .phtml 파일을 PHP로 실행하게
할 수 있습니다. 이렇게 하면 됩니다:
<FilesMatch "\.ph(p[2-6]?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
.phps 파일을 PHP 소스 파일로 실행하려면, 다음을 추가합니다:
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
16. 아파치 서버를 시작하는 정상 절차를 사용합니다, 즉:
/usr/local/apache2/bin/apachectl start
- 또는 -
service httpd restart
위 단계를 따라하면 아파치2 웹 서버를 PHP SAPI 모듈로 실행하게 됩니다. 물론, 아파치와 PHP에는 많은 설정 옵션이 존재합니다. 자세한 정보는 해당 소스 트리에서 ./configuration --help를 쳐 보십시오. 멀티쓰레드 버전의 아파치2를 빌드하려면, 표준 MPM 모듈 prefork를 worker나 perchild로 덮어써야 합니다. 이를 위해서는 위의 6번째 단계에서 --with-mpm=worker나 --with-mpm=perchild 옵션을 추가해야 합니다. 이를 하기 전에, 최소한 이 일이 어떻게 작동하는지와 장단점을 파악하십시오. 자세한 정보는 » MPM 모듈에 관한 아파치 문서를 읽어보십시오.
Note: 내용 협상을 사용하려면, 아파치 MultiViews FAQ를 읽어보십시오.
Note: 아파치 멀티쓰레드 버전을 빌드하려면, 시스템이 쓰레드를 지원해야 합니다. 이 경우 PHP를 실험적인 Zend Thread Safety (ZTS)로 빌드하게 합니다. 그러므로 모든 확장을 사용할 수 없습니다. 권장하는 설치는 아파치를 표준 prefork MPM 모듈로 빌드하는 것입니다.
유닉스 시스템 아파치 2.0
10-Aug-2009 05:13
17-Jun-2009 02:58
Solution for fedora is yum install mysql-devel. Then set --with-mysql=/usr/include/mysql/
monguesto
24-Apr-2009 02:09
Configuration notes for cent5.2, April 2009.
----------------------------------------------------
Note: I'll walk you through my steps, so you can do it custom yerself. It's possible that I am an idiot and there are much easier ways to do this. But this worked for me. Also , you could just use my configure script and yum command line and probably have it work okay.
Scenario
----------
I'm setting this up for a fairly typical drupal install, with a mysql backend. I set up the dev server with the php package from the cent yum repo, and the customer ran Drupal with that for a while, but now wants a more current PHP than the cent package provides.
my approach for determining required modules
------------------------------------
1. get the list of the modules
$ php -m | grep -v -e Modules] -e ^$ > php-default-modules
2. create the configure script
$ for i in $(cat php-default-modules); do echo -n "--with-$i ">> phpconfigure.sh ;done
3. run the configure script, and iterate through the "Configure script errors" section below until it completes properly
4. at the end of the output, look for a notice of unknown options
Notice: Following unknown configure options were used:
--with-date
--with-gum-disease
Check './configure --help' for available options
5. as suggested, execute './configure --help' and correct the options. The "for" command above indiscriminately inserts "--with-" for all modules, but bundled modules may require "--enable-" instead, so mostly you'll be changing those. For modules that are enabled by default you'll need to remove the entry.
6. Add anything else you personally want or need. I like to add "--enable-safe-mode".
I configured with the following command line:
php-5.2.9]$ ./configure --with-mcrypt --with-mhash --with-bz2 --enable-calendar --with-curl --enable-dbase --enable-exif --enable-ftp --with-gd --with-gettext --with-gmp --with-iconv --enable-mbstring --with-mime_magic --with-mysql --with-mysqli --with-openssl --enable-pcntl --with-pdo_mysql --with-pdo_sqlite --with-pspell --enable-shmop --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-zlib --enable-safe-mode
as such, i needed a number of packages installed. Now I haven't tracked additional packages over base--there may be required packages that I happened to have installed for other things. But this is a pretty good list, i reckon:
php-5.2.9]$ sudo yum install mcrypt libmcrypt mhash libmhash libxml2-devel openssl-devel bzip2-devel curl-devel libjpeg-devel libpng-devel gmp-devel mysql-devel aspell-devel zlib zlib-devel
Configure script errors
--------------------------------------------
In my experience, these errors have been due (with any software, PHP included) mostly to missing development packages, which contain the libraries and headers needed to compile support for that library's function into the application.
This becomes a process of:
-executing the ./configure script and looking at the error
-installing the devel package providing the resource referenced by the error (google using the error as search term as needed)
-repeat until the ./configure script makes it through without error
Upshot: identify the software referenced by the error, and install it.
Example
-----------
Example error:
configure: error: Cannot find OpenSSL's <evp.h>
Example explanation
configure is looking for a header (and probably a lot of other stuff) from a missing openssl package.
Example solution:
php-5.2.9]$sudo yum install openssl-devel
Compiling (and testing and submitting)
----------------------------------------------
with ./configure working, you're ready to compile. I think it's important to test and submit the tests to the developers, you do what you want.
$ make;make test
Installing
-------------
$sudo make install
(be sure you, heh, have the system php removed before you do this step. seriously)
Best of luck!
02-Feb-2009 10:31
I have successfully installed Apache 2.2.11 and PHP 5.2.8 under Red Hat 9.0 on a Pentium 166 with 32 MB of RAM.
While I used RH9, the worst possible case, these notes are probably good for RH-based distributions too (Red Hat Enterprise, Fedora, CentOS...)
If you want to install MySQL, it needs to be installed before PHP because PHP requires some libraries be available.
One think important when picking up a binary distribution of MySQL is to download all four packages: MySQL-server, MySQL-devel, MySQL-client and MySQL-shared. Note: The MySQL was bundled with PHP 4 but is not anymore in PHP 5.
Then you need to install Apache before PHP, because again PHP needs some libraries be available. I installed Apache 2 from source, using the very last version available, which is 2.2.11.
I installed PHP 5.2.8 from source. Here, I had a number of problems, but none which I could not resolve easily, some of them with a little help from different forums I found through Google.
Rembember: When it says you need a package named xyz and you notice there is also one named xyz-devel, grab it.
Most of the packages I got from:
http://legacy.redhat.com/pub/redhat/linux/9/en/os/i386/RedHat/RPMS/
A similar page exists for other versions of Red Hat
and:
http://rpmfind.net/
This site has an updated version of some of the packages. Make sure to use only the one labeled for you version (in my case, Red Hat 9.0) or it will not likely work.
You already have glibc and glibc-common installed, but you need to get glibc-devel and glibc-kernheaders. Make sure to match glibc's version (rpm -q glibc). Note: When it says kernel-header is a required dependency, that's glibc-kernheader (not kernel-source). You will also need binutils (no need to match the version), and gcc and cpp (version must match).
You need zlib-devel (zlib is probably already installed, match the version you have).
If you install the GD extension, the actual library is already bundled with PHP 5 (use that one, they have done some changes in there, so don't upgrade), but you will need to install libpng and libpng-devel (match version, or disable in configure if you don't want) and libjpeg (no -devel with that one).
You will also need libxml2. Now there were a problem, because PHP requires libxml2 be 2.6 or greater, but Red Hat only supplied 2.5.4-1 for RH9 (if you have a more recent distro, you might be more lucky). After looking for a while, I decided to grab the source code for the most recent distribution at the official website (http://xmlsoft.org/) and compiled.
Hope my post is useful to someone. Please, share your experience when compiling/installing for your particular platform and setup. Remember how hard it's been for you the very first time. I confess, my very first server installation took me nearly a week and I was glad others helped me.
24-May-2008 11:27
I couldn't start Apache2 after installing PHP5 in archlinux, I got this error :
Cannot load /.../libphp5.so into server: /.../libphp5.so: undefined symbol: _efree
The solution was "make clean" on the PHP5 source directory, then ./configure, make & make install again.
22-Sep-2006 10:33
Install issues on Redhat, specifically RHEL4 with php4 already installed:
I discovered that there was an issue caused by redhat loading php4 in another file seperate from the httpd.conf file! This took me hours to discover. Make sure you know if the apache config file (httpd.conf) is loading configurations from a directory (or another file(s)) as well. If so, look in there for any php module loading which could conflict with the new module you are compiling/installing.
28-Aug-2006 12:34
for slackware 10.2 users with apache2, mysql5, and trying to install php5:
when following the directions above, after this step:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql
i kept getting this error:
"Unable to find MySql header files...."
the only way i could get php5 with mysql support was to compile MySql5 from source, and not use the binary as the mysql site recommends.
then i was able to ./configure successfully, but for some reason php was configured to compile the CGI version.
so, had to use this ./configure line:
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --disable-cgi
alternatively, you could install php4 which does bundle the MySql client files.
06-Jul-2006 03:41
PHP 5.1.4 INSTALLATION on Solaris 9 (Sparc)
Solaris9 Packages Installed:
Verify required package installation:
root# pkginfo SUNWbtool SUNWsprot SUNWtoo SUNWhea SUNWarc \
SUNWlibm SUNWlibms SUNWdfbh SUNWxglh SUNWcg6h
Uninstall Default Apache Packages:
root# /etc/init.d/apache stop
root# pkginfo |grep Apache
root# pkgrm SUNWaclg SUNWapchd SUNWapchr SUNWapchu
Create installation Directory:
root# mkdir /phpdata/
Download Required Packages from Sunfreeware:
Install libiconv-1.8 and gcc3.3.2 packages
root# pkgadd -d ./libiconv-1.8-sol9-sparc-local
root# pkgadd -d ./gcc-3.3.2-sol9-sparc-local
set LD_LIBRARY_PATH, CC and PATH variables
root# LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/sparcv9/:\
/usr/lib:/usr/openwin/lib:/opt/local/lib:/usr/local/ssl/lib:\
/usr/local/apr/lib:/opt/mysql/mysql/lib
root# CC=gcc
root# PATH=$PATH:/usr/ucb:/usr/local/bin/
root# export LD_LIBRARY_PATH CC PATH
Install apr-1.2.2 and aprutil-1.2.2 packages
root# gzcat apr-1.2.2.tar.gz |tar xvf -
root# cd apr-1.2.2
root# ./configure
root# make
root# make install
root# cd ..
root# gzcat aprutil-1.2.2.tar.gz |tar xvf -
root# cd apr-util-1.2.2/
root# ./configure --with-apr=/usr/local/apr/
root# make
root# make install
Install gawk-3.1.4, expat-1.95.5, db-4.2.52.NC,
gdbm-1.8.3, libgcc-3.3 and libxml2-2.6.16 packages
root# cd ..
root# pkgadd -d ./gawk-3.1.4-sol9-sparc-local
root# pkgadd -d ./expat-1.95.5-sol9-sparc-local
root# pkgadd -d ./db-4.2.52.NC-sol9-sparc-local
root# pkgadd -d ./gdbm-1.8.3-sol9-sparc-local
root# pkgadd -d ./libgcc-3.3-sol9-sparc-local
root# pkgadd -d ./libxml2-2.6.16-sol9-sparc-local
Install GNU make package
root# gzcat make-3.81.tar.gz |tar xvf -
root# cd make-3.81
root# ./configure
root# make
root# make install
root# cd ..
Install mysql-standard-5.0.22 package
Search for user mysql
root# grep mysql /etc/passwd
root# grep mysql /etc/group
If not found create user and group mysql
root# groupadd mysql
root# useradd -G mysql mysql
root# pkgadd -d ./mysql-standard-5.0.22-solaris9-sparc.pkg.gz
Install openssl-0.9.7g package
root# gzcat openssl-0.9.7g.tar.gz |tar xvf -
root# cd openssl-0.9.7g
root# ./config shared
root# make
root# make install
root# cd ..
Install Apache2 package
root# gzcat httpd-2.2.0.tar.gz |tar xvf -
root# cd httpd-2.2.0
root# ./configure --enable-so
root# /usr/local/bin/make
root# /usr/local/bin/make install
root# cd ..
Install php-5.1.4 package
root# gzcat php-5.1.4.tar.gz |tar xvf -
root# cd php-5.1.4
root# ./configure --with-apxs2=/usr/local/apache2/bin/apxs\
--with-ldap --with-mysql=/opt/mysql/mysql/
root# /usr/local/bin/make
root# /usr/local/bin/make install
root# cp php.ini-dist /usr/local/lib/php.ini
Edit httpd.conf to load the PHP module
and to parse certain extensions as PHP
root# vi /usr/local/apache2/conf/httpd.conf
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php .phtml
Start Apache
root# /usr/local/apache2/bin/apachectl start
Add environmental variables below HTTPD
root# vi /usr/local/apache2/bin/apachectl
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/lib/sparcv9/:
/usr/lib:/usr/openwin/lib:/opt/local/lib:/usr/local/ssl/lib:
/usr/local/apr/lib:/opt/mysql/mysql/lib
PATH=/bin:/sbin:/usr/ccs/bin:/usr/sbin:/usr/openwin/bin:\
/usr/ucb:/usr/local/bin/
export LD_LIBRARY_PATH PATH
Create Apache Startup Script
30-Mar-2006 11:13
I've (painfully) discovered that installing PHP5 with "make install" under SuSe 9.2 is NOT a good idea.
http://www.aditus.nu/jpgraph/apache2suse.php
This page explains how to install it without breaking everything that's php-related in the Apache2 configuration. Its first purpose, though, is to show how to have php 4 and 5 to cohabit properly.
28-Sep-2005 06:30
Using Apache2 & PHP5 work perfectly fine & safe together.
- all core modules are safe in Zend Engine 2
- third-party-libraries should be avoided
- semaphores and shared memory enables you to ensure yourself that your application/website is thread-safe also with non-thread-safe PHP modules!
04-Aug-2005 08:30
FILE TRUNCATED!!
during the make process should u receive an error declaring ext/ctype/ctype.lo (or another file) is truncated then you need to 'make clean' prior to a healthy 'make' and 'make install.'
looking into your ext/ directory you may find the offensive file to be 1 byte long.
28-Feb-2005 10:22
For the SuSE9.2 install of PHP5.
First:
If building on a x64 platform, please set LDFLAGS="-L/usr/lib64" before configure.
As for install, it suffices to go to /etc/apache2 and:
ln -s sysconfig.d/loadmodule.conf httpd2-prefork.conf
and then make install
11-Feb-2005 07:21
To install mysql and mysqli with PHP5 do the following:
after doing:
./configure --with-mysql=/path/to/mysql_config --with-mysqli=/path/to/mysql_config
do this:
"
if you want to use both the old mysql and the new mysqli interface, load the Makefile into your editor and search for the line beginning with EXTRA_LIBS; it includes -lmysqlclient twice; remove the second instance
"
then you can:
make
make install
.....
Pleasse note: you must have mysql-dev installed (RPM or source) or you will not have the mysql_config file at all. The standard, server, and client installations of MySQL do not include it. I read somewhere that the mysql and mysqli paths must be identical.
Quoted from Michael Kofler at the following link:
http://www.kofler.cc/forum/forumthread.php?rootID=3571
20-Jan-2005 01:36
Building PHP 5.x with Apache2 on SuSE Professional 9.1/9.2
SuSE uses a rather fragmented set of Apache configuration files stored in /etc/apache2/. When you configure PHP 5.x with:
$ ./configure --with-apxs2=/usr/sbin/apxs2
$ make
everything builds just fine; but when you issue:
$ su -c "make install"
the unconventional Apache conf file layout confuses the install-sapi section of the Makefile and the process halts with the following error:
apxs:Error: Config file /etc/apache2/httpd2-prefork.conf not found.
make: *** [install-sapi] Error 1
At this point only the PHP SAPI library has been copied into place; the rest of the files (like PEAR scripts, PHP-CLI, etc) have not been installed. But never fear! You can overcome this problem with the following steps:
1. Edit Makefile and change the following line to remove "install-sapi":
install_targets = install-sapi install-cli install-pear install-build install-headers install-programs
2. Issue the make install command again:
$ su -c "make install"
3. Add the PHP module & type instructions to the Apache configuration. As root, create a new file, /etc/apache2/conf.d/php5.conf that contains the following lines:
LoadModule php5_module /usr/lib/apache2/libphp5.so
AddType application/x-httpd-php php
--- And that's it. Everything else is just as the documentation suggests it should be.
15-Nov-2004 06:38
Hi too had same problem with multiview like when i execute http://huey/admin/test.php it used to compile but when i use http://huey/admin/test it wouldnt recognise it as php file... i worked it out with the addhandler method and AddType in different line and setting multiview for directive
"multiviews Options Indexes FollowSymLinks MultiViews"
the directives u can set it to root directory so now when u type pn test it will search in precendence for test.php, test.html if any .....
its working for me with apache2.0.47 and php 4.3.9 on solaris
praveen
