nginx 설치하기
Apache가 대중적으로 많이 사용되고 있지만 요즘 가벼운 웹 서비스를
구축할려는 수요가 많이 보여진다.
NGINX 를 설치해보았다.
다운로드
wget http://nginx.org/download/nginx-1.1.8.tar.gz
설치
설치전 필요패키지
yum install pcre* make
tar xvfz nginx-1.1.8.tar.gz
cd nginx-1.1.8
./configure –prefix=/usr/local/nginx && make && make install
http://wiki.nginx.org/RedHatNginxInitScript 사이트에서 스크립트 파일 내용 복사해서
vim /etc/init.d/nginx 에 붙여넣기
nginx 첨부파일 참조
chmod 700 /etc/init.d/nginx
chkconfig –add nginx
/etc/init.d/nginx start
wget http://kr2.php.net/get/php-5.2.14.tar.bz2/from/kr.php.net/mirror
tar jxvf php-5.2.14.tar.bz2tar jxvf php-5.2.14.tar.bz2
php 5.2대에서는 php-fpm을 사용하기 위해 패치가 필요합니다
여러가지 fastcgi 사용방법이 있지만 fpm을 이용해 보도록 하겠습니다.
wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
gzip -d php-5.2.17-fpm-0.5.14.diff.gz
cd php-5.2.17
./buildconf –force
Forcing buildconf
buildconf: checking installation…
buildconf: autoconf not found.
You need autoconf version 2.13 or newer installed
to build PHP from CVS.
make: *** [buildmk.stamp] Error 1
위 에러 발생시
[root@localhost php-5.2.17]# yum install autoconf
[root@localhost php-5.2.17]# ./buildconf –force
Forcing buildconf
buildconf: checking installation…
buildconf: autoconf version 2.63 (ok)
buildconf: Your version of autoconf likely contains buggy cache code.
Running vcsclean for you.
To avoid this, install autoconf-2.13.
Can’t figure out your VCS, not cleaning.
위 에러 발생시
yum install autoconf213
export PHP_AUTOCONF=”/usr/bin/autoconf-2.13″
export PHP_AUTOHEADER=/usr/bin/autoheader-2.13
nginx 컴파일
./configure –prefix=/usr/local/php-fpm –enable-fastcgi –enable-fpm –with-libevent –enable-mod-charset –enable-safe-mode –enable-sigchild –enable-magic-quotes –with-libxml-dir –with-openssl –with-zlib –with-zlib-dir –with-bz2 –enable-calendar –with-curl –enable-dba –with-gdbm –enable-exif –enable-ftp –with-gd –with-jpeg-dir –with-png-dir –with-ttf –with-freetype-dir –enable-gd-native-ttf –with-gettext –with-imap –with-imap-ssl –with-kerberos –enable-mbstring –with-mhash –with-mcrypt –with-mysql=/usr/local/mysql –with-mysqli –enable-sockets –with-regex=php –enable-sysvmsg –enable-sysvsem –enable-sysvshm –enable-zendmultibyte && make && make install
디폴트 스크립트 복사
cp /usr/local/php-fpm/sbin/php-fpm /etc/init.d/
현재 설정과 시스템에 맞게 스크립트 내용 변경
vi /etc/init.d/php-fpm
chkconfig –add php-fpm
vi /usr/local/php-fpm/etc/php-fpm.conf
(아래부분 설정내용 확인)
<value name=”owner”>nobody</value>
<value name=”group”>nobody</value>
<value name=”user”>nobody</value>
<value name=”group”>nobody</value>
/etc/init.d/php-fpm start
vi /usr/local/nginx/conf/nginx.conf (아래 설정 내용 확인)
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
cp php.ini-recommended /usr/local/php-fpm/lib/php.ini
echo ‘<?php phpinfo(); ?>’ > /usr/local/nginx/html/index.php
nginx 시작
/etc/init.d/nginx restart