2012年5月9日水曜日

install nginx on CentOS5 by yum

※this text from livedoor blog 2009/11/2

nginxをyumでインストールします

Apacheなどで80番ポートが使われているか確認、使われていたらストップしておく
$ sudo /usr/sbin/lsof  -i | grep http
httpd     3376   root    4u  IPv6  13817       TCP *:http (LISTEN)
httpd     3376   root    6u  IPv6  13822       TCP *:https (LISTEN)
httpd     3388 apache    4u  IPv6  13817       TCP *:http (LISTEN)
httpd     3388 apache    6u  IPv6  13822       TCP *:https (LISTEN)
httpd     3389 apache    4u  IPv6  13817       TCP *:http (LISTEN)
httpd     3389 apache    6u  IPv6  13822       TCP *:https (LISTEN)
httpd     3390 apache    4u  IPv6  13817       TCP *:http (LISTEN)
httpd     3390 apache    6u  IPv6  13822       TCP *:https (LISTEN)
httpd     3391 apache    4u  IPv6  13817       TCP *:http (LISTEN)
httpd     3391 apache    6u  IPv6  13822       TCP *:https (LISTEN)
httpd     3392 apache    4u  IPv6  13817       TCP *:http (LISTEN)
httpd     3392 apache    6u  IPv6  13822       TCP *:https (LISTEN)
httpd     3393 apache    4u  IPv6  13817       TCP *:http (LISTEN)
httpd     3393 apache    6u  IPv6  13822       TCP *:https (LISTEN)
httpd     3394 apache    4u  IPv6  13817       TCP *:http (LISTEN)
httpd     3394 apache    6u  IPv6  13822       TCP *:https (LISTEN)
httpd     3395 apache    4u  IPv6  13817       TCP *:http (LISTEN)
httpd     3395 apache    6u  IPv6  13822       TCP *:https (LISTEN)
$ sudo /etc/init.d/httpd stop
httpd を停止中:                                            [  OK  ]


EPELレポジトリをインストール
i386の場合
$ wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
$ sudo rpm -Uvh epel-release-5-3.noarch.rpm

x86_64の場合
$ wget http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm
$ sudo  epel-release-5-3.noarch.rpm

yumでnginxをインストール
$ sudo yum install nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: ftp.jaist.ac.jp
 * base: ftp.jaist.ac.jp
 * epel: ftp.jaist.ac.jp
 * extras: ftp.jaist.ac.jp
 * rpmforge: fr2.rpmfind.net
 * updates: ftp.jaist.ac.jp
epel                                                                                              | 3.4 kB     00:00    
epel/primary_db                                                                                   | 2.2 MB     00:00    
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package nginx.i386 0:0.6.39-1.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================================================================
 Package                    Arch                      Version                            Repository                 Size
=========================================================================================================================
Installing:
 nginx                      i386                      0.6.39-1.el5                       epel                      318 k

Transaction Summary
=========================================================================================================================
Install      1 Package(s)        
Update       0 Package(s)        
Remove       0 Package(s)        

Total download size: 318 k
Is this ok [y/N]: y
Downloading Packages:
nginx-0.6.39-1.el5.i386.rpm                                                                       | 318 kB     00:00    
警告: rpmts_HdrFromFdno: ヘッダ V3 DSA signature: NOKEY, key ID 217521f6
epel/gpgkey                                                                                       | 1.7 kB     00:00    
Importing GPG key 0x217521F6 "Fedora EPEL <epel@fedoraproject.org>" from /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : nginx                                                                                             1/1

Installed:
  nginx.i386 0:0.6.39-1.el5                                                                                             

Complete!

nginxを起動する
$ sudo /etc/init.d/nginx start
nginx を起動中:                                            [  OK  ]


ブラウザで確認
http://192.168.197.1/