Linux2014. 11. 26. 17:07

# 리눅스 서버 root 비밀번호시 변경시에 체크를 위해 사용함.


# 패스워드가 입력된 파일이 있는지 확인 

# find . -name "*" -exec grep "검색어" {} \; 1> 로그저장파일.txt 2>&1 &

'Linux' 카테고리의 다른 글

CentOS pear,soap 설치  (0) 2014.05.07
CentOs NFS설정  (0) 2014.03.20
CentOS 6.3 APM설치  (0) 2014.02.28
[급펌] CentOS memcach 설치  (0) 2013.06.24
[Linux] ssh 디렉터리 삭제. 안지워지고 에러날때??  (0) 2013.05.23
Posted by E.No
Linux/PHP2014. 5. 8. 19:49

php에서 soap 통신을 하기위하여 앞서 php-soap 를 설치하고 

검색을 통해서 알게된 사실이다. 


정확하게 인지한것인지는 모르겠지만.. (만약 잘못된 정보라면 알려주시면 감사드립니다.)


php-4.* 버젼에서는 soap기본지원이 되지 않고 php5.*버젼에서 기본 지원하기때문에 nusoap라는 클래스가 

양쪽 모두 사용가능하여 php soap 통신을 위하여 가장 많이 쓰이며, 간편한 라이브러리라고 한다.


여튼 나는 nusoap클래스를 사용하여 서버, 클라이언트를 테스트 해보았고,

잘 되는것을 확인 하였다.


우선 아래는 찾아봤던 내용의 링크이다.

nusoap 다운로드)

- http://sourceforge.net/projects/nusoap/


예제 )

- http://stackoverflow.com/questions/9130117/nusoap-simple-server

- http://patelmilap.wordpress.com/2011/09/01/soap-simple-object-access-protocol/


soap 관련 설명등)

- http://www.welog.net/gbbs/bbs/board.php?bo_table=php&wr_id=186 (예제)

- http://www.welog.net/gbbs/bbs/board.php?bo_table=php&wr_id=187 (개념)


# nusoap-server.php


$root = $_SERVER["DOCUMENT_ROOT"];

require_once($root.'/Lib/Class/nusoap/nusoap.php');

$server = new soap_server;

$strURL = "www.testNuSoap.com"; #네임스페이스 지정을 해주는것인데 사실 왜 해주는것인지 정확히 모르겠다..

$strNameSpace = $strURL."?wsdl";

$server->configureWSDL("testnusoap",$strNameSpace); //wsdl 생성

$server->register('hello_func',array("name"=>"xsd:string"),array("return"=>"xsd:string")); //함수 등록

# 함수를 등록할때 어는곳에서는 $server->register('hello_func'); 이렇게만 지정을 한다.

# 나의 경우 뒤에 배열 옵션들은 받는 인수, 리턴될 값에 대한 타입을 지정해줬다. 

# 이렇게 하지 않으면 출력이 안되더라.. 왜지?


function hello_func($name){

//  에러시 falt 메시지 전달

    if($name == ''){

    return new soap_fault('Client','','Must supply a valid name.');

    }

    return "hello ".$name;

}

$server->service($HTTP_RAW_POST_DATA);




# nusoap-client.php


ini_set("soap.wsdl_cache_enabled", "0");

$root = $_SERVER["DOCUMENT_ROOT"];

require_once($root.'/Lib/Class/nusoap/nusoap.php');

try{

## 서버 server.php 의 URL을 넘겨줌

$strServerURL = "http://192.168.30.24/soap/nusoap-server.php?wsdl"

$soapclient = new soapclient($strServerURL);

## 서버에서 실행할 함수호출

$parameters = urlencode("Eno");

$result = $soapclient->hello_func($parameters);

echo urldecode($result);

}catch(SoapFault $exception){

echo $exception->getMessage();

}



# 결과 


hello Eno



위 소스는 server.php 에서 wsdl을 생성, client.php에서 해당 내용을 읽어 server.php의 함수를 사용하는것. 이게 주된 내용이다.


nusoap를 사용하기 이전에 php.net에 나와있는것처럼 

SoapServer, SoapClient 클래스를 사용하여 테스트를 했을때는 아래와 같았다.



# soap-server.php


function printString($nCode)

{

if($nCode == "1")

{

return "1입력";

}else{

return "그외 입력됨.";

}

}

 

try {

$server = new SOAPServer(NULL,array('uri' => 'http://192.168.30.24/soap/soap-server.php'));

 

$server->addFunction("printString");

$server->handle();

}catch(SOAPFault $f){

print $f->faultstring;

}



# soap-client.php


