Category: PHP

PHP Related

Manual PHP Compilation

Below steps would be more than enough to recompile php on stock centos/fedora machines. This would be best suited for servers with out any control panel. For ones with control panel, you need to first take the configure command from the phpinfo and then appended what is required.

Before proceeding, it is recommended that you have httpd-devel installed in your server.

# rpm -qa | grep httpd-devel

If the above doesn’t yield any result, ensure to install it using yum.

# yum install httpd-devel

Now let us start with the steps of PHP compilation.

# cd /usr/local/src

# tar -jxvf php-5.2.13.tar.bz2

# cd php-5.2.13

# ‘./configure’ ‘–prefix=/usr/local/php’ ‘–with-apxs2=/usr/sbin/apxs’ ‘–with-png-dir=/usr’ ‘–enable-gd-native-ttf’ ‘–without-gdbm’ ‘–with-gettext’ ‘–with-gmp’ ‘–with-iconv’ ‘–with-jpeg-dir=/usr’ ‘–with-openssl’ ‘–with-zlib’ ‘–enable-exif’ ‘–enable-ftp’ ‘–enable-magic-quotes’ ‘–enable-sockets’ ‘–enable-wddx’ ‘–with-kerberos’ ‘–enable-shmop’ ‘–enable-calendar’ ‘–with-libxml-dir=/usr’ ‘–enable-pcntl’ ‘–enable-mbstring=shared’ ‘–without-sqlite’ ‘–enable-mbregex’ ‘–with-gd’ ‘–enable-bcmath’ ‘–enable-dba’ ‘–with-xmlrpc’ ‘–with-mysql=/usr/bin/’ ‘–with-mysqli=/usr/bin/mysql_config’ ‘–enable-dom’ ‘–with-xsl’ ‘–enable-soap’ ‘–with-xsl=/usr’ ‘–enable-xmlreader’ ‘–enable-xmlwriter’ ‘–enable-pdo’ –with-pdo-mysql=/usr’ ‘–with-pdo-sqlite=/usr’ ‘–enable-json’ ‘–enable-zip’ ‘–with-pspell’ ‘–with-mhash=/usr’ ‘–with-tidy=/usr’ ‘–with-curl=/usr’ ‘–with-mcrypt=/usr’ ‘–enable-gd-native-ttf’ ‘–with-ttf’ ‘–with-t1lib=/usr’

You may get errors related to missing libraries in the above command. Those all are available in yum. Install the library and its devel package and execute the above command once again. Take an example of missing freetype library, below steps needs to be followed.

#yum search freetype

# yum install freetype.i386 freetype-devel.i386

And once the required library is installed go and execute the configure command string  again until all libraries required are installed and configure command creates required scripts and files to get ready for the next step of compilation.

# cat /proc/cpuinfo  | grep processor | wc -l

# make -j4 [4 is result from earlier command]

# cp .libs/libphp5.so  /etc/httpd/modules/

# make -j4 install [may have to update the httpd.conf file so as to remove the php module added again in it by this command]

And now, you have php compiled running on your server, which you may confirm using

# php -v

Joomla / Mambo shows error when trying to install a module or component.

Joomla shows error of below pattern when trying to install a module or component.

Warning: is_dir(): Stat failed for /home/xyzabc/public_html/cms/media/install_443448a97a130/images (errno=13 – Permission denied) in /home/xyzabc/public_html/cms/administrator/includes/pcl/pclzip.lib.php on line 4287

Warning: is_dir(): Stat failed for /home/xyzabc/public_html/cms/media/install_443448a97a130/images (errno=13 – Permission denied) in /home/xyzabc/public_html/cms/administrator/includes/pcl/pclzip.lib.php on line 4287

This is because of 2 reasons

1 ) Bad folder permissions

2 ) Register globals in on in php.ini

The solution

1 ) Issue the below command after going to the installation directory of Joomla

# chmod 777 administrator/backups/ administrator/components/ administrator/modules/ administrator/templates/ cache/ components/ images/ images/banners/ images/stories/ language/ mambots/ mambots/content/ mambots/editors/ mambots/editors-xtd/ mambots/search/ media/ modules/ templates/

2 ) Copy the server’s php.ini to the Joomla installation directory and edit it to make sure that register globals is off. At times a httpd service restart would be required.

Hope now you can install components and modules to your Joomla installation.

Installing PHP5 along with working php4 on FreeBSD server

Below are the steps to install php5 on a FreeBSD server. We are going to install php 5.1.2 current satble php5 version.

# cd /usr/local/src

# wget http://us2.php.net/get/php-5.1.2.tar.bz2/from/this/mirror (or any other mirror)

# tar -jxvf php-5.1.2.tar.bz2

# cd php-5.1.2/

#5 ) PHP=’/usr/bin/php’ ( result of which php )

# CFG=`$PHP -i | grep configure | sed “s/’//g” | sed “s/–prefix=\/usr//g” | sed “s/’//g” | sed “s/\.\/configure \(.*\)–with-apxs.*apxs \(.*\)/\1 \2/” | sed “s/<tr><td class=\”e\”>Configure Command <\/td><td class=\”v\”>//g” | sed “s/<\/td><\/tr>//g”`

# CFGLINE=”${CFG##* => } –prefix=/usr/local/php5 –exec-prefix=/usr/local/php5 –enable-force-cgi-redirect –enable-discard-path”

# ./configure $CFGLINE

# make

# make install

# cp /usr/local/php5/bin/php /usr/local/cpanel/cgi-sys/php5

# chown root:wheel /usr/local/cpanel/cgi-sys/php5

# cp -f php.ini-recommended /usr/local/php5/lib/php.ini

# Edit /usr/local/apache/conf/httpd.conf to add the below enteries

Action application/x-httpd-php5 “/cgi-sys/php5″

AddType application/x-httpd-php5 .php5

Restart the httpd service.

Now for using php 5 you need to either have the scripts with extension .php5 or need to have the below entry in your .htaccess file

AddHandler application/x-httpd-php5 .php

Reference : – http://devel.webonce.com/php5.txt

 

 

Installing PHP5 along with working php4 on Redhat server

Below are the steps to install php5 on a redhat server. We are going to install php 5.1.2 current satble php5 version.

# cd /usr/local/src

# wget http://us2.php.net/get/php-5.1.2.tar.bz2/from/this/mirror (or any other mirror)

# tar -jxvf php-5.1.2.tar.bz2

# cd php-5.1.2/

# PHP=’/usr/local/bin/php’ ( result of which php )

# CFG=`$PHP -i | grep configure | sed “s/–prefix=\/usr\/local//g” | sed “s/’//g” | sed “s/\.\/configure \(.*\)–with-apxs.*apxs \(.*\)/\1 \2/”`

 # CFGLINE=”${CFG##* => } –prefix=/usr/local/php5 –exec-prefix=/usr/local/php5 –enable-force-cgi-redirect –enable-discard-path”

# ./configure $CFGLINE

# make

# make install

# cp /usr/local/php5/bin/php /usr/local/cpanel/cgi-sys/php5

# chown root:wheel /usr/local/cpanel/cgi-sys/php5

# cp -f php.ini-recommended /usr/local/php5/lib/php.ini

Edit /usr/local/apache/conf/httpd.conf to add the below enteries

Action application/x-httpd-php5 “/cgi-sys/php5″

AddType application/x-httpd-php5 .php5

# /etc/init.d/httpd restart

Reference : – http://devel.webonce.com/php5.txt