[아파치] PHP Notice:  Undefined index: 에러


/var/log/httpd/ 로그파일에 "PHP Notice:  Undefined index:" 같은 에러가 엄청 많이 기록이 되는군요~

소스를 수정하여도 되겠지만 너무 많다면 로그가 안나오게 할 수도 있습니다.


# vi /etc/php.ini 수정

;error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

error_reporting = E_ALL & ~E_DEPRECATED & ~(E_NOTICE | E_WARNING)

~E_STRICT => ~(E_NOTICE | E_WARNING) 로 수정하고 아파치를 재시작 합니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

[리눅스] 쉘스크립트 실행 /bin/sh^M 오류


윈도우에서 만들어진 쉘스크립트 파일을 시놀로지에 넣어서 실행하니깐 아래와 같은 오류가 생기더군요~

root@mynas:~/bin# ./test.sh

-ash: ./test.sh: /bin/sh^M: bad interpreter: No such file or directory

또는

line 1: #!/bin/sh: No such file or directory ( <feff> 유니코드 BOM 으로 저장된 경우 )

개행 문자를 unix 로 바꿔주어야 합니다.


# vi test.sh

:set fileformat=unix

저장하고 다시 실행해보세요~


line 1: #!/bin/sh: No such file or directory

이렇게 나온다면

# vi -b test.sh 로 실행해서 

<feff>#!/bin/sh

위와 같이 나오면 앞에 문자를 지워주고 저장하면 됩니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

[리눅스] PHP SESSION 저장 안되는 문제


아파치에서 VirtualHost 를 다른 소유자로 변경하고 재시작 했더니 잘되던 phpmyadmin 에서 아래와 같은 오류가 뜨더군요~

mod_ruid2 모듈과 함께 사용중인데 원인을 찾는데 함참 걸렸네요~

import.php: Missing parameter: import_type

import.php: Missing parameter: format

세션이 저장되는 폴더 /var/lib/php/session 폴더의 퍼미션을 777로 바꾸어도 안되더니 가만 생각해 보니 그 안에 원래 있던 세션 파일의 소유자가 달라서 그렇더군요~

해당 파일을 지우고 하니 잘 됩니다~


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

[CentOS] vnstat 갱신이 안되는 문제


같은 버전의 CentOS 7.x 버전에서 vnstat 을 설치했는데 어떤 서버는 괜찮고 어떤 서버는 아래와 같이 갱신이 안되네요~

vnstat -d 명령어로 "enp2s0: Not enough data available yet." 와 같은 메시지가 뜬다면 /var/log/message 를 확인해보세요~

Mar 17 05:02:40 example vnstatd: Info: Monitoring: enp2s0 (1000 Mbit)

Mar 17 05:02:40 example vnstatd: Error: Unable to open database "/var/lib/vnstat/enp2s0" for writing: Permission denied

Mar 17 05:02:40 example vnstatd: Error: Unable to write database, continuing with cached data.


/var/log/message 파일에 위와 같은 에러가 있다면 /var/lib/vnstat/ 폴더에 이더넷 파일의 소유권을 확인해 보세요~


# ls -l /var/lib/vnstat/

total 4

-rw-r--r-- 1 root root 2792 Mar 18 16:14 enp2s0

root 로 되어 있다면 vnstat 으로 변경해 줍니다.

chown vnstat.vnstat /var/lib/vnstat/enp2s0


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

phpMyAdmin 로그인 세션 시간 변경



phpMyAdmin 에 접속하고 얼마되지 않았는데도 세션이 금방 만료가 됩니다.

로그인 쿠키 유효시간이 default 1440 초, 분으로 24분으로 되어있기 때문입니다.

$cfg['Servers'][$i]['auth_type']     = 'cookie';

 ==>

$cfg['Servers'][$i]['auth_type']     = 'http';

cookie 를 http 로 변경하여도 되지만, 나중에 재로그인시 바뀐 URL 주소로는 정상적으로 로그인이 안되는 현상이 생깁니다.


▶ /etc/phpMyAdmin/config.inc.php 수정


...

$cfg['VersionCheck'] = FALSE;

$cfg['LoginCookieValidity'] = 43200;

?>

위와 같이 $cfg['LoginCookieValidity'] 값에 적당한 시간 값을 초단위로 넣어주면 됩니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

[CentOS] 네임서버 1차 2차 3차 구축 방법


서브 도메인이 많은 경우라면 네임서버(DNS)를 직접 구축해서 운영하는게 편하고 단순히 www 만 서비스 한다면 도메인 업체의 네임서버를 이용하는게 편합니다.