$client = new SoapClient(null, array('location' => "http://192.168.30.24/soap/soap-server.php",'uri' => "http://192.168.30.24/soap/soap-server.php"));

echo $return = $client->__soapCall("printString",array("1"));



# 결과

1입력



결국 두개다 server.php에서 선언된 함수 사용이 가능했다.

확인은 했지만.. 실제 적용을 해야하는데 개념이 잘 안잡힌다. OTL 


업무를 진행하고나서 이번 포스트에는 수정해야 할 내용이 많을것같다.


이상 여튼 soap사용법은 이러하다.



Posted by E.No
Linux2014. 5. 7. 16:21

검색을 하다보니까 pear 이 기본설치가 되어있다.. 안되어있다 등등(포트팅 날짜를 확인하지 않은 내 죄 니라..)

여튼 pear 설치 방법도 여러가지가있고..


괜히 겁먹고 검색하는데 시간을 너무 많이 허비했다.


CentOS에서는 간단하다. (역시 yum설치가 최고..!)

yum으로 APM설치를 했을 경우,


# yum -y install php-pear*

# yum -y install php-soap

# service httpd restart 


이상 phpinfo 에서 soap가 enabled되어 있는것을 확인 할 수 있다.


soap통신 사용에 대해서는 일단 진행후에.. 간략히 남겨놓도록 하자.!

'Linux' 카테고리의 다른 글

linux 특정문자가 있는 파일 확인  (0) 2014.11.26
CentOs NFS설정  (0) 2014.03.20
CentOS 6.3 APM설치  (0) 2014.02.28
[급펌] CentOS memcach 설치  (0) 2013.06.24
[Linux] ssh 디렉터리 삭제. 안지워지고 에러날때??  (0) 2013.05.23
Posted by E.No
Linux2014. 3. 20. 16:59

파일서버 구축하다가 필요해서...


일단 CnetOs 에는 설치시에 기본적으로 nfs가 설치된다고 하니 굳이 설치하지 않아도 된다.


nfs설치 확인 

# rpm -qa nfs-utils 

nfs-utils-1.2.3-36.el6.x86_64



만약 설치되지 않았다면 yum을 이용해 설치해주자.

# yum -y install nfs-utils



설치가 되었다면 큰 맥락은 아래와 같다.


- 서버

1) /etc/exports 에 설정 정보입력

2) nfs 서비스 시작


- 클라이언트

1) 공유 디렉터리 마운트


@ 여기까지만 해도 사용 할 수는 있다.


- 그 외 사항 

1) 방화벽에서 nfs서비스의 Port를 차단 할 경우 iptables에 정책 추가

2) 서버가동시 nfs가 자동실행되도록 서비스를 등록하자.

3) 서버가동시 공유디렉토리가 영구 설정되도록 /etc/fstab 파일을 편집.





서버와 클라이언트에서 세부 사항은 아래와같이 진행하지.


- 서버

1) /etc/exports 에 설정 정보입력


# vi /etc/exports 


/[공유디렉터리] [접속허용서버IP]([옵션],[옵션],..)


ex) /Upload xxx.xxx.xxx.xxx(rw,sync) -> 여기 rw 옵션은 읽기,쓰기 가능하게.. sync는 뭐 싱크 뭐시기이겠지..?;;


위 처럼 추가해주자!







2) nfs 서비스 시작


서비스 시작은 다른 서비스를 시작하는것과 마찬가지로.

# service nfs start 





- 클라이언트

1) 공유 디렉토리 마운트


마운트 역시는 아래 명령어처럼..


# mount [서버IP]:[공유경로] [공유경로(마운트디렉토리]]


@아참.. 마운트 전에 디렉토리 부터 생성해야한다.. 


# mkdir [마운트디렉토리]



ex) 

# mkdir /Upload

# mount xxx.xxx.xxx.xxx:/Upload /Upload


@ 나같은 경우에 공유,마운트 디렉토리를 절대경로로 하지 않았더니 에러가 발생했다.   mount 시에 절대경로를 꼭 사용해야하는지는 잘 모르겠음.... ㅡ,.ㅡ




이렇게 하면 일단 이미지서버의 디렉토리가 공유된다.



- 그 외 사항에 대해서는 간략하게!..


1) 방화벽에서 nfs서비스의 Port를 차단 할 경우 iptables에 정책 추가

이쪽에 대해서는 http://hmgirl.tistory.com/152 여기 주인장분이 정리를 잘 해 주셨다...


2) 서버가동시 nfs가 자동실행되도록 서비스를 등록하자.

# chkconfig --level 2345 nfs on


3) 서버가동시 공유디렉토리가 영구 설정되도록 /etc/fstab 파일을 편집.

# vi /etc/fstab

