해당버전에 맞는 oracle client rpm 을 다운로드

 

https://www.oracle.com/database/technologies/instant-client/linux-x86-64-downloads.html

 

Instant Client for Linux x86-64 (64-bit)

Instant Client Installation for Linux x86-64 (64-bit) For general Instant Client information, see the Home Page. ODBC users should follow the ODBC Installation Instructions. Instant Client RPMs are also available without click-through from yum.oracle.com f

www.oracle.com

1. basic

2. devel

3. sqlplus

 

rpm -ivh oracle-instantclient12.2-basic-12.2.0.1.0-1.x86_64.rpm

rpm -ivh oracle-instantclient12.2-devel-12.2.0.1.0-1.x86_64.rpm

rpm -ivh oracle-instantclient12.2-sqlplus-12.2.0.1.0-1.x86_64.rpm

 

autoconf 설치를 진행한다

https://smarthink.tistory.com/39

불러오는 중입니다...

 

pecl 에서 oci-8 다운로드

 

1. phpize

2. ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/12.2/client64/lib

3. ln -s /usr/include/oracle/12.2/client64/ /usr/lib/oracle/12.2/client64/lib/include

4. make && make install

 

php.ini oci8.so 설정

 

oracle instantclient 환경변수 설정

1. splplus 실행을 위한 환경변수 추가

2. vim /etc/profile

3.    export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib

       alias sqlplus='/usr/lib/oracle/11.2/client64/bin/sqlplus'

4. 저장 후 source /etc/profile

 

정상연동 확인 명령어

1. php -r "oci_connect();"

2. 명령어를 잘못사용했단 에러문구가 나오면 정상연결

 

3. splplus  실행 후 정상 접속 명령어 나오면 됨

'기억할것들 > PHP' 카테고리의 다른 글

centos7 php-7 mssql 연결  (0) 2019.12.10
[CSS] 로 문자열 줄임 처리하기  (0) 2018.08.29
php 7.2.8 소스 설치  (0) 2018.08.13
구글 영수증 검증  (0) 2018.07.25

pdo 이용

 

pecl.php.net 에서

 

PECL :: The PHP Extension Community Library

What is PECL? PECL is a repository for PHP Extensions, providing a directory of all known extensions and hosting facilities for downloading and development of PHP extensions. The packaging and distribution system used by PECL is shared with its sister, PEA

pecl.php.net

sqlsrv, pdo_sqlsrv 다운로드

서버에서 pecl install sqlsrv, pdo_sqlsrv (파일명까지) - gcc 4.7 이상 필요

 

curl https://packages.microsoft.com/config/rhel/7/prod.repo > /etc/yum.repos.d/mssql-release.repo

 

yum install unixODBC-devel mssql-tools

 

c11 무슨 에러 발생하면

wget https://ftp.gnu.org/gnu/gcc/gcc-4.8.2/gcc-4.8.2.tar.gz

tar zxvf gcc-4.8.2.tar.gz

cd gcc-4.8.2

./contrib/download_prerequisites (의존성 파일 다운로드)

./configure --prefix=/usr/local/gcc-4.8.2 --enable-checking=release --enable-languages=c,c++ --disable-multilib

(겁나 오래걸림)

make && make install

 

vim ~/.bashrc

export GCC=/usr/local/gcc-4.8.2 19

export LD_LIBRARY_PATH=$GCC/lib64:$PPL/lib:$LD_LIBRARY_PATH 20

export PATH=$GCC/bin:$PATH

 

php extension 에 sqlsrv, pdo_sqlsrv 추가하고

아파치 재시작

 

 $conn =  new PDO ("sqlsrv:Server=디비주소,$port;Database=디비이름",                               아이디, 비번);

$query = $conn->prepare("SELECT * FROM app");
if ($query->execute()) {
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
print_r($row);
}
}

'기억할것들 > PHP' 카테고리의 다른 글

php-oracle 연동  (0) 2020.02.24
[CSS] 로 문자열 줄임 처리하기  (0) 2018.08.29
php 7.2.8 소스 설치  (0) 2018.08.13
구글 영수증 검증  (0) 2018.07.25

전혀 PHP는 아니지만...

코딩할때 가끔 써먹는데 자꾸 잊어버려서 기록해둔다



1. 한줄 문장 문자열 ... 표시하기

1
2
3
4
5
6
7
.content {
    width:100px;
    text-overflow:ellipsis;
    white-space:nowrap;
    word-wrap:normal;
    overflow:hidden;
}
cs


2. 두줄 이상일 시 문자열 ... 표시하기


1
2
3
4
5
6
7
8
9
.content {
    overflow:hidden;
    text-overflow:ellipsis;
    line-height:1.2em;
    height:3.6em;
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:3;    
}
cs

'기억할것들 > PHP' 카테고리의 다른 글

php-oracle 연동  (0) 2020.02.24
centos7 php-7 mssql 연결  (0) 2019.12.10
php 7.2.8 소스 설치  (0) 2018.08.13
구글 영수증 검증  (0) 2018.07.25

 

이 순서는 가장 마지막이어야 한다.

PHP 설치는 Apache, Mysql 이 설치된 이후에 하도록 한다.

 

1) Apache 설치방법

2) Mysql  설치방법

 

1. extension 에 사용할 파일들을 먼저 설치해 보자.

 

1
yum install bzip2-devel curl-devel gmp-devel libxslt-devel openldap-devel libicu-devel sqlite-devel oniguruma-devel
cs

 

2. libmcrypt 를 설치한다 [다운로드 바로가기]

 

1
2
$ ./configure --libdir=/lib64
$ make && make install
cs

 

3. libzip을 설치한다.

   굉장히 많은 시도를 해봤다.

    yum 으로 설치하면 0.10 버전이기 때문에 php7 설치가 안된다. 소스설치를 하면 1.5 버전이긴 하지만, 컴파일 및 메이크 시 에러가 많이난다.

    그래서 딱 맞는 0.11 버전 RPM 버전을 찾았다. centos7 64bit 용이다.

     

libzip-0.11.2.zip
다운로드

 

     위 파일을 다운로드 받고 서버로 보낸다.

 

1
2
$ rpm -ivh libzip-0.11.2-6.el7.psychotic.x86_64.rpm
$ rpm -ivh libzip-devel-0.11.2-6.el7.psychotic.x86_64.rpm
cs

 

   (libzip 최신 버전 설치법을 포스팅했다)

2019/07/02 - [Issue] - libzip 최신버전 설치하기

 

 

4. 사전준비는 끝났다. 이제 설치를 한다.

    PHP 소스파일을 다운받고 압축 푼 곳으로 이동하여 아래 명령어를 실행한다.

 

1
./configure --prefix=/apps/php-7.2.8 --with-apxs2=/apps/httpd-2.4.34/bin/apxs --with-mysqli --with-zlib --with-zlib-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-freetype-dir=/usr --with-libxml-dir=/usr --with-gd --with-gettext --with-curl --with-bz2=/usr --with-gmp --with-iconv --with-mhash --with-xmlrpc --with-xsl --with-kerberos --with-openssl=/usr/local/openssl --with-openssl-dir=/usr/local/openssl --enable-pdo --enable-shmop --enable-soap --enable-sockets --enable-wddx --enable-ctype --enable-debug --enable-sockets --enable-calendar --enable-sysvsem=yes --enable-ftp --enable-inline-optimization --enable-bcmath --enable-exif --enable-mbstring --enable-json --enable-zip --with-libzip=/usr/lib64 --with-ldap=/usr/lib64 --with-ldap-sasl --with-pdo-mysql --enable-maintainer-zts
cs

 

 

 

    설치를 편하게 하는 컴파일 실행파일 을 올려두긴 하겠다.  

run.sh
다운로드

 

 

 

- ldap.h 관련 에러 발생 시

1
ln -/usr/include/ldap.h /usr/lib64/ldap.h
cs

 

 

- off_t undefined; check your library configuration 발생 시 

1
2
3
4
$ vim /etc/ld.so.conf
 
(맨 하단 줄에)
/usr/local/lib64
 
(wq로 종료 후)
$ ldconfig
cs

 

 

- collect2: ld returned 1 exit status 에러 발생 시

yum install libtool-ltdl-devel

 

'기억할것들 > PHP' 카테고리의 다른 글

php-oracle 연동  (0) 2020.02.24
centos7 php-7 mssql 연결  (0) 2019.12.10
[CSS] 로 문자열 줄임 처리하기  (0) 2018.08.29
구글 영수증 검증  (0) 2018.07.25

이걸 검색 하는 분들은, 이게 왜 필요한지도 아실거라 생각한다.

그리고 정리하긴 항상 귀찮으니 대충 알 수 있을 정도로만 정리하려 한다.


[중요한 부분]

구글 영수증 검증을 위해서는 Access Token 이라는 것이 필요하다.

그런데 이 Access Token은 유효기간이 있다.! (1시간정도)

간이 지나면 현재 Access Token으로는 검증을 할 수 없기 때문에,

이를 교체 해야 한다. 그래서 필요한 것이 Refresh Token 이다.


아래 내용은 Refresh Token 을 얻는 방법 부터 시작된다.



[구글 영수증 검증을 위해서는]


1. 구글 개발자 콘솔의 권한이 필요하다.

  (https://console.developers.google.com/apis)


2. 프로젝트를 선택한다 ( 프로젝트가 없다면 새프로젝트를 생성한다)


3. 사용자 인증정보를 만듭니다.

    oAuth 클라이언트 ID 를 선택해야 한다.


  



4. 우리는 웹으로 검증프로세스를 진행할 것이기 때문에, 웹 어플리케이션으로 만든다.


5. 만드는 과정에서 보면 승인된 리디렉션 URI 를 입력해야 한다. 

   구글에 RefreshToken 발급 요청 시 이곳에 기록한 URL로 연결이 되기 때문에 반드시 접속 가능한 주소를 입력한다.


6. 생성을 완료하고 생성한 정보를 누르면 아래와 같이 ID와 보안코드가 발급된다. (이것도 중요함!)


7. API 및 서비스 사용설정을 누르고 Google Play Android Developer API 로 가서 사용설정을 누른다.


8. RefreshToken 발급을 위해서 특정 Code를 발급받아야 한다. 이 과정은 아래의 URL을 사용자 설정에 맞게 수정 후 웹브라우저로 접속한다.


${client_id} = 6번의  client ID

${redirect_url} = 6번에서 등록한 접속 가능한 RedirectUrl


[요청 URL]

https://accounts.google.com/o/oauth2/auth?
scope=https://www.googleapis.com/auth/androidpublisher
&response_type=code
&state=test
&access_type=offline
&client_id=${client_id}
&redirect_uri=${redirect_url}
&approval_prompt=force


위 URL을 복사해 가더라도 편의상 보기 편하기 위해 해논 개행은 꼭 다 붙이고 진행하길 바란다


위 URL 로 접속하면 이제 get 파라미터로 code가 전달 된다.

이 code를 꼭 기억하도록 한다. RefreshToken 을 획득하기 위해 꼭 필요하다.


9. access token 과 refresh token 획득을 위해 다음 url 에 요청한다

   (필자는 curl을 통해 호출했다)




$fParam = array(

'code' => ${client_code}, // 8 에서 발급받은 code

'client_id' => ${client_id}, // 8 에서 사용한 google client id

'client_secret' => ${client_secret}, // 8 에서 사용한 google client secret

'redirect_uri' => ${return url}, // 8 에서 사용한 google return url

'grant_type' => 'authorization_code',

);


token 발급을 위한 요청  url  은 아래와 같다.


$ch = curl_init();

curl_setopt( $ch, CURLOPT_URL, 'https://accounts.google.com/o/oauth2/token' );

curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded') );

curl_setopt( $ch, CURLOPT_HEADER, 0 )

curl_setopt( $ch, CURLOPT_POST, TRUE )

curl_setopt( $ch, CURLOPT_POSTFIELDS, http_build_query($fParam) )

curl_setopt( $ch, CURLOPT_TIMEOUT, 300 )

curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );

curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0 );

curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE );


$result = curl_exec( $ch );

if ( $result === FALSE ) {

die( 'Curl failed: ' . curl_error( $ch ) );

}


curl_close( $ch );

return json_decode( $result );


위 코드를 작성한 URL 에 접속하면 요청이  잘 내려온다

아래와 같은 형식으로


stdClassObject ( 

[access_token] => user_accessToken

[expires_in]=>3600

[refresh_token]=>user_refreshToken

[scope] => https://www.googleapis.com/auth/androidpublisher 

[token_type] => Bearer 

)


원하는 Access Token 과 RefreshToken 이 니왔다.


자세히 보면 expires_in 3600 이라는게 있는데, 이게 Access Token 의 유효시간이다.

저 배열을 그대로 DB 에 담아두고 Refresh Token 을 이용해 Access Token 을 주기적으로 갱신해야 한다.


10. Refresh Token . 을 사용해 AccessToken 갱신하기


$fParam array(

'refresh_token' => ${refresh_token}, // 9 에서 발급받은 refresh tolen

'client_id' => ${client_id}, // 8 에서 사용한 google client id

'client_secret' => ${client_secret}, // 8 에서 사용한 google client secret

'grant_type' => 'refresh_token',

);



$ch curl_init();

curl_setopt$chCURLOPT_URL'https://accounts.google.com/o/oauth2/token' );

curl_setopt$chCURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded') );

curl_setopt$chCURLOPT_HEADER)

curl_setopt$chCURLOPT_POSTTRUE )

curl_setopt$chCURLOPT_POSTFIELDS, http_build_query($fParam) )

curl_setopt$chCURLOPT_TIMEOUT300 )

curl_setopt$chCURLOPT_RETURNTRANSFER);

curl_setopt$chCURLOPT_SSL_VERIFYHOST);

curl_setopt$chCURLOPT_SSL_VERIFYPEERFALSE );


$result curl_exec$ch );

if $result === FALSE ) {

die'Curl failed: ' curl_error$ch ) );

}


curl_close$ch );

return json_decode$result );


위와 같은 형식으로 던지면 9번의 결과와 같게 json 타입으로 갱신된 Access Token이 넘어온다.

이 항목은 Access Token Expire 되기 전에 주기적으로 갱신해야 한다.



여기까지가 영수증 검증을 위한 준비 단계 이다. 휴 힘들었다.


11. 마지막, 영수증 상태 검증


영수증 검증을 위해 아래 URL 을 호출한다.


${PackageName} : 앱 패키지 이름

${ProductID} : 인앱 구매 상품의 제품코드

${PuchaseToken} : 결제 후 내려오는 영수증 번호

${access_token} : 10번을 통해 갱신되는  access token


https://www.googleapis.com/androidpublisher/v1.1/applications/${PackageName}/inapp/${ProductID}/purchases/${PuchaseToken}?access_token=${access_token}


위 URL 을 file_get_content 등을 통해 호출하면 json type 으로 리턴값이 온다.


결과의 purchaseState 의 값이 0 일 경우 정상적인 영수증이다.


이 정도면.. 되지않을까...?




'기억할것들 > PHP' 카테고리의 다른 글

php-oracle 연동  (0) 2020.02.24
centos7 php-7 mssql 연결  (0) 2019.12.10
[CSS] 로 문자열 줄임 처리하기  (0) 2018.08.29
php 7.2.8 소스 설치  (0) 2018.08.13

+ Recent posts