직접 운영하려면 도메인의 네임서버 호스트를 구축하려는 1차, 2차, 3차 IP로 지정하여야 합니다.

# yum -y install bind bind-chroot bind-libs bind-utils


bind 설치 후 환경설정을 1차에서 zone 파일 수정시 2차, 3차까지 동기화 되도록 합니다.


▶ 1차, 2차, 3차 /etc/named.conf 수정

options {

        version "Unknown";

        allow-transfer { 2차ip; 3차ip; }

        allow-recursion { localhost; any; };

        allow-query-cache { localhost; any; };

        listen-on port 53 { 127.0.0.1; any; };

        //listen-on-v6 port 53 { ::1; };

        directory       "/var/named";

        dump-file       "/var/named/data/cache_dump.db";

        statistics-file "/var/named/data/named_stats.txt";

        memstatistics-file "/var/named/data/named_mem_stats.txt";

        recursing-file  "/var/named/data/named.recursing";

        secroots-file   "/var/named/data/named.secroots";

        allow-query     { localhost; any; };

        recursion yes;

}

allow-transfer 는 1차 네임서버 /etc/named.conf 에만 있으면 됩니다.


▶ 1차, 2차, 3차 /etc/rndc.key 1차와 동일하게 설정


▶ 1차 /etc/named.rfc1912.zones 편집

zone "example.com" IN {

        type master;

        file "example.com.zone";

        allow-update { 2차ip; 3차ip; };

};


▶ 2차, 3차 /etc/named.rfc1912.zones 편집

zone "example.com" IN {

        type slave;

        file "example.com.zone";

        masters { 1차IP; };

};


▶ 환경설정 확인

# named-checkconf -z

1차에서 설정한 도메인이 리스트에 나오는지 확인합니다.


그리고 기존의 zone 파일 있다면 지우면 됩니다.