xxx.xxx.xxx.xxx:/Upload /Upload    nfs    hard    0 0  #추가!


- fstab 수정 후 netfs 활성화


# chkconfig --level 35 netfs on



이상 끝.



'Linux' 카테고리의 다른 글

linux 특정문자가 있는 파일 확인  (0) 2014.11.26
CentOS pear,soap 설치  (0) 2014.05.07
CentOS 6.3 APM설치  (0) 2014.02.28
[급펌] CentOS memcach 설치  (0) 2013.06.24
[Linux] ssh 디렉터리 삭제. 안지워지고 에러날때??  (0) 2013.05.23
Posted by E.No
Linux2014. 2. 28. 11:59

정리해두었던 문서도 있지만 


제일 깔끔하게 정리해놓으신것같아 참조.


http://want2u.tistory.com/11


굳.


추가로 vsftpd 와 ssh도 설치해주면 기본적인 세팅은 끝난듯.


vsftpd

# yum -y install vsftpd 

# chkconfig --level 2345 vsftpd on

# service vsftpd start 


sshd

# yum -y install openssh-server openssh-clients openssh-askpass 

# chkconfig --level 2345 sshd on

# service sshd start 



'Linux' 카테고리의 다른 글

linux 특정문자가 있는 파일 확인  (0) 2014.11.26
CentOS pear,soap 설치  (0) 2014.05.07
CentOs NFS설정  (0) 2014.03.20
[급펌] CentOS memcach 설치  (0) 2013.06.24
[Linux] ssh 디렉터리 삭제. 안지워지고 에러날때??  (0) 2013.05.23
Posted by E.No
Linux/Apache2013. 10. 21. 10:42

자꾸만 까먹어서..

chkconfig levels 2345 [서비스명] on

ex) chkconfig --levels 2345 httpd on 


각 레벨(숫자)의 의미는 아래와 같다

1: halt (종료모드)

2: single user mode (단일 사용자 모드, 시스템 복구시)

3: multiuser, without NFS (The same as 3, if you do not have networking)

4: unused

5: X11 (다중사용자 모드 X window mode login)

6: reboot (재부팅)


추가할때는 

chkconfig --add [서비스명]


/************
httpd 서비스는 chkconfig 를 지원하지 않습니다 라고 출력시 

 [root@localhost /]# vi /etc/init.d/httpd

#!/bin/sh 밑에 추가 5줄

# chkconfig: 2345 90 90
# description: init file for Apache server daemon
# processname: /usr/local/server/apache/bin/apachectl
# config: /usr/local/server/apache/conf/httpd.conf
# pidfile: /usr/local/server/apache/logs/httpd.pid

*************/


확인 할때

chkconfig --list [서비스명]


삭제 할때

chkconfig --del [서비스명]


이상.




Posted by E.No
Linux/Apache2013. 7. 24. 11:20

 

root 계정으로

#ln -s [실제 위치] /가상디렉터리명

 

Posted by E.No
Linux2013. 6. 24. 21:41

* CentOS 6.x 64비트 환경에 php 5.4버전에 memcache 설치.

* yum 저장소 추가
rpm -Uhv http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm

yum -y install memcached


*****************************************************
만약 패키지가 없어서 설치가 안 되거나, 최신 버전으로 rpm을 만들어서 설치할려면 실행

최신 버전 다운로드
wget http://memcached.org/latest

* 의존성 에러가 날 경우
yum install gcc libevent libevent-devel

* 현재 1.4.15버전이 가장 최신 버전일 경우
rpmbuild -ta memcached-1.4.15.tar.gz

파일 생성시간이 조금 걸리니 에러없이 처리되면 rpm 파일을 생성된다.


* rpm 파일의 생성을 확인한다.
ll /root/rpmbuild/RPMS/x86_64/memcached-1.4.15-1.el6.x86_64.rpm


memcached-1.4.15-1.x86_64.rpm
memcached-debuginfo-1.4.15-1.x86_64.rpm

두개의 파일이 생성되어 있다.

* 설치
rpm -Uvh /root/rpmbuild/RPMS/x86_64/memcached-1.4.15-1.el6.x86_64.rpm
rpm -qa |grep memcached
*****************************************************


* 내용 확인
vi /etc/sysconfig/memcached
-----------------------------------------------
PORT=”11211″ #define on which port to urn
USER=”nobody” #same as apache user
MAXCONN=”1024″ #maximum number of connections allowed
CACHESIZE=”64″ #memory used for caching
OPTIONS=”" #use for any custom options
-----------------------------------------------

memcached -h

/etc/init.d/memcached start

/etc/init.d/memcached status

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

memcached (pid 9795)를 실행 중...

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


