红联Linux门户
Linux帮助

RedHat和CentOS下Nginx安装

发布时间:2015-04-02 14:55:33来源:linux网站作者:ilovezhangxian

官网当前最稳定的的版本是1.6.1,本教程以1.6.1为例:


1,RedHat和CentOS可以设置rpm源,

RHEL 5:http://nginx.org/packages/rhel/5/noarch/RPMS/nginx-release-rhel-5-0.el5.ngx.noarch.rpm
RHEL 6:http://nginx.org/packages/rhel/6/noarch/RPMS/nginx-release-rhel-6-0.el6.ngx.noarch.rpm
RHEL 7:http://nginx.org/packages/rhel/7/noarch/RPMS/nginx-release-rhel-7-0.el7.ngx.noarch.rpm
CentOS 5:http://nginx.org/packages/centos/5/noarch/RPMS/nginx-release-centos-5-0.el5.ngx.noarch.rpm
CentOS 6:http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
CentOS 7:http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

下载然后安装上面的文件

运行命令 yum install nginx

debian和Ubuntu可以配置如下源

deb http://nginx.org/packages/debian/ codename nginx

deb-src http://nginx.org/packages/debian/ codename nginx

deb http://nginx.org/packages/ubuntu/ codename nginx

deb-src http://nginx.org/packages/ubuntu/ codename nginx

运行

apt-get update

apt-get install nginx


2,源码编译

http://nginx.org/en/download.html 下载nginx1.6.1

./configure
--sbin-path=/usr/local/nginx/nginx
--conf-path=/usr/local/nginx/nginx.conf
--pid-path=/usr/local/nginx/nginx.pid
--with-http_ssl_module
make
make install

中途可能有依赖关系,可以根据提示安装相关依赖


更多安装信息参考 http://nginx.org/en/docs/configure.html