'yum php56 설치'에 해당되는 글 1건

  1. 2018.06.29 CentOS에 php 5.6 설치하기(오라클 oci8 까지 연동)
2018. 6. 29. 12:21



#이전 php 삭제 


PHP 설치 여부 확인

[root@localhost ~]# rpm -qa | grep php
php-common-5.1.6-5.el5
php-cli-5.1.6-5.el5




PHP 삭제

[root@localhost ~]# rpm -e php-cli-5.1.6-5.el5
[root@localhost ~]# rpm -e php-common-5.1.6-5.el5

[root@localhost ~]# rpm -qa | grep php

[root@localhost ~]#

Apache 확인 및 삭제

[root@localhost ~]# rpm -qa | grep apache
[root@localhost ~]# rpm -qa | grep httpd
httpd-2.2.3-6.el5.centos.1
[root@localhost ~]# rpm -e httpd-2.2.3-6.el5.centos.1
오류: Failed dependencies:
httpd >= 2.2.0 is needed by (installed) gnome-user-share-0.10-6.el5.i386


============================================================


참고 블로그 http://runningbaek.blogspot.com/2009/08/rpm-mysql-apache-php.html


==========================================================



#yum remi Repo 추가하기 

 그냥 yum 하면, php5.3버전을 설치해서, Repo 업데이트 해줘야함.


참고 블로그 : https://zetawiki.com/wiki/YUM_remi_%EC%A0%80%EC%9E%A5%EC%86%8C_%EC%B6%94%EA%B0%80


[root@zetawiki ~]# rpm -qa | grep remi-release
[root@zetawiki ~]# yum install http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
... (생략)
===========================================================================================
 Package              Arch           Version                 Repository               Size
===========================================================================================
Installing:
 remi-release         noarch         6.8-1.el6.remi          /remi-release-6         6.3 k

Transaction Summary
===========================================================================================
Install       1 Package(s)

Total size: 6.3 k
Installed size: 6.3 k
Is this ok [y/N]: y
[root@zetawiki ~]# rpm -qa | grep remi-release
remi-release-6.8-1.el6.remi.noarch
[root@zetawiki ~]# yum list remi-release




=================================================================



# remi Repo를 이용해서 yum 으로 php5.6 설치


참고 블로그 : https://zetawiki.com/wiki/CentOS_6%EC%97%90_PHP_5.6_%EC%84%A4%EC%B9%98_(yum_remi)




[root@zetawiki ~]# yum --enablerepo=remi-php56 install php
... (생략)
===========================================================================================
 Package              Arch         Version                          Repository        Size
===========================================================================================
Installing:
 php                  x86_64       5.6.26-1.el6.remi                remi-php56       2.7 M
Installing for dependencies:
 libedit              x86_64       2.11-4.20080712cvs.1.el6         base              74 k
 libzip-last          x86_64       1.1.3-1.el6.remi                 remi-safe         42 k
 php-cli              x86_64       5.6.26-1.el6.remi                remi-php56       4.0 M
 php-common           x86_64       5.6.26-1.el6.remi                remi-php56       1.1 M
 php-pecl-jsonc       x86_64       1.3.10-1.el6.remi.5.6            remi-php56        51 k
 php-pecl-zip         x86_64       1.13.4-1.el6.remi.5.6            remi-php56        53 k

Transaction Summary
===========================================================================================
Install       7 Package(s)

Total download size: 8.0 M
Installed size: 29 M
Is this ok [y/N]: y



나 같은 경우는 php-devel도 필요하기 때문에 php-devel도 추가한다.




예>

[root@localhost oci8-1.4.9]# yum --enablerepo=remi-php56 install php php-devel



확인 

[root@zetawiki ~]# rpm -qa | grep php



[root@zetawiki ~]# php -v
PHP 5.6.26 (cli) (built: Sep 15 2016 14:57:05) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies





그 사실, php-devel 이 필요한 이유는 php oci8 설치할때, 

phpize 를 사용해야하는데, phpize는 php-devel이 필요하기 때문이다.




==========================================================


#oci8 설치


참고 블로그 : http://zetawiki.com/wiki/PHP%EC%97%90%EC%84%9C_%EC%98%A4%EB%9D%BC%ED%81%B4_DB_%EC%82%AC%EC%9A%A9


pecl download oci8-1.4.9.tgz
tar xvzf oci8-1.4.9.tgz
cd oci8-1.4.9
phpize
./configure --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client64/lib
ln -s /usr/include/oracle/11.2/client64/ /usr/lib/oracle/11.2/client64/lib/include
make all install



