Nginx概要(編集対象)

5951 ワード

Nginxは軽量級だが高性能なWebサーバと逆プロキシサーバであり、メールのプロキシサーバでもあり、本来使用していたApacheの代わりにNginxを使用する人が増えている.
Nginxのインストール:
1、CentOS&Redhatのyumインストール(CentOS 6.xを例に):
システム情報の確認
[root@wangdong-centos1 ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)
[root@wangdong-centos1 ~]# uname -r
2.6.32-504.el6.x86_64
[root@wangdong-centos1 ~]# uname -m
x86_64

インストール済みかどうかを確認
[root@wangdong-centos1 ~]# rpm -aq nginx
[root@wangdong-centos1 ~]#

まずyumソースをアリクラウドに変更することをお勧めします
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

yumを使用してnginxパッケージを検索する
[root@wangdong-centos1 ~]# yum search nginx
Loaded plugins: fastestmirror, security
Determining fastest mirrors
 * base: mirrors.aliyun.com
 * epel: mirrors.aliyun.com
 * extras: mirrors.aliyun.com
 * updates: mirrors.aliyun.com
base                                                                                                                                           | 3.7 kB     00:00
epel                                                                                                                                           | 4.3 kB     00:00
epel/primary_db                                                                                                                                | 5.8 MB     00:13
extras                                                                                                                                         | 3.4 kB     00:00
updates                                                                                                                                        | 3.4 kB     00:00
updates/primary_db                                                                                                                             | 3.9 MB     00:10
========================================================================= N/S Matched: nginx =========================================================================
collectd-nginx.x86_64 : Nginx plugin for collectd
munin-nginx.noarch : Network-wide graphing framework (cgi files for nginx)
nginx-filesystem.noarch : The basic directory layout for the Nginx server
owncloud-nginx.noarch : Nginx integration for ownCloud
nginx.x86_64 : A high performance web server and reverse proxy server
Name and summary matches only, use "search all" for everything.
[root@wangdong-centos1 ~]#
yum取付nginx
[root@wangdong-centos1 ~]# yum install nginx -y

nginxの起動
[root@wangdong-centos1 ~]# /etc/init.d/nginx start
Starting nginx:                                            [  OK  ]

POST nginxの設定
[root@wangdong-centos1 ~]# chkconfig --list nginx
nginx          0:off1:off2:off3:off4:off5:off6:off
[root@wangdong-centos1 ~]# chkconfig nginx on
[root@wangdong-centos1 ~]# chkconfig --list nginx
nginx          0:off1:off2:on3:on4:on5:on6:off

2、Ubuntu&Debianのaptインストール(Debian 7.xを例に):
システム情報の確認
root@wangdong-debian1:~# cat /etc/issue
Debian GNU/Linux 7 
 \l root@wangdong-debian1:~# root@wangdong-debian1:~# uname -r 3.2.0-4-amd64 root@wangdong-debian1:~# uname -m x86_64

インストール済みかどうかを確認
root@wangdong-debian1:~# dpkg -s nginx
dpkg-query: package 'nginx' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files,
and dpkg --contents (= dpkg-deb --contents) to list their contents.

aptを使用してnginxパッケージを検索する
root@wangdong-debian1:~# apt-cache search nginx
collectd-core - statistics collection and monitoring daemon (core system)
fcgiwrap - simple server to run CGI applications over FastCGI
gitweb - fast, scalable, distributed revision control system (web interface)
gunicorn - Event-based HTTP/WSGI server
libplack-middleware-file-sass-perl - Sass and SCSS support for all Plack-based PSGI frameworks
nginx - small, powerful, scalable web/proxy server
nginx-common - small, powerful, scalable web/proxy server - common files
nginx-doc - small, powerful, scalable web/proxy server - documentation
nginx-extras - nginx web/proxy server (extended version)
nginx-extras-dbg - nginx web/proxy server (extended version) - debugging symbols
nginx-full - nginx web/proxy server (standard version)
nginx-full-dbg - nginx web/proxy server (standard version) - debugging symbols
nginx-light - nginx web/proxy server (basic version)
nginx-light-dbg - nginx web/proxy server (basic version) - debugging symbols
nginx-naxsi - nginx web/proxy server (version with naxsi)
nginx-naxsi-dbg - nginx web/proxy server (version with naxsi) - debugging symbols
nginx-naxsi-ui - nginx web/proxy server - naxsi configuration front-end
rt4-fcgi - External FastCGI support for request-tracker4
ruby-passenger - Rails and Rack support for Apache2 and Nginx
stud - scalable TLS unwrapping daemon
uwsgi-extra - fast, self-healing application container server (extra files)

aptでnginxをインストールする
root@wangdong-debian1:~# yes | apt-get install nginx

nginxがインストールされているかどうかをもう一度確認します.
root@wangdong-debian1:~# dpkg -s nginx
Package: nginx
Status: install ok installed
Priority: optional
Section: httpd
Installed-Size: 87
Maintainer: Kartik Mistry 
Architecture: all
Version: 1.2.1-2.2+wheezy3
Depends: nginx-full | nginx-light
Description: small, powerful, scalable web/proxy server
 Nginx ("engine X") is a high-performance web and reverse proxy server
 created by Igor Sysoev. It can be used both as a standalone web server
 and as a proxy to reduce the load on back-end HTTP or mail servers.
 .
 This is a dependency package to install either nginx-full (by default) or
  nginx-light.
Homepage: http://nginx.net