아니면 chown named.named /var/named/*.zone 명령어로 퍼미션을 조정하여야 2차 네임서버에서 파일 갱신이 됩니다.


위와 같이 잘 설정이 되었다면 1차 네임서버에서 named 를 재시작하면 2차 네임서버의 /var/named/*.zone 파일이 동기화가 됩니다.

하지만 텍스트 파일이 아닌 바이너리 파일 형태로 넘어갑니다.

zone 파일을 동기화를 하지 않는다면 rsync 유틸로 동기화 해서 cron 으로 named 를 재시작 해도 될 것 같습니다.



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

[CentOS] 7.x 아파치 2.4.x mod_cband 0.9.7.5 컴파일



Apache 트래픽 제어 모듈은 cband 만한게 없는 것 같네요~

CBandScoreboard 설정시 "apache2_mod_cband: cannot open scoreboard file" 같은 에러는 해당 경로의 퍼미션을 조정하면 됩니다.

CBandUser (apache 또는 root로 생성) 를 설정하고 VirtualHost (mod_ruid2 로 유저계정) 에서 사용시 파일권한이 달라서 나는 에러는 666 으로 변경하여 주세요~


# wget https://github.com/vobruba-martin/mod_cband/archive/0.9.7.5.tar.gz

# tar zxvf 0.9.7.5.tar.gz

# cd mod_cband-0.9.7.5

# ./configure  ## configure: error: apxs missing 에러가 납니다.

checking for gcc... gcc

checking for C compiler default output file name... a.out

checking whether the C compiler works... yes

checking whether we are cross compiling... no

checking for suffix of executables...

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ANSI C... none needed

checking whether make sets $(MAKE)... yes

checking for apr_palloc in -laprutil... no

checking for an ANSI C-conforming const... yes

checking for apxs... no

checking for apxs2... no

configure: error: apxs missing

httpd-devel 을 설치해 줍니다.


# yum -y install httpd-devel

# ./configure

checking for gcc... gcc

checking for C compiler default output file name... a.out

checking whether the C compiler works... yes

checking whether we are cross compiling... no

checking for suffix of executables...

checking for suffix of object files... o

checking whether we are using the GNU C compiler... yes

checking whether gcc accepts -g... yes

checking for gcc option to accept ANSI C... none needed

checking whether make sets $(MAKE)... yes

checking for apr_palloc in -laprutil... no

checking for an ANSI C-conforming const... yes

checking for apxs... apxs

checking how to run the C preprocessor... gcc -E

checking for egrep... grep -E

checking for ANSI C header files... yes

checking for sys/types.h... yes

checking for sys/stat.h... yes

checking for stdlib.h... yes

checking for string.h... yes

checking for memory.h... yes

checking for strings.h... yes

checking for inttypes.h... yes

checking for stdint.h... yes

checking for unistd.h... yes

checking stdio.h usability... yes

checking stdio.h presence... yes

checking for stdio.h... yes

checking for string.h... (cached) yes

checking assert.h usability... yes

checking assert.h presence... yes

checking for assert.h... yes

checking ctype.h usability... yes

checking ctype.h presence... yes

checking for ctype.h... yes

checking errno.h usability... yes

checking errno.h presence... yes

checking for errno.h... yes

checking math.h usability... yes

checking math.h presence... yes

checking for math.h... yes

checking netinet/in.h usability... yes

checking netinet/in.h presence... yes

checking for netinet/in.h... yes

checking sys/socket.h usability... yes

checking sys/socket.h presence... yes

checking for sys/socket.h... yes

checking arpa/inet.h usability... yes

checking arpa/inet.h presence... yes

checking for arpa/inet.h... yes

configure: creating ./config.status

config.status: creating Makefile


# make

# make install


# find / -name mod_cband.so 명령어로 제대로 설치가 되었는지 확인하면 됩니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

[리눅스] 아파치 트래픽 제어


Apache 2.2.x 속도 제어 모듈중에 mod_cband 가 있습니다.

2.4 버전에서도 사용은 가능하지만 약간의 수정이 필요합니다.

mod_qos 라는 모듈도 있는데 yum install mod_qos 로 설치가 가능합니다.

yum install epel_release 가 먼저 설치되어 있어야 합니다.


아래는 mod_qos 기본적인 설정입니다.

/etc/httpd/conf.d/qos.conf 파일을 만들어 주면 됩니다.

# allows max 50 connections from a single ip address:

QS_SrvMaxConnPerIP                        50

# limits download bandwidth to 5Mbit/sec (resp. 640kbytes/sec)

#QS_LocKBytesPerSecLimit       /           640

# 100Mbps

QS_LocKBytesPerSecLimit       /           12800

# disables connection restrictions for certain clients:

QS_SrvMaxConnExcludeIP                    127.0.0.1

QS_SrvMaxConnExcludeIP                    192.168.1.

# Brute Force

# allows a single IP addess to access the URI /wp-login.php not more

# than 10 times within an hour:

SetEnvIf                 Request_URI ^/wp-login.php LimitLogin

QS_ClientEventLimitCount 10 3600 LimitLogin


# Status Viewer

<Location /qos>

    SetHandler qos-viewer

    Order Deny,Allow

    Deny from All

    Allow from 127.0.0.1

</Location>

status 에 자신의 아이피를 넣어주면 됩니다.


최신 버전을 사용하려면 https://sourceforge.net/projects/mod-qos/files/ 여기에서 최신버전을 다운로드 받으면 됩니다.

사용방법은 http://mod-qos.sourceforge.net/ 여기를 참고하세요~



블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

[CentOS] KVM CDROM 꺼내기

LINUX 2018. 12. 7. 16:44

[CentOS] KVM CDROM 꺼내기



이전에 설치한 VPS 를 또 설치하려니 아래처럼 이미 디스크가 사용중이라고 에러가 나는군요~


ERROR    Disk /var/lib/libvirt/boot/CentOS-7-x86_64-Minimal-1810.iso is already in use by other guests ['CentOS7'].


사용된 이미지를 꺼내는 방법입니다.


[root@vps images]# virsh domblklist CentOS7

Target     Source

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

hda        /var/lib/libvirt/boot/CentOS-7-x86_64-Minimal-1810.iso

vda        /var/lib/libvirt/images/CentOS7.img


[root@vps images]# virsh change-media CentOS7 hda --eject

Successfully ejected media.

[root@vps images]# virsh domblklist CentOS7

Target     Source

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

hda        -

vda        /var/lib/libvirt/images/CentOS7.img



위에 CentOS7 은 virsh list --all 로 확인하면 됩니다.


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,

[리눅스] qcow2 를 img 형태로 변환하기



VHDX 포맷을 IMG 로도 변환이 가능합니다.


# yum install qemu-img


# qemu-img create -f qcow2 Image.qcow2 10G

# qemu-img convert Image.qcow2 -O raw test.img


# qemu-img create -f vhdx Image.vhdx 10G

# qemu-img convert Image.vhdx -O raw Image.img


▶ QEMU-IMG 지원 포맷


Supported formats: vvfat vpc vmdk vhdx vdi ssh sheepdog rbd raw host_cdrom host_floppy host_device file qed qcow2 qcow parallels nbd iscsi gluster dmg tftp ftps ftp https http cloop bochs blkverify blkdebug


생소한 포맷들이 많네요~


블로그 이미지

영은파더♥

가상서버호스팅 VPS 리눅스 서버관리 윈도우 IT

,