FAT47の底辺インフラ議事録

学んだことのメモ帳です

CentOS5.6にNginx1.0.6をソースコードからインストール

事前準備

#パッケージ入手
cd /home/work
wget http://nginx.org/download/nginx-1.0.6.tar.gz

#必要モジュールインストール
yum install pcre*

#展開
tar zxvf nginx-1.0.6.tar.gz

インストール

cd nginx-1.0.6

./configure --prefix=/usr/local/nginx-1.0.6 --user=httpd --group=httpd --with-http_ssl_module --with-http_realip_module
make
make install
 
#シンボリックリンク作成 
ln -s /usr/local/nginx-1.0.6 /usr/local/nginx

起動スクリプト作成

vim /etc/init.d/nginx
#!/bin/bash
# Startup script for the Nginx Web Server
# chkconfig: 2345 85 15
# description: Nginx is a Light weight World Wide Web server.  It is used to serve \
#              HTML files and CGI.
# processname: nginx# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf. /etc/rc.d/init.d/functions

nginx='/usr/local/nginx/sbin/nginx'
prog=nginx
RET=0

start () {
  echo -n $"Starting $prog: "
  daemon $nginx
  RET=$?
  echo
  return $RET
}

stop () {
  echo -n $"Stopping $prog: "
  killproc $nginx
  RET=$?
  echo
  return $RET
}

reload() {
  echo -n $"Reloading $prog: "
  killproc $nginx -HUP
  RET=$?
  echo
  return $RET
}

case "$1" in
  start)
    start
  ;;
  stop)
    stop
  ;;
  restart)
    stop
        start
  ;;
  reload)
    reload
  ;;
  *)
    echo $"Usage: $prog {start|stop|restart|reload}"
    exit 1
  ;;
esac
exit $RET

#実行権限付与

chmod 755 /etc/init.d/nginx

設定

vim /usr/local/nginx/conf/nginx.conf

#以下の項目を変更する

error_log  /var/log/nginx/error.log;
pid        /var/run/nginx.pid;
    server {
        listen       80;
        server_name  localhost;


起動

/etc/init.d/nginx start

chkconfig --add nginx
chkconfig --list nginx

動作確認
http://localhost

にアクセスしてページが表示されれば成功