Nginx是一款轻量级但高性能的Web服务器及反向代理服务器,也是邮件的代理服务器,越来越多的人开始使用Nginx来替代原本使用的Apache。
Nginx的安装:
1、CentOS&Redhat的yum安装(以CentOS6.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 ]
设置开机自启动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安装(以Debian7.x为例):
确认系统信息
root@wangdong-debian1:~# cat /etc/issue Debian GNU/Linux 7 \n \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 <[email protected]> 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