netstat -anp | grep 11211
-----------------------------------------------
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 9795/memcached
udp 0 0 0.0.0.0:11211 0.0.0.0:* 9795/memcached
-----------------------------------------------

* php 확장 모듈 설치


cd /home/admin/
wget http://pecl.php.net/get/memcache-2.2.7.tgz


tar zxvf memcache-2.2.7.tgz
cd memcache-2.2.7
phpize
./configure
make
make install


# 만약 아래의 에러가 발생할때에 추가해준다.

error: memcache support requires ZLIB.

yum install zlib-devel


php -i | grep php.ini
-----------------------------------------------
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
-----------------------------------------------

# 아래의 에러가 발생할때 수정해준다.

PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function.


vi /etc/php.ini

[Date]
date.timezone = Asia/Seoul



ll /usr/lib64/php/modules/memcache.so

vi /etc/php.d/memcache.ini
-----------------------------------------------
extension = memcache.so
-----------------------------------------------

cat memcache.ini
-----------------------------------------------
extension = memcache.so
-----------------------------------------------

/etc/init.d/httpd restart

php -i | grep memcache
-----------------------------------------------
/etc/php.d/memcache.ini,
memcache
memcache support => enabled
memcache.allow_failover => 1 => 1
memcache.chunk_size => 8192 => 8192
memcache.default_port => 11211 => 11211
memcache.default_timeout_ms => 1000 => 1000
memcache.hash_function => crc32 => crc32
memcache.hash_strategy => standard => standard
memcache.max_failover_attempts => 20 => 20
Registered save handlers => files user memcache
-----------------------------------------------

* 모듈 확인
php -m
memcache


* 항상 실행

chkconfig memcached on

chkconfig --list |grep memcached


* 브라우저에서 확인
vi test_mem.php
-----------------------------------------------
<?php
$memcache = new Memcache;
$memcache->connect('localhost', 11211) or die ("Could not connect");

$version = $memcache->getVersion();
echo "Server's version: ".$version."<br/>\n";

$tmp_object = new stdClass;
$tmp_object->str_attr = 'test';
$tmp_object->int_attr = 123;

$memcache->set('key', $tmp_object, false, 10) or die ("Failed to save data at the server");
echo "Store data in the cache (data will expire in 10 seconds)<br/>\n";

$get_result = $memcache->get('key');
echo "Data from the cache:<br/>\n";

var_dump($get_result);
?>
-----------------------------------------------


브라우저에서 대략 이런 문자가 나타나면 성공
-----------------------------------------------
Server's version: 1.4.5
Store data in the cache (data will expire in 10 seconds)
Data from the cache:
object(stdClass)#3 (2) { ["str_attr"]=> string(4) "test" ["int_attr"]=> int(123) }
-----------------------------------------------

'Linux' 카테고리의 다른 글

linux 특정문자가 있는 파일 확인  (0) 2014.11.26
CentOS pear,soap 설치  (0) 2014.05.07
CentOs NFS설정  (0) 2014.03.20
CentOS 6.3 APM설치  (0) 2014.02.28
[Linux] ssh 디렉터리 삭제. 안지워지고 에러날때??  (0) 2013.05.23
Posted by E.No
Linux2013. 5. 23. 20:17

하위 폴더 모두 삭제했는데..

FTP등 접속했을때 폴더가 남아있고 지워지지 않을때..

권한문제로 안지워질경우가 있다..

그럴때는

rm -rf 폴더명

 

'Linux' 카테고리의 다른 글

linux 특정문자가 있는 파일 확인  (0) 2014.11.26
CentOS pear,soap 설치  (0) 2014.05.07
CentOs NFS설정  (0) 2014.03.20
CentOS 6.3 APM설치  (0) 2014.02.28
[급펌] CentOS memcach 설치  (0) 2013.06.24
Posted by E.No
Linux/Apache2013. 4. 3. 18:02

FTP, SSH 특정 IP 접속 허용

#vi etc/hosts.deny 

 

ssh : xxx.xxx.xxx.xxx #허용 IP 추가

vsftp : xxx.xxx.xxx.xxx #허용 IP 추가

 

저장 후 닫기.-> 바로 적용됨.

 

웹사이트 접근 허용

# vi etc/httpd/conf/httpd.conf

 

디렉터리 설정에..

 

<Directory "웹컨텐츠 디렉터리">

Order deny,allow    

Deny from all           
    # 아래 허용 IP추가
    Allow from xxx.xxx.xxx.xxxx
    Allow from xxx.xxx.xxx.xxxx

</Directory>

 

저장 후 닫기 -> 아파치 재시작 or httpd 서비스 재시작

 

 

Posted by E.No