위에서 OCI8 다운로드 부분인 pecl download oci8-1.4.9.tgz은, 이것 대신 wget http://pecl.php.net/get/oci8-1.4.9.tgz를 실행하거나, http://pecl.php.net/package/oci8 에서 직접 다운로드해도 된다.




[root@zetawiki ~]# pecl download oci8-1.4.9.tgz
downloading oci8-1.4.9.tgz ...
Starting to download oci8-1.4.9.tgz (169,255 bytes)
.....................................done: 169,255 bytes
File /root/oci8-1.4.9.tgz downloaded
[root@zetawiki ~]# tar xvzf oci8-1.4.9.tgz 
... (생략)
oci8-1.4.9/php_oci8.h
oci8-1.4.9/php_oci8_int.h
oci8-1.4.9/README
[root@zetawiki ~]# cd oci8-1.4.9
[root@zetawiki oci8-1.4.9]# phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
[root@zetawiki oci8-1.4.9]# ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/11.2/client64/lib
... (생략)
configure: creating ./config.status
config.status: creating config.h
config.status: executing libtool commands
[root@zetawiki oci8-1.4.9]# ln -s /usr/include/oracle/11.2/client64/ /usr/lib/oracle/11.2/client64/lib/include
[root@zetawiki oci8-1.4.9]# make all install
... (생략)
Build complete.
Don't forget to run 'make test'.

Installing shared extensions:     /usr/lib64/php/modules/
→ /usr/lib64/php/modules/ 에 PHP 확장기능 oci8.so 가 설치되었다.





#####위에는 오라클 인스턴스 클라이언트를 쓸때라, 경로 지정을 해줘서 라이브러리 가져와서 쓰는법이고,

오라클이 설치되어있는 상태에서는 ,


./configure --with-oci8=shared,$ORACLE_HOME


위에처럼 치고, 

Ln 링크는 생략하고,


make all install 해주면, 된다.



----------------------------------------------------------------------

Libraries have been installed in:

   /appls/oci8File/oci8-1.4.9/modules


If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR'

flag during linking and do at least one of the following:

   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable

     during execution

   - add LIBDIR to the `LD_RUN_PATH' environment variable

     during linking

   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag

   - have your system administrator add LIBDIR to `/etc/ld.so.conf'


See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

----------------------------------------------------------------------


Build complete.

Don't forget to run 'make test'.


Installing shared extensions:     /usr/lib/php/modules/

[root@localhost oci8-1.4.9]# 



위에처럼  /usr/lib/php/modules/ 폴더에, 설치 됬다고 뜰거다.


설치확인

[root@zetawiki oci8-1.4.9]# ll /usr/lib64/php/modules/oci8.so 
-rwxr-xr-x 1 root root 502555 Jun 19 14:44 /usr/lib64/php/modules/oci8.so






========================================================================


# php 연동하기

[root@zetawiki oci8-1.4.9]# echo 'extension=oci8.so' > /etc/php.d/oci8.ini
[root@zetawiki oci8-1.4.9]# service httpd restart
Stopping httpd:                                            [  OK  ]
Starting httpd:                                            [  OK  ]



연동확인

php -r "oci_connect();"
[root@zetawiki ~]# php -r "oci_connect();"
Warning: oci_connect() expects at least 2 parameters, 0 given in Command line code on line 1




=============================================================================



여기서 부터 중요하다!!


오라클이랑, apache를 연결해줘야한다.

처음에 이것때문에, oci8은 떴는데, 디비 연결이 안되서......헤맸었다.

근데, phpinfo.php를 만들어서 목록을 보면 환경변수에, Oracle이 안떴다.



vi /etc/sysconfig/httpd

또는 

~/.bash_profile (#source .bash_profile)

로 들어가서,



export LD_LIBRARY_PATH="/OraRoom/oracle/11g/lib"

export NLS_LANG="AMERICAN_AMERICA.AL32UTF8"

export ORACLE_HOME="/OraRoom/oracle/11g"

export TNS_ADMIN="/OraRoom/oracle/11g/network/admin"



오라클 정보를 추가해준다.



그리고 항상 서버는 재시작!!!

service httpd restart




이야~ 인제 다 되었다.!!!

테스트 하러가자!!!!!


아~!! tnsnames.ora 파일을 불러올때 확인해야될께, 권한이다.

폴더랑, 파일 권한을 바꿔줘야한다!!!


chmod 755 tnsnames.ora


이거때문에, tns목록을 php에서 못 불러와서.....몇시간을 헤맸다!!!



테스트 법은 추후에 다시 올리겠다.


Posted by Tyson