Webサーバ nginxをインストール

Webサーバ nginxをインストール


 素晴らしいパフォーマンスを発揮するというnginx(エンジンエックス)インストール方法の覚書。
 今回は、CentOS6に、yumを使ってインストールしてみた。

 作業はrootアカウントで行う。


yumのレポジトリを登録


 /etc/yum.repos.d/nginx.repo を新規作成し、中身をこんなふうに書く。

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/6/$basearch/

gpgcheck=0

enabled=1


yumコマンドでインストール


[root@localhost yum.repos.d]# yum search nginx
Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

 * base: ftp.iij.ad.jp

 * extras: ftp.iij.ad.jp

 * updates: ftp.iij.ad.jp

nginx                                                    | 2.9 kB     00:00    

nginx/primary_db                                         |  24 kB     00:00    

============================== N/S Matched: nginx ==============================

nginx.i386 : nginx is a high performance web server  ←パッケージ名!
nginx-debug.i386 : debug version of nginx

  Name and summary matches only, use "search all" for everything.

※64ビット版の場合は若干パッケージ名(nginx.i386)が異なる。

[root@localhost yum.repos.d]# yum install nginx.i386
Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

 * base: ftp.iij.ad.jp

 * extras: ftp.iij.ad.jp

 * updates: ftp.iij.ad.jp

Setting up Install Process

Resolving Dependencies

--> Running transaction check

---> Package nginx.i386 0:1.4.1-1.el6.ngx will be installed

--> Finished Dependency Resolution

Dependencies Resolved

================================================================================

 Package         Arch           Version                   Repository       Size

================================================================================

Installing:

 nginx           i386           1.4.1-1.el6.ngx           nginx           317 k

Transaction Summary

================================================================================

Install       1 Package(s)

Total download size: 317 k

Installed size: 734 k

Is this ok [y/N]: y
Downloading Packages:

nginx-1.4.1-1.el6.ngx.i386.rpm                           | 317 kB     00:01    

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : nginx-1.4.1-1.el6.ngx.i386                                   1/1

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

Thanks for using NGINX!

Check out our community web site:

* http://nginx.org/en/support.html

If you have questions about commercial support for NGINX please visit:

* http://www.nginx.com/support.html

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

Installed:

  nginx.i386 0:1.4.1-1.el6.ngx                                                 

Complete!


とりあえずサービス起動


[root@localhost ~]# service nginx start
nginx を起動中:                                            [  OK  ]

[root@localhost ~]# ps -ef | grep nginx ←プロセスを確認
root     14262     1  0 05:33 ?        00:00:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf

nginx    14264 14262  0 05:33 ?        00:00:00 nginx: worker process                  

root     14268  2817  0 05:33 pts/0    00:00:00 grep nginx

これでとりあえず起動。
サーバ上でブラウザを起動し、http://127.0.0.1 を開いて、nginxらしきメッセージが出てくれば一応のインストール成功。


▲デフォルトのnginxトップページ