Category Archives: Useful

GPG key retrieval failed: [Errno 14] Peer cert cannot be verified or peer cert invalid

MariaDB repo 추가후 yum update시 아래와 같은 에러 발생

GPG key retrieval failed: [Errno 14] Peer cert cannot be verified or peer cert invalid

원인은 현재 시간과 서버의 시간이 맞지 않은 것으로 보여 지며

서버 시간 업데이트 (rdate) 등으로 처리 완료

ex) rdate -s time.bora.net

이후 yum update 를 실행하면 정상작동

Centos PHP 5.3 → 5.x 업그레이드

# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
# /etc/yum.repos.d/remi.repo

사용할 PHP 버젼에 enabled를 0에서 1로 교체
기본 remi의 경우 5.4

# yum update php* -y

PHP7 Uncaught Error: Class “ZipArchive” 오류시

Centos 6.x x86_64 기준

remi REPO 활성화 되어 있어야함.

remi REPO 추가
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

#yum install php70-php-pecl-zip

centos 6 PHP7 + MSSQL

YUM REPO 추가
1. epel
# rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

2. remi
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

기존 PHP 삭제
# yum remove php*

PHP 7 설치 (php 패키지는 개인의 용도에 맞게 설치)
# yum –enablerepo=remi install php70 php70-php php70-php-cli php70-php-common php70-php-gd php70-php-json php70-php-mbstring php70-php-mcrypt php70-php-mysqlnd php70-php-opcache php70-php-pear php70-php-xml php70-php-devel php70-php-imagick php-pdo

※ php.ini 파일은 /etc/opt/remi/php70/php.ini로 변경 됨

PHP 7에서 MSSQL로의 쿼리는 PDO를 통해 가능하며 접속 및 테스트 코드는 아래와 같음

”config.php”

<?
 // 반드시 DRIVER는 dblib로
 $_DB_INFO_MSSQL = array(
  "_DRIVER" => "dblib", 
  "_HOST" => "", 
  "_PORT" => "1433", 
  "_USER" => "", 
  "_PASS" => "", 
  "_DB" => ""
 );
?>

”MSSQL_SAMPLE.php”

<?
/*
* Project : MSSQL DBMS Class (PHP 7 PDO)
* Author : colorweb <enjoyteam@nate.com>
* Last : 2016-08-02
*/
class MSSQL extends PDO
{
    private $dns;
    private $engine; 
    private $host; 
    private $database; 
    private $user; 
    private $pass; 
    private $port; 
    private $_CONN; 
    private $_RESULT;
    
    public function __construct(){ 
        $this->engine = $GLOBALS["_DB_INFO_MSSQL"]["_DRIVER"]; 
        $this->host = $GLOBALS["_DB_INFO_MSSQL"]["_HOST"]; 
        $this->database = $GLOBALS["_DB_INFO_MSSQL"]["_DB"]; 
        $this->user = $GLOBALS["_DB_INFO_MSSQL"]["_USER"]; 
        $this->pass = $GLOBALS["_DB_INFO_MSSQL"]["_PASS"]; 
        $this->port = $GLOBALS["_DB_INFO_MSSQL"]["_PORT"]; 
        $this->dns = $this->engine.\':dbname=\'.$this->database.";host=".$this->host.":".$this->port; 
    } 

    function connect()
    {
        try {
            $this->_CONN = new PDO ($this->dns, $this->user, $this->pass);
        } catch (PDOException $e) {
            //$this->logsys .= "Failed to get DB handle: " . $e->getMessage() . "\\n";
            echo "Failed to get DB handle: " . $e->getMessage();
        }
    }

 function select($sql)
 {
  if(!$this->_CONN) { $this->connect(); }

  $_CONN = $this->_CONN;

  $this->_RESULT = $_CONN->query($sql);

  return $this->_RESULT;
 }

 function get_rows()
 {
  return $this->_RESULT->fetchAll();
 }

 function excute($sql)
 {
  if(!$this->_CONN) { $this->connect(); }

  $_CONN = $this->_CONN;

  $this->_RESULT = $_CONN->prepare($sql);
  $this->_RESULT->execute();

  return $this->_RESULT;
 }
}
?>

