<?php

$serverName = "서버IP";
$connectionInfo = array ("Database"=>"DB명","UID"=>"DB유저명","PWD"=>"DB패스워드");
$conn = sqlsrv_connect($serverName, $connectionInfo);
    

if ($conn) {

echo "연결 성공!\n";

} else {

echo "연결 실패!\n";

die ( print_r (sqlsrv_errors(), true)); 

}

sqlsrv_close($conn);

?>

'Works > PHP' 카테고리의 다른 글

Dezend Encoder  (0) 2017.07.10
PHP의 php.ini 설정에서 register_globals = on/off 차이  (0) 2017.06.21
php 퍼미션 관련 함수  (0) 2016.10.25
PHP 문자열 함수  (0) 2016.06.30
도메인을 판별하여 목적도메인으로 리다이렉션  (0) 2016.04.28


CentOS 7 은 많은 변화가 있었지만 그중 하나가 네트워크 인터페이스 이름 입니다.

지금까지 네트워크 인터페이스 이름은 eth0, eth1 식으로 고정되어 있었습니다. 하지만 CentOS 7 부터는 바이오스 장치 이름을 조합해서 생성됩니다. 다시 말해서 각 서버마다 네트워크 인터페이스 카드가 모두 동일하다고 할지라도 CentOS 7 에서의 네트워크 인터페이스 이름은 모두 다를 수가 있다는 겁니다.

이 문서는 CentOS 7 에서 네트워크 인터페이스 이름 바꾸기 에 대한 것입니다.

1. 상태확인

CentOS 7 에서의 네트워크 인터페이스 이름은 다음과 같습니다.

