Search This Blog

Thursday, October 6, 2011

Install IcePHP using Ice-3.4.1

First, you need to install the Ice libs.

zeus ~ # emerge Ice -av These are the packages that would be merged, in order: Calculating dependencies... done! [ebuild R ] dev-libs/Ice-3.4.1 USE="ncurses python -debug -doc -examples -mono -ruby -test" RUBY_TARGETS="ruby18" 0 kB Total: 1 package (1 reinstall), Size of downloads: 0 kB Would you like to merge these packages? [Yes/No]

And then copy the compressed file to a safe and different place, then go there and expand the file.

zeus ~ # cp /usr/portage/distfiles/Ice-3.4.1.tar.gz /root/ zeus ~ # cd /root/ zeus ~ # tar -xzvf Ice-3.4.1.tar.gz Ice-3.4.1/ Ice-3.4.1/CHANGES Ice-3.4.1/ICE_LICENSE Ice-3.4.1/LICENSE Ice-3.4.1/Makefile Ice-3.4.1/Makefile.mak Ice-3.4.1/README Ice-3.4.1/RELEASE_NOTES Ice-3.4.1/allTests.py Ice-3.4.1/certs/ Ice-3.4.1/certs/ImportKey.class Ice-3.4.1/certs/ImportKey.java Ice-3.4.1/certs/c_dsa1024_priv.pem Ice-3.4.1/certs/c_dsa1024_pub.pem Ice-3.4.1/certs/c_rsa1024.pfx Ice-3.4.1/certs/c_rsa1024_priv.pem Ice-3.4.1/certs/c_rsa1024_pub.pem Ice-3.4.1/certs/cacert.pem Ice-3.4.1/certs/cakey.pem Ice-3.4.1/certs/certs.jks Ice-3.4.1/certs/client.jks Ice-3.4.1/certs/dsaparam1024.pem ...

To compile the IcePHP library we need to go to the php directory.

zeus ~ # cd Ice-3.4.1/php/

In order to set the path of php libraries, we need to set it in the Make.rules.php file, but first, we must know where the libraries are.

zeus php ~ # locate php.h
/usr/lib/php5/include/php/main/php.h
/usr/share/doc/freetds-0.64/userguide/php.htm
zeus php ~ # vi config/Make.rules.php
PHP_HOME                ?= /usr/lib/php5

We have all configured, so we just need to compile the library.

zeus php ~ # make making all in src make[1]: Entering directory `/root/Ice-3.4.1/php/src' making all in IcePHP make[2]: Entering directory `/root/Ice-3.4.1/php/src/IcePHP' c++ -c -I. -I/usr/include -I/usr/lib/php5/include/php -I/usr/lib/php5/include/php/main -I/usr/lib/php5/include/php/Zend -I/usr/lib/php5/include/php/TSRM -Wall -D_REENTRANT -fPIC -g Communicator.cpp c++ -c -I. -I/usr/include -I/usr/lib/php5/include/php -I/usr/lib/php5/include/php/main -I/usr/lib/php5/include/php/Zend -I/usr/lib/php5/include/php/TSRM -Wall -D_REENTRANT -fPIC -g Connection.cpp Connection.cpp: In function 'bool IcePHP::connectionInit()': Connection.cpp:376: warning: deprecated conversion from string constant to 'char*' Connection.cpp:378: warning: deprecated conversion from string constant to 'char*' Connection.cpp:378: warning: deprecated conversion from string constant to 'char*' Connection.cpp:391: warning: deprecated conversion from string constant to 'char*' Connection.cpp:391: warning: deprecated conversion from string constant to 'char*' Connection.cpp:393: warning: deprecated conversion from string constant to 'char*' Connection.cpp:395: warning: deprecated conversion from string constant to 'char*' Connection.cpp:395: warning: deprecated conversion from string constant to 'char*' Connection.cpp:397: warning: deprecated conversion from string constant to 'char*' Connection.cpp:421: warning: deprecated conversion from string constant to 'char*' Connection.cpp:421: warning: deprecated conversion from string constant to 'char*' Connection.cpp:423: warning: deprecated conversion from string constant to 'char*' c++ -c -I. -I/usr/include -I/usr/lib/php5/include/php -I/usr/lib/php5/include/php/main -I/usr/lib/php5/include/php/Zend -I/usr/lib/php5/include/php/TSRM -Wall -D_REENTRANT -fPIC -g Endpoint.cpp Endpoint.cpp: In function 'bool IcePHP::endpointInit()': Endpoint.cpp:288: warning: deprecated conversion from string constant to 'char*' ...

if you got an error message like this.

zeus php ~ # make making all in src make[1]: Entering directory `/root/Ice-3.4.1/php/src' making all in IcePHP make[2]: Entering directory `/root/Ice-3.4.1/php/src/IcePHP' make[2]: *** No rule to make target `../../../cpp/include/Ice/CommunicatorF.h', needed by `Communicator.o'. Stop. make[2]: Leaving directory `/root/Ice-3.4.1/php/src/IcePHP' make[1]: *** [all] Error 1 make[1]: Leaving directory `/root/Ice-3.4.1/php/src' make: *** [all] Error 1

Is just because your ICE_HOME environment variable is missing, you can set this variable in the global profile or just for this build.

zeus php # export ICE_HOME=/usr/ && make

