|
This a howto on compiling php from source. This has been done many times before, so what's different, I have added more detail in the form of dependancies,tips, errors with fixes to try and simplify the process, and remove some of the common head aches. As with all howto's you use it at your own risk.
Note this Howto was writen for Fedora 12 x68_64 but should apply to most Fedora installs.
Dependencies - depending on the functionality that you require the following may be needed.
rpm list :
re2c
bison
flex
lemon
patch
glib2-devel
gcc-c++
libtool ?
ibtool-ltdl-devel
httpd-devel
openssl-devel
mysql-devel
libxml2-devel
libcurl-devel
gdbm-devel
libjpeg-devel
libmcrypt-devel
libpng-devel
mhash-devel
pam-devel
postgresql-devel
mhash
sqlite-devel
unixODBC-devel
firebird-devel
freetds-devel
recode-devel
libicu-devel
enchant-devel
postgresql
postgresql-libs
zlib-devel
freetype
db4-devel-static
db4-devel
db4
zlib-devel
zziplib
zziplib-devel
bzip2-devel
bzip2-libs
epic**
gd
gd-devel
t1lib-devel
t1lib
gmp-devel
uw-imap-devel
ncurses-devel
aspell-devel
libedit-devel
mm-devel
net-snmp-devel
libtidy-devel
libxslt-devel
Tips:
1) If running 64 bit os use --with-libdir=lib64 the will resolve a lot of path dependency issues.
2) set the correct include paths in you php.ini
; UNIX: "/path1:/path2"
include_path = ".:/php/includes; /opt/php-5.2.13/lib/php;"
3)Note if a recompile still gives errors after installing dependencies and fixing paths
then start again on clean source as "make clean" does not remove all
settings and old compiles.
4)If your are having issues with debugging add " > debugging.log" to the end of the command you are exicuting to capture the output. eg: make > debugging.log
I typicaly download the current stable source from the php.net site / local mirror into a directory that I can use for the compile.
[root@www php-5.2.13]# wget http://nz.php.net/distributions/php-5.2.13.tar.gz
[root@www php-5.2.13]# tar -zxf php-5.2.13.tar.gz
[root@www php-5.2.13]# cd ./php-5.2.13
now I run configure with compile options to my requitements. You will note I'm installing php into the /opt/php-5.2.13 , this is because I run multiple installs of php, called as cgi.
[root@www php-5.2.13]#./configure \
--prefix='/opt/php-5.2.13' \
--exec-prefix='/opt/php-5.2.13' \
--with-config-file-path='/opt/php-5.2.13/etc' \
--with-libdir=lib64 \
--enable-cgi \
--enable-fastcgi \
--enable-discard-path \
--enable-force-cgi-redirect \
--enable-pcntl \
--enable-ftp \
--enable-magic-quotes \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-sysvmsg \
--enable-gd-native-ttf \
--enable-ucd-snmp-hack \
--enable-shmop \
--enable-calendar \
--enable-mbstring \
--enable-mbregex \
--enable-bcmath \
--enable-dba \
--enable-dom \
--enable-wddx \
--enable-soap \
--enable-json \
--enable-posix \
--enable-inline-optimization \
--enable-ctype \
--enable-pcntl \
--disable-rpath \
--with-libmbfl \
--enable-zip \
--with-bz2=shared \
--with-zlib \
--with-exec-dir \
--with-t1lib=shared \
--with-gettext=shared \
--with-gmp=shared \
--with-iconv=shared \
--with-pcre-regex \
--with-t1lib \
--with-layout=GNU \
--with-kerberos \
--with-imap \
--with-imap-ssl \
--with-snmp \
--with-xsl=sharedyip \
--with-libedit \
--with-pspell \
--with-mcrypt \
--with-mhash \
--with-tidy \
--with-ncurses \
--with-mm \
--with-readline \
--with-openssl \
--without-gdbm \
--with-curl \
--with-pear \
--with-mime-magic \
--with-db4 \
--with-regex=php \
--with-tidy \
--enable-ucd-snmp-hack \
--with-snmp=shared \
--enable-xml \
--enable-xmlreader \
--enable-xmlwriter \
--with-xmlrpc \
--with-pic \
--enable-exif \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gd \
--with-jpeg-dir='/usr/lib64' \
--with-png-dir='/usr/lib64' \
--with-xpm-dir='/usr/lib64' \
--with-ttf=/usr/include/freetype2 \
--with-ldap \
--with-ldap-sasl \
--with-mysql=static \
--with-mysql-sock=/var/lib/mysql \
--with-mysqli=static \
--with-mysqli=/usr/bin/mysql_config \
--with-pgsql=shared \
--with-interbase=shared \
--with-mssql=shared
Next we want to compile the code.
[root@www php-5.2.13]# make
It is recomended to run make test but this can be skipped it takes ages......
[root@www php-5.2.13]# make test
Now we install the compiled binaries / files
[root@www php-5.2.13]# make install
I use the php.ini-recommended as the starting point for my php.ini. Depending on your compile options you may want to copy it to /etc , for my install I copy it to /opt/php-5.2.13/etc/
[root@www php-5.2.13]# cp php.ini-recommended /opt/php-5.2.13/etc/php.ini
Errors and fixes
./Configure errors
Error: Configure: error: xml2-config not found. Please check your libxml2 installation.
Fix: yum install libxml2-devel
Error: configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing.
This should not happen. Check config.log for additional information.
Fix: yum install uw-imap-devel
Error: configure: error: Cannot find pspell
Fix: yum install aspell-devel
Error: configure: error: Please reinstall libedit - I cannot find readline.h
Fix: yum install libedit-devel
Error: configure: error: cannot find mm library
Fix: yum install mm-devel
Error: configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution
Fix: yum install libxslt-devel
Error:
configure: warning: bison versions supported for regeneration of the Zend/PHP parsers: 1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 (found: none).
configure: warning: flex versions supported for regeneration of the Zend/PHP parsers: 2.5.4 (found: )
configure: warning: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.
configure: warning: lemon versions supported for regeneration of libsqlite parsers: 1.0 (found: none).
configure: warning: bison versions supported for regeneration of the Zend/PHP parsers: 1.28 1.35 1.75 1.875 2.0 2.1 2.2 2.3 2.4 2.4.1 (found: none).
Fix: yum install bison bison flex lemon re2c
Make errors
To do |