[root@localhost ~]# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.55  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::5def:d7b6:b644:3343  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:f5:93:8e  txqueuelen 1000  (Ethernet)
        RX packets 76  bytes 11976 (11.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 84  bytes 11460 (11.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1  (Local Loopback)
        RX packets 72  bytes 6248 (6.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 72  bytes 6248 (6.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s3 으로 나옵니다. 네트워크 인터페이스 설정 파일도 이름과 동일하게 생성 됩니다.

[root@localhost ~]# ls -al /etc/sysconfig/network-scripts/ifcfg-enp0s3
-rw-r--r--. 1 root root 312  3월 28 09:31 /etc/sysconfig/network-scripts/ifcfg-enp0s3


2. eth0 로 바꾸기

바꾸는 방법은 grub 에서 바이오스장치이름을 네트워크 인터페이스 이름으로 사용하지 않겠다고 선언하는 것입니다. 커널이 업그레이드되면 grub 에 파라메터값을 다시 해줘야 하는 불편함을 없애기위해서 grub 의 기본설정을 변경해 줍니다.

[root@localhost ~]# cat /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet net.ifnames=0 biosdevname=0 ipv6.disable=1"
GRUB_DISABLE_RECOVERY="true"

핵심은 ‘GRUB_CMDLINE_LINUX’ 에 ‘net.ifnames=0 biosdevname=0’ 를 추가하는 것입니다. 그리고 다음과 같이 grub2 를 다시 만들어 줍니다.
ipv6.disable=1 을 적용하면 ipv6 기반이 비활성화 됩니다.

grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.9.3.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.9.3.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.8.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.8.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.6.3.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.6.3.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-babecd961e9a465686311e3f5930f25e
Found initrd image: /boot/initramfs-0-rescue-babecd961e9a465686311e3f5930f25e.img
done

이제 네트워크 인터페이스 파일을 다음과 같이 바꿔 줍니다.

root@localhost ~]# cd /etc/sysconfig/network-scripts/
[root@localhost network-scripts]# mv ifcfg-enp0s3 ifcfg-eth0

[추가] 이름 변경한 ifcfg-eth0 파일 내용 중 DEVICE= 와 NAME= 또한 동일하게 변경한다.

이제 재부팅을 하면 네트워크 인터페이스 이름이 eth0 로 올라온것을 볼 수 있습니다.



configure: error: readline library not found
yum -y install readline readline-devel

1. pstree 명령어를 찾을 수 없을 때

명령 : yum -y install psmisc

2. ifconfig 명령어를 찾을 수 없을 때

명령 : yum -y install net-tools

3. autoconf 명령을 찾을 수 없을 때 (pecl 또는 phpize 명령 실행시 autoconf 는 필수 설치 항목이다.)

[에러 메시지]
Cannot find autoconf. Please check your autoconf installation and the $PHP_AUTOCONF
environment variable is set correctly and then rerun this script.

해결 : yum -y install autoconf

4. scp 명령어를 찾을수 없을 때

해결 : yum -y install openssh-clients (설치되면 scp, sftp등이 설치된다.)

5. nslookup 명령어를 찾을 수 없을 때 (CentOS7 에서)

해결 : yum -y install bind-utils

6. wget 명령어를 찾을 수 없을 때

해결 : yum -y install wget

7. lspci 명령어를 찾을 수 없을 때

해결 : yum -y install pciutils

8. ntsysv 명령어를 찾을 수 없을 때

해결 : yum -y install ntsysv

9. smartctl 명령어를 찾을 수 없을 때

해결 : yum -y install smartmontools

10. hdparm 명령어를 찾을 수 없을 때

해결 : yum -y install hdparm

11. rdate 명령어를 찾을 수 없을 때

해결 : yum -y install rdate


최소 설치 리눅스에서는 setup, ntsysv 와 같은 명령어가 미포함 되어 있으므로 아래 명령어로 패키지를 설치해 준다.

yum install setuptool

yum install system-config-network-tui

yum install ntsysv

[출처] http://jumals.tistory.com/06


* Test Environment

 

CentOS 5.x 32bit

 

Red : 강조

Blue : 명령어 & 메뉴이동

Green : 주석

Pink : 변수

Purple : 예시

Orange : 출력&편집&소스

 

* Incident

 

svn 설치과정 중 apxs 파일관련 오류가 발생하여 해당 파일을 실행하였더니 아래와 같이 오류가 발생하였다.

[root@mooon]# /usr/local/apache_svn/bin/apxs -h

/usr/local/apache_svn/bin/apxs: /replace/with/path/to/perl/interpreter: bad interpreter: No such file or directory 

 

 

 

* Resolution

위 오류가 발생한 이유는 시스템상에 perl 이 없는 상태에서 소스설치를 진행하여 apxs 파일이 perl을 찾지 못해 발생하는 오류이다.

perl을 설치하고 apxs 파일을 수정하면 해결 된다.

[root@mooon]# yum install perl

[root@mooon]# vi /usr/local/apache_svn/bin/apxs

#!/replace/with/path/to/perl/interpreter -w // 삭제 

#!/usr/bin/perl -w // 추가 

 

 

 * Reference 

 

http://wnstjqdl.tistory.com/23 



서버를 이전 또는 동일한 옵션의 APM 을 다른 서버에 설치하게 될 경우 기존 APM 옵션을 알아야 하는데

따로 적어두지 않았을 경우에는 곤란함이 있다.


[14.48.175.179 서버 기준]


1.apache 소스 컴파일 옵션 확인

cat /usr/local/apache/build/config.nice

#! /bin/sh
#
# Created by configure

"./configure" \
"--prefix=/usr/local/httpd-2.2.27" \
"--sysconfdir=/etc/httpd/conf" \
"--enable-modules=most" \
"--enable-mods-shared=most" \
"--enable-ssl" \
"--enable-rewrite" \
"--enable-so" \
"$@"


2. php 소스 컴파일 옵션 확인

/usr/local/php/bin/php-config | grep configure

 --configure-options [--prefix=/usr/local/php-5.3.28 --with-apxs2=/usr/local/apache/bin/apxs --with-mysql=/usr/local/mysql --with-config-file-path=/etc/httpd/conf --with-iconv --with-mcrypt=/usr --with-ncurses=/usr --with-gdbm=/usr --with-zlib=/usr --with-openssl --with-kerberos=/usr --with-imap-ssl=/usr --with-gd=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-zlib-dir=/usr --with-xpm-dir=/usr --with-freetype-dir=/usr --with-pic --with-curl --with-dbm --disable-libtool-lock --disable-short-tags --disable-debug --disable-ipv6 --enable-inline-optimization --enable-zend-multibyte --enable-fast-install --enable-safe-mode --enable-magic-quotes --enable-calendar --enable-ftp --enable-sockets --enable-gd-native-ttf --enable-gd-jis-conv --enable-dba=shared --enable-exif --enable-zip --enable-mbstring --enable-dbase --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-bcmath --enable-shmop --enable-xml --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libdir=lib64]

3. mysql 소스 컴파일 옵션 확인

grep -i configure_line /usr/local/mysql/bin/mysqlbug

CONFIGURE_LINE="./configure  '--prefix=/usr/local/mysql-5.0.96' '--with-mysqld-user=mysql' '--localstatedir=/mysql/data' '--with-charset=utf8' '--with-extra-charsets=all' '--with-pthreads' '--enable-thread-safe-client' '--enable-named-pipe' '--enable-shared' '--with-openssl' '--with-big-tables' '--with-readline' '--without-debug' '--without-docs' '--without-bench'"
`test -n "$CONFIGURE_LINE"  && echo "Configure command: $CONFIGURE_LINE"`


[출처] http://jelbin.tistory.com/63


방법 1 : chpasswd ( CentOS, Ubuntu 에서 가능 )

명령 : echo '아이디:패스워드' | chpasswd


방법 2 : passwd ( CentOS는 가능. Ubuntu는 불가 )

명령 : echo '패스워드' | passwd --stdin 아이디

※ 요약

리눅스 명령어 lastb는 접속 실패 기록을 보여주는 명령어다. last 명령어가 로그인 기록과 재부팅 기록을 보기 위해 /var/log/wtmp 파일을 열람한다면, lastb는 /var/log/btmp 파일을 열람하여 실패 목록을 보여준다. lastb는 접속 실패를 기록하는 파일인 btmp 파일을 열람한다는 것을 제외하고는 last 명령어와 같다.

※ 경로

/usr/bin/lastb

※ 사용법

lastb [옵션]... [유저명]... [tty]...


※ 옵션

 옵션

 설명

 -num

 num 만큼의 줄만 출력

 -n num

 -num과 동일

 -R

 hostname필드는 출력 안 함

 -a

 출력되는 목록에서 hostname 필드는 마지막에 출력

 -d

 다른 host에서 접속한 내용만 출력

 -x

 shutdown 상태 및 runlevel이 바뀐 상태 출력

 -f file

 지정한 file에서 정보를 읽어와서 출력


[출처] http://shaeod.tistory.com/729

'Works > CentOS & RockyLinux' 카테고리의 다른 글

CentOS setup ntsysv 설치  (0) 2017.03.21
시스템 패스워드 한줄로 변경하기  (0) 2017.02.14
CentOS 다운로드 미러 사이트  (0) 2017.01.03
CentOS7 hostname 설정  (0) 2016.10.31
tmpwatch  (0) 2016.10.19



 

'개인용' 카테고리의 다른 글

HDTunePro5.6  (0) 2018.08.07
소득금액증명원 홈텍스에서 발급신청하기  (0) 2017.11.22
티스토리 A레코드 IP  (0) 2015.10.28