php 설치시 만나는 각종에러

리눅스/PHP|2016. 12. 12. 13:12
반응형

리눅스 APM 소스설치시 Error 및 해결 방법
APM 소스설치시 발생되는 몇가지 Error와 그 해결 방법이다.


1. Mysql


Error 1)
checking for termcap functions library... configure: error: No curses/termcap library found
make: *** No targets specified and no makefile found.  Stop.

해결 방법
# yum –y install libtermcap-devel ncurses-devel 설치


Error 2)
/bin/rm: cannot remove `libtoolT': No such file or directory 
해결 방법
mysql 소스파일 Directory에서 아래 진행
# autoreconf --force --install
# aclocal
# libtoolize --automake --force
# automake --force --add-missing



2. Apache
Error 1)
configure: error: ...No recognized SSL/TLS toolkit detected

해결 방법
# yum –y install openssl-devel



3. PHP
Error 1)
Checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>
해결 방법
# yum –y install openssl-devel


Error 2)
Configure: error: xml2-config not found. Please check your libxml2 installation.
해결 방법
# yum –y install libxml2-devel


Error 3)
Configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
해결 방법
# yum –y install curl-devel


Error 4)
Configure: error: libpng.(also) not found.
해결 방법
# yum –y install libpng-devel


Error 5)
Configure: error: Please reinstall the BZip2 distribution
해결 방법
# yum –y install bzip2-devel


Error 6)
Configure: error: libjpeg.(also) not found.
해결 방법
# yum –y install libjpeg-devel


Error 7)
Checking for unixODBC support... configure: error: ODBC header file '/usr/include/sqlext.h' not found!
해결 방법
# yum –y install unixODBC-devel


Error 8)
configure: error: DBA: Could not find necessary header file(s).
해결 방법
# yum –y install gdbm-devel


Error 9)
Configure: error: Cannot find MySQL header files under /usr.
Note that the MySQL client library is not bundled anymore!
해결 방법
# yum –y install mysql-devel


Error 10)
Configure: error: freetype.h not found.
해결 방법
# yum –y install freetype-devel


Error 11)
Configure: error: Unable to locate gmp.h
해결 방법
# yum –y install gmp-devel


Error 12)
Configure: error: Cannot find pspell
해결 방법
# yum –y install pspell-devel


Error 13)
configure: error: not found. Please reinstall the expat distribution.
해결 방법
# yum –y install expat-devel


Error 14)
Configure: error: Please reinstall the ncurses distribution
해결 방법
# yum –y install ncurses-devel


Error 15)
Configure: error: snmp.h not found. Check your SNMP installation.
해결 방법
# yum –y install net-snmp-devel



반응형

댓글()

클래스간 변수 공유 - 전역변수 (global variable) 사용하기

프로그래밍/Android (Java)|2016. 12. 12. 08:44
반응형

별도의 파일 생성


Global_Variable.java


package com.tistory.sysdocu;


import android.app.Application;


public class Global_Variable extends Application {


    private String GlobalString;


    public String getState(){

        return GlobalString;

    }


    public void setState(String GS){

        GlobalString = GS;

    }


}




AndroidManifest.xml 내용 추가


(생략)


    <application

        android:name=".Global_Variable"

        android:icon="@drawable/ic_launcher"

        android:label="@string/app_name"

        android:theme="@style/AppTheme">


(생략)




본문 파일에서 사용하기


(생략)


   @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);


        Global_Variable GV = ((Global_Variable)getApplicationContext());

        GV.setState("Hello world");        // 저장

        String Global = GV.getState();    // 불러오기


(생략)



반응형

댓글()

텍스트파일의 내용을 순차적으로 읽어들이는 방법

프로그래밍/BASH SHELL|2016. 11. 29. 10:08
반응형

/test.txt 파일의 내용에

file1

file2

file3

file4

file5

 

가 있는 경우

  

 

#!/bin/bash
for LIST in `cat /test.txt`; do
    echo $LIST
done 

 

 

와 같은 스크립트를 돌리면

 

file1

file2

file3

file4

file5

 

와 같은 결과가 나온다.

 

 

[출처] http://www.ischo.net/

 

 

위 코드는 cat /test.txt 대신 echo "$temp" 와 같이 사용도 가능합니다.

대신 한줄씩 불러들이기 위해서 $temp 변수 앞뒤로 쌍따옴표 붙이는것을 잊으면 안됩니다.

 

그리고 이것은 한 줄에 공백이 있을 경우 맨 앞에 것만 불러오는 단점이 있습니다.

불러들이는 행에 여러 열이 있을 경우 아래와 같이 각 열에 변수 적용이 가능합니다.

 

while read cnt name trash
        do
                echo "${cnt} : ${name}"
        done < list.txt 

 

또는 공백이 불특정하게 많을 경우 아래와 같이 사용도 가능합니다.

 

while read item; do
    echo $item
done < list.txt 

 

파일이 아닌 변수에서 한줄씩 라인을 읽어오고 싶을 경우 아래와 같이 파이프라인 (버티컬바)를 이용해 처리합니다.

 

echo "$list" | while read item; do
    echo $item
done

 

반응형

댓글()

변수 두개 붙여서 하나의 변수명으로 사용할 경우

프로그래밍/BASH SHELL|2016. 11. 29. 07:57
반응형

# vi test.sh


#!/bin/bash


size[1]="10G"

size[2]="10G"

size[3]="0G"

size[4]="0G"


for ((i=1; i<=4; i++)) ;do

    if [ ${size[$i]} == "0G" ]; then

        echo "no order ($i/4)"

    else

        echo ${size[$i]}

    fi

done 



# sh test.sh




반응형

댓글()

지연 실행 (delay)

프로그래밍/Android (Java)|2016. 11. 14. 08:08
반응형

import android.os.Handler;



                        new Handler().postDelayed(new Runnable() {

                            @Override

                            public void run() {

                                // 이곳에 실행코드 입력

                            }

                        }, 3000);  // 3초 지연후 실행코드 실행



반응형

댓글()

php 로 소켓 프로그램 만들기 (다중 처리, 멀티스레드)

프로그래밍/PHP|2016. 10. 28. 17:17
반응형

- 본 예제는 client 의 연결을 자식 프로세스(thread) 로 구동시켜 여러 client 의 요청을 다중 처리하도록 하는 코드 입니다.

- 본 예제는 client 와 서버가 메세지를 한 번씩 주고 받는 예제 입니다.



1. 서버에서 데몬 생성


# vi server.php


#!/usr/local/php/bin/php -q

<?php

set_time_limit(0);


define("_IP",    "0.0.0.0");    // 접속 허용할 IP. 모든 IP 에 대하여 오픈할 경우 0.0.0.0 으로 설정

define("_PORT",  "81");


$sSock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);


socket_bind($sSock, _IP, _PORT);

socket_listen($sSock);


pcntl_signal(SIGCHLD, SIG_IGN);


while($sock = socket_accept($sSock))

{

    socket_getpeername($sock, $sockIp, $sockPort);

    msg("\nclient connect : ".$sockIp.":".$sockPort."\n");


    $pid = pcntl_fork();

    if($pid == -1)

    {

        msg("fork failed\n");

        exit;

    }

    // 자식 프로세스 일때 

    if($pid == 0)

    {

        $buf = socket_read($sock, 4096);


        // 클라이언트에서 받은 데이타 처리하는 부분

        msg("recive data : ".$buf."\n");    // 클라이언트에게 받은 메세지

        msg("client(".$sockPort.") time data request\n");

        $re = "Complete launching server";    // 클라이언트에게 응답할 메세지

        socket_write($sock, $re);

        msg("client disconnect : ".$sockIp.":".$sockPort."\n");

        socket_close($sock);

        exit;

    }

}


function msg($msg)

{

    echo "SERVER >> ".$msg;

}

?>


실행 권한 부여 및 작성후 데몬 구동


# chmod 700 server.php

# ./server.php &




2. 클라이언트에서 접속 파일 생성


# vi client.php


#!/usr/local/php/bin/php -q

<?php

define("_IP",    "192.168.10.2");    // 접속할 서버 IP

define("_PORT",  "81");                // 접속할 서버 PORT


$sock      = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

socket_connect($sock, _IP, _PORT);

msg("socket connect to "._IP.":"._PORT."\n");


// 서버로 보낼 데이타

$stdin = "time";

socket_write($sock, $stdin);

$sMsg  = socket_read($sock, 4096);


msg("result : ".$sMsg."\n");


socket_close($sock);

exit;


// 로그를 출력합니다. 디버그용

function msg($msg)

{

    echo "CLIENT >> ".$msg;

}

?>




3. 테스트


client 에서 생성한 client.php 파일을 실행합니다.


# ./client.php

# ./client_multi.php

CLIENT >> socket connect to 192.168.30.20:444

CLIENT >> result : Complete launching server


* 참고로 (client 접속 당시) 서버 콘솔에 출력된 메세지 입니다.


# SERVER >> client connect : 192.168.30.40:32966

SERVER >> recive data : time

SERVER >> client(32966) time data request



[참조하여 작성함] http://www.phpschool.com/class/php_multi_socket_server3.html

반응형

댓글()

530 user cannot log in 오류 해결 (IIS 7.5)

윈도우즈/IIS|2016. 10. 20. 11:24
반응형








[출처] http://cafe.naver.com/myvb/65490

반응형

댓글()

값이 배열 안에 존재하는지 확인하는 in_array함수

프로그래밍/PHP|2016. 10. 17. 12:28
반응형

<?php 

 $os = array("Mac", "NT", "Irix", "Linux"); 


 if (in_array("NT", $os)) { 

      echo "NT가 존재합니다."; 

 } 

 // 결과: NT가 존재합니다. 


 // 이 함수는 대소문자를 구분하므로 false입니다. 

 if (in_array("mac", $os)) { 

      echo "찾는 문자가 존재합니다."; 

 } 

 // 결과: 

 ?>



[출처] http://habony.tistory.com/82

반응형

댓글()

php 로 소켓 프로그램 만들기 (다중 처리 불가, queue 진행 방식)

프로그래밍/PHP|2016. 10. 14. 13:32
반응형

- 본 예제는 client 의 다중 접속 처리가 되지 않는 1 client 를 위한 코드 입니다.

  동시에 두개의 요청이 들어오게 되면 먼저 들어온 요청 처리 후, 대기 되었던 두번째 요청을 처리하게 됩니다.


- 본 예제는 server 에서 보내주는 메세지를 client 에서 확인하는 예제입니다.




1. 서버에서 데몬 생성


# vi server.php


#!/usr/local/php/bin/php -q    // php 실행 파일

<?php

set_time_limit(0);    // 작업을 마칠때까지 세션을 끊지 않음

define("_IP",    "192.168.10.2");    // 서버 IP

define("_PORT",  "443");                // 서버에서 사용할 PORT


$sSock      = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

socket_bind($sSock, _IP, _PORT);

socket_listen($sSock);

while($cSock = socket_accept($sSock))

{

    socket_getpeername($cSock, $addr, $port);

    echo "SERVER >> client connected $addr:$port \n";

    $date = date("Y/m/d H:i:s");

    socket_write($cSock, $date);

    socket_close($cSock);

    echo "SERVER >> client Close.\n";

}

?>


실행 권한 부여 및 작성후 데몬 구동


# chmod 700 server.php

# ./server.php &




2. 클라이언트에서 접속 파일 생성


# vi client.php


#!/usr/bin/php -q    // php 실행 파일

<?php

set_time_limit(0);    // 작업을 마칠때까지 세션을 끊지 않음

define("_IP",    "192.168.10.2");    // 서버 IP

define("_PORT",  "443");               // 서버에서 사용하는 PORT


$sock      = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);

socket_connect($sock, _IP, _PORT);

echo "CLIENT >> socket connect to "._IP.":"._PORT."\n";

$date = socket_read($sock, 4096);

echo "CLIENT >> this time is $date \n";

socket_close($sock);

echo "CLIENT >> socket closed.\n";

?>




3. 테스트


client 에서 생성한 client.php 파일을 실행합니다.


# ./client.php

CLIENT >> socket connect to 192.168.10.2:443

CLIENT >> this time is 2016/10/14 13:27:49 

CLIENT >> socket closed.


* 참고로 (client 접속 당시) 서버 콘솔에 출력된 메세지 입니다.


SERVER >> client connected 192.168.10.3:44450 

SERVER >> client Close.




* 내용 추가


client 에서 server 로 메세지를 보내기 위해서는 각각의 파일에 아래 내용을 추가해줍니다.


# vi client.php


$message="Hero";

socket_write($sock, $message, strlen($message)) or die("Could not send data to server\n"); 


# vi server.php


$input = socket_read($cSock, 4096) or die("Could not read input\n");

echo "$input";


반응형

댓글()

sshpass 사용법

리눅스/OS 일반|2016. 10. 11. 17:41
반응형

목차


1 개요


2 활용예시 1: sshpass + ssh (접속)


3 활용예시 2: sshpass + ssh (명령어 실행)


4 활용예시 3: sshpass + scp (파일 보내기)


5 참고 자료




활용예시 1: sshpass + ssh (접속)


명령어

sshpass -p패스워드 ssh -o StrictHostKeyChecking=no 아이디@호스트주소


실행예시

[root@zetawiki ~]# sshpass -pP@ssw0rd ssh -o StrictHostKeyChecking=no root@135.79.246.99

Warning: Permanently added '135.79.246.99' (RSA) to the list of known hosts.

Last login: Wed Nov 27 15:52:59 2013 from 135.79.246.80

[root@jmtest01 ~]#

→ 135.79.246.80(jmnote) → 135.79.246.99(jmtest01) 접속



활용예시 2: sshpass + ssh (명령어 실행)


명령어

sshpass -p패스워드 ssh -o StrictHostKeyChecking=no 아이디@호스트주소 명령어


실행예시

[root@zetawiki ~]# sshpass -pP@ssw0rd ssh -o StrictHostKeyChecking=no root@135.79.246.99 hostname

jmnote02

[root@zetawiki ~]#

→ 135.79.246.99에서 hostname 명령어가 실행되어 원격서버의 호스트명 jmnote02가 출력됨



활용예시 3: sshpass + scp (파일 보내기)


명령어

sshpass -p패스워드 scp -o StrictHostKeyChecking=no 로컬파일 아이디@호스트주소:/폴더/파일명


실행예시

[root@zetawiki ~]# sshpass -pP@ssw0rd scp -o StrictHostKeyChecking=no hello.txt root@135.79.246.99:/root/hello.txt

[root@zetawiki ~]# sshpass -pP@ssw0rd ssh -o StrictHostKeyChecking=no root@135.79.246.99

Last login: Wed Nov 27 15:56:26 2013 from 135.79.246.80

[root@jmtest01 ~]# ll hello.txt

-rw-r--r-- 1 root root 6 Nov 27 16:03 hello.txt

→ 135.79.246.80(jmnote)에서 135.79.246.99(jmtest01)로 hello.txt 복사




[출처] http://zetawiki.com/wiki/%EB%A6%AC%EB%88%85%EC%8A%A4_sshpass_%EC%82%AC%EC%9A%A9%EB%B2%95



내용 추가 ==============


1) 변수 이용

쉘스크립트에서 사용할 경우 변수 지정을 먼저 하고 가져다 쓰면 편리합니다.

server_cmd="sshpass -p1q2w3e4r ssh -o StrictHostKeyChecking=no root@192.168.10.2"


# $server_cmd df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

                       19G  8.6G  8.8G  50% /

/dev/sda1              99M   41M   54M  43% /boot

tmpfs                 249M     0  249M   0% /dev/shm


2) ssh 포트가 기본 포트가 아닐경우
sshpass -p1q2w3e4r ssh -t -p220 -o StrictHostKeyChecking=no root@192.168.10.2

3) scp 와 특정 포트를 동시 사용

sshpass -p1q2w3e4r scp -P220 -o StrictHostKeychecking=no /root/crm/crm.log root@192.168.10.2:/root/


4) 여러줄의 명령을 보낼 경우

a.txt 에 아래 내용 넣은 후

touch 111

touch 222

아래와 같이 실행합니다.

cat a.txt |$server_cmd



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



반응형

댓글()

우분투 ppa 관리 (리스트/추가/삭제)

리눅스/OS 일반|2016. 10. 10. 14:36
반응형

1. 리스트 확인

grep ^'deb ' /etc/apt/sources.list /etc/apt/sources.list.d/*.list


2. 추가

add-apt-repository ppa:PPA_NAME


3. 삭제

add-apt-repository --remove ppa:PPA_NAME


반응형

댓글()