And our Dynamically Linked "Shared Object" library it will be in the lib directory.

zeus php ~ # ll lib/IcePHP.so -rwxr-xr-x 1 root root 3171151 Nov 1 23:11 lib/IcePHP.so

Now you need to copy this library in some directory and append this directory in the extensions section of the php.ini file.

zeus php ~ # cp lib/IcePHP.so /etc/php/apache2-php5/ext zeus php ~ # vi /etc/php/apache2-php5/php.ini extension_dir = /etc/php/apache2-php5/ext extension = IcePHP.so

Also in the lib directory, we will find all the PHP-ICE library files that our web apps need.

zeus php ~ # ll lib/ total 3152 drwxr-xr-x 2 root root 256 Nov 2 05:11 Glacier2 -rw-r--r-- 1 500 500 425 Jun 3 16:48 Glacier2.php drwxr-xr-x 2 root root 1152 Nov 2 05:11 Ice -rw-r--r-- 1 500 500 4279 Jun 3 16:48 Ice.php drwxr-xr-x 2 root root 80 Nov 2 05:11 IceBox -rw-r--r-- 1 500 500 379 Jun 3 16:48 IceBox.php drwxr-xr-x 2 root root 376 Nov 2 05:11 IceGrid -rw-r--r-- 1 500 500 612 Jun 3 16:48 IceGrid.php -rwxr-xr-x 1 root root 3171151 Nov 2 05:11 IcePHP.so drwxr-xr-x 2 root root 112 Nov 2 05:11 IcePatch2 -rw-r--r-- 1 500 500 386 Jun 3 16:48 IcePatch2.php drwxr-xr-x 2 root root 80 Nov 2 05:11 IceStorm -rw-r--r-- 1 500 500 383 Jun 3 16:48 IceStorm.php -rw-r--r-- 1 500 500 5293 Jun 3 16:48 Ice_ns.php -rw-r--r-- 1 500 500 5344 Jun 3 16:48 Makefile -rw-r--r-- 1 500 500 3488 Jun 3 16:48 Makefile.make

Now we need to copy these libraries in the PHP shared folder and append the new path of Ice libraries

zeus php ~ # cp -rfv lib/ /usr/share/php/Ice-3.4.1 `Ice-3.4.1/php/lib/' -> `/usr/share/php/Ice-3.4.1' `Ice-3.4.1/php/lib/Ice' -> `/usr/share/php/Ice-3.4.1/Ice' `Ice-3.4.1/php/lib/Ice/Current.php' -> `/usr/share/php/Ice-3.4.1/Ice/Current.php' `Ice-3.4.1/php/lib/Ice/FacetMap.php' -> `/usr/share/php/Ice-3.4.1/Ice/FacetMap.php' `Ice-3.4.1/php/lib/Ice/LoggerF.php' -> `/usr/share/php/Ice-3.4.1/Ice/LoggerF.php' `Ice-3.4.1/php/lib/Ice/ConnectionF.php' -> `/usr/share/php/Ice-3.4.1/Ice/ConnectionF.php' `Ice-3.4.1/php/lib/Ice/ObjectFactory.php' -> `/usr/share/php/Ice-3.4.1/Ice/ObjectFactory.php' `Ice-3.4.1/php/lib/Ice/RouterF.php' -> `/usr/share/php/Ice-3.4.1/Ice/RouterF.php' `Ice-3.4.1/php/lib/Ice/PropertiesF.php' -> `/usr/share/php/Ice-3.4.1/Ice/PropertiesF.php' `Ice-3.4.1/php/lib/Ice/Plugin.php' -> `/usr/share/php/Ice-3.4.1/Ice/Plugin.php' `Ice-3.4.1/php/lib/Ice/Endpoint.php' -> `/usr/share/php/Ice-3.4.1/Ice/Endpoint.php' `Ice-3.4.1/php/lib/Ice/Router.php' -> `/usr/share/php/Ice-3.4.1/Ice/Router.php' `Ice-3.4.1/php/lib/Ice/LocalException.php' -> `/usr/share/php/Ice-3.4.1/Ice/LocalException.php' `Ice-3.4.1/php/lib/Ice/Stats.php' -> `/usr/share/php/Ice-3.4.1/Ice/Stats.php' `Ice-3.4.1/php/lib/Ice/Locator.php' -> `/usr/share/php/Ice-3.4.1/Ice/Locator.php' `Ice-3.4.1/php/lib/Ice/Logger.php' -> `/usr/share/php/Ice-3.4.1/Ice/Logger.php' ...

zeus php ~ # vi /etc/php/apache2-php5/php.ini include_path = ".:/usr/share/php5:/usr/share/php:/usr/share/php/Ice-3.4.1"

Finally, do not forget to restart the apache web server.

zeus php ~ # /etc/init.d/apache2 restart * Stopping apache2 ... [ ok ] * Starting apache2 ... [ ok ]

If you got an error like this:

PHP Deprecated: Comments starting with '#' are deprecated in /etc/php/apache2-php5.4/php.ini on line 693 in Unknown on line 0 PHP Warning: PHP Startup: ice: Unable to initialize module\nModule compiled with module API=20090626\nPHP compiled with module API=20100525\nThese options need to match\n in Unknown on line 0

You should read the Gentoo Upgrading PHP guide.