”MSSQL_TEST.php”

<?
include "config.php";
include "MSSQL_SAMPLE.php";

$_MSSQL = new MSSQL($_DEBUG);
$_MSSQL->connect();
$db_list = $_MSSQL->select("select * from [table_name]");
$db_data = $_MSSQL->get_rows();

// 전체 데이터를 가져와서 출력하는 예제 #1
for($i=0; $i<sizeof($db_data); $i++)
{
    echo $db_data[$i][FIELD_NAME];
}
?>

 

KVM + webvirtManager

※ 설치 환경
– CentOS 6.6 x86_64
– 리얼 IP 1, NAT 구성

1. KVM 설치
https://github.com/retspen/webvirtmgr/wiki/Setup-Host-Server

2. webvirtManager 설치
https://github.com/retspen/webvirtmgr/wiki/Install-WebVirtMgr

3. console 구동을 위한 python library 추가 설치
※ 설치시 반드시 python-devel 필요
# pip install numpy

4. console 구동을 위한 python 실행
# python /var/www/webvirtmgr/console/webvirtmgr-console

5. webvirtmanager 실행
# python /var/www/webvirtmgr/manage.py runserver 0:8000

CentOS 6.x git upgrade

1. rpmforge Repo 추가
RHEL/CentOS 6 – 64bit
# rpm -i ’http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm’
# rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt

RHEL/CentOS 6 – 32bit
# rpm -i ’http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.3-1.el6.rf.i686.rpm’
# rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt

2. /etc/yum.repos.d/rpmforge.repo 수정
[rpmforge-extras]의 enabled를 1로 변경

3. git update
# yum update git

Centos 7.0 설치 후

최소 설치 후 몇가지를 추가해주면 더 좋다.

1. ifconfig와 같은 network 명령어가 작동하지 않는다.(아에 없다)
# yum install net-tools

2. epel 설치
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm
# rpm -ivh epel-release-7-2.noarch.rpm

EPEL Repo 추가

centos 7.x x86_64
http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-2.noarch.rpm

centos 6.x  x86_64
http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

centos 6.x i383
http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

centos 5.x x86_64
http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

centos 5.x i386
http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

fastcgi 컴파일시 에러

> fcgio.cpp: In destructor ’virtual fcgi_streambuf::~fcgi_streambuf()’:
> fcgio.cpp:50: error: ’EOF’ was not declared in this scope
> fcgio.cpp: In member function ’virtual int fcgi_streambuf::overflow(int)’:
> fcgio.cpp:70: error: ’EOF’ was not declared in this scope
> fcgio.cpp:75: error: ’EOF’ was not declared in this scope
> fcgio.cpp: In member function ’virtual int fcgi_streambuf::sync()’:
> fcgio.cpp:86: error: ’EOF’ was not declared in this scope
> fcgio.cpp:87: error: ’EOF’ was not declared in this scope
> fcgio.cpp: In member function ’virtual int fcgi_streambuf::underflow()’:
> fcgio.cpp:107: error: ’EOF’ was not declared in this scope
> make[3]: *** [fcgio.lo] Error 1

위 에러 발생시

libfcgi/fcgio.cpp 파일에 #include <cstdio>  추가 후 컴파일

 

lighttpd+php+mysql+xcache 설치

os : centos 6.2 x86_64

http://pkgs.repoforge.org/rpmforge-release/ 자신의 os 맞는 rpm 다운로드 후 설치

1. lighttpd 설치
# yum install lighttpd -y

2. php 설치
# yum install lighttpd-fastcgi php-cli

3. php에서 MySQL을 지원하기 위한 패키지 설치
# yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-xcache -y

4. php.ini에 아래 내용 추가
# echo ’cgi.fix_pathinfo = 1’ >> /etc/php.ini

5. lighttpd 설정(자신의 서버에 맞게 알아서..)
# vi /etc/lighttpd/lighttpd.conf

Error : couldn’t set ’max filedescriptors’ Permission denied 발생시
/etc/sysconfig/selinux 파일의
SELINUX=enforcing 을 SELINUX=disabled 로 교체후 리붓