PHP 5.5.6 + Oracle Instant Client 12.1 @ Fedora server
Zdravím všechny případné čtenáře,
po dosti dlouhém čase mi to opět nedá a píšu sem další návod na problém, jenž sem řešil v práci.
Jedním dechm musím dodat, že tak deset let pracuji běžně s Debianem a Fedoru používám jen a pouze neboť naše firma ji v daných systémech používá místo Debianu – jednoduše jeden správce kdysi nainstaloval Fedoru a stal se z toho standard. A já tak dnes a denně přicházím na kloub zálubnostem Fedory, jenž se oproti Debianu prostě musí lišit, asi by-design a z principu 🙂 Ale co mě nezabije to mě posílí/obohatí, případně tam narvu Debian 🙂 Tady, jdeme na to – nainstalujeme si Apache + PHP 5.5.6 s Oracle clientem na x86_64 prostředí … Jo a komentáře nechávám v „originále“, tedy anglicky + výstupy příkazů jsou „redakčně zkráceny“ …
Autor nezodpovídá za následky využití toho návodu a doufá, že všichni případní jeho uživatelé jsou si vědomi toho co dělají a případné důsledky ! Tedy jako vždy – žádné záruky autor NEDÁVÁ !
Install Apache/httpd and PHP using yum:
[root@svr007 tmp]# yum install httpd php php-common ... yum output ... Total download size: 6.9 M Installed size: 28 M Is this ok [y/d/N]: y Downloading packages: ... packages list ... Running transaction check Running transaction test Transaction test succeeded Running transaction Verifying ... Installed ... Dependency Installed ... Complete!
Verify that module is there (but it is the bad one – not working):
[root@svr007 tmp]# ls -l /usr/lib64/php/modules/ total 4568 -rwxr-xr-x 1 indian area 602282 Nov 7 11:07 oci8.so ... modules list ...
Restart Apache and verify its status:
[root@svr007 tmp]# systemctl restart httpd [root@svr007 tmp]# systemctl status httpd httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled) Active: active (running) since Fri 2014-11-07 11:59:38 CET; 1s ago Main PID: 33290 (httpd) Status: "Processing requests..." CGroup: /system.slice/httpd.service ├─33290 /usr/sbin/httpd -DFOREGROUND ├─33291 /usr/sbin/httpd -DFOREGROUND ├─33292 /usr/sbin/httpd -DFOREGROUND ├─33293 /usr/sbin/httpd -DFOREGROUND ├─33294 /usr/sbin/httpd -DFOREGROUND └─33295 /usr/sbin/httpd -DFOREGROUND Nov 07 11:59:38 svr007 httpd[33290]: [Fri Nov 07 11:59:38.647870 2014] [so:warn] [pid 33290] AH01574: module php5_module is already loaded, skipping Nov 07 11:59:38 svr007 httpd[33290]: AH00557: httpd: apr_sockaddr_info_get() failed for svr007 Nov 07 11:59:38 svr007 systemd[1]: Started The Apache HTTP Server.
Aha, there is a doubled configuration of php5 modules, let’s fix it and verify modules it selves:
[root@svr007 tmp]# view /etc/httpd/conf.d/php.conf ... comment-out PHP module related lines (it is already included to httpd) ... # # LoadModule php5_module modules/libphp5.so # # # LoadModule php5_module modules/libphp5-zts.so # [root@svr007 tmp]# ls -l /etc/httpd/conf.d/modules/ total 11128 -rwxr-xr-x 1 indian area 4333312 Nov 13 2013 libphp5.so -rwxr-xr-x 1 indian area 4547240 Nov 13 2013 libphp5-zts.so ... modules list ...
Download Oracle InstantClient from Oracle website and install it like this:
[root@svr007 tmp]# rpm -Uvh oracle-instantclient12.1-basic-12.1.0.2.0-1.x86_64.rpm [root@svr007 tmp]# rpm -Uvh oracle-instantclient12.1-devel-12.1.0.2.0-1.x86_64.rpm
Download OCI8 interface:
[root@svr007 tmp]# pear download pecl/oci8 downloading oci8-2.0.8.tgz ... Starting to download oci8-2.0.8.tgz (190,854 bytes) .........................................done: 190,854 bytes File /tmp/oci8-2.0.8.tgz downloaded
Untar the package and switch DIR:
[root@svr007 tmp]# tar xzf oci8-2.0.8.tgz [root@svr007 tmp]# cd oci8-2.0.8/
„PHPIZE it“:
[root@svr007 oci8-2.0.8]# phpize Configuring for: PHP Api Version: 20121113 Zend Module Api No: 20121212 Zend Extension Api No: 220121212
Run configure script with Oracle InstantClient LIB directory path:
[root@svr007 oci8-2.0.8]# ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/12.1/client64/lib/ ... configure script output ...
Let’s compile it:
[root@svr007 oci8-2.0.8]# make ... compile output ... libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin:/usr/lib/oracle/12.1/client64:/sbin" ldconfig -n /tmp/oci8-2.0.8/modules ---------------------------------------------------------------------- Libraries have been installed in: /tmp/oci8-2.0.8/modules
Install a new OCI8 module and check it:
[root@svr007 oci8-2.0.8]# make install Installing shared extensions: /usr/lib64/php/modules/ [root@svr007 oci8-2.0.8]# ls -l /usr/lib64/php/modules/ total 4524 ... ... -rwxr-xr-x 1 indian area 561026 Nov 7 15:54 oci8.so ... ...
To avoid Oracle error message and its disfunction like „ORA-24408: could not generate unique server group name“; edit /etc/hosts file to make oci8 work corretly with Oracle InstantClient:
[root@svr007 oci8-2.0.8]# view /etc/hosts ... append your servers name to 127.0.0.1 record, like ... 127.0.0.1 localhost svr007 ::1 localhost svr007
Restart and check Apache for last time:
[root@svr007 oci8-2.0.8]# systemctl restart httpd [root@svr007 oci8-2.0.8]# systemctl status httpd httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled) Active: active (running) since Tue 2014-11-11 09:53:11 CET; 2s ago Process: 105728 ExecStop=/bin/kill -WINCH $MAINPID (code=exited, status=0/SUCCESS) Process: 85213 ExecReload=/usr/sbin/httpd $OPTIONS -k graceful (code=exited, status=0/SUCCESS) Main PID: 105733 (httpd) Status: "Processing requests..." CGroup: /system.slice/httpd.service ├─105733 /usr/sbin/httpd -DFOREGROUND ├─105734 /usr/sbin/httpd -DFOREGROUND ├─105735 /usr/sbin/httpd -DFOREGROUND ├─105736 /usr/sbin/httpd -DFOREGROUND ├─105737 /usr/sbin/httpd -DFOREGROUND └─105738 /usr/sbin/httpd -DFOREGROUND Nov 11 09:53:11 svr007 systemd[1]: Started The Apache HTTP Server.
Fine, it is UP and RUNNING. As a last thing verify that Oracle connection is working:
[root@svr007 oci8-2.0.8]# php -B "var_dump(oci_connect('DBUSR', 'DBPWD', '127.0.0.1:1521/DBNAME'));" resource(5) of type (oci8 connection) ^C [root@svr007 oci8-2.0.8]#
A to je vše přátelé, úžasná práce 🙂
That’s all folks, well done 🙂