导入源
导入rpm包
rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
或者
创建源
安装准备依赖lib库
yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
创建/etc/yum.repos.d/nginx.repo
添加以下,以centos7为例
[nginx] name=nginx repo baseurl=http://nginx.org/packages/mainline/rhel/7/$basearch/ gpgcheck=0 enabled=1
导入key
rpm –import http://nginx.org/keys/nginx_signing.key
查看yum中的nginx信息
[root@localhost ~]# yum info nginx Loaded plugins: fastestmirror, langpacks nginx | 2.9 kB 00:00:00 nginx/x86_64/primary_db | 19 kB 00:00:00 Loading mirror speeds from cached hostfile * base: centos.nethub.com.hk * extras: centos.nethub.com.hk * updates: centos.nethub.com.hk Available Packages Name : nginx Arch : x86_64 Version : 1.10.2 Release : 1.el6.ngx Size : 825 k Repo : nginx/x86_64 Summary : High performance web server URL : http://nginx.org/ Licence : 2-clause BSD-like license Description : nginx [engine x] is an HTTP and reverse proxy server, as well as : a mail proxy server.
安装
[root@localhost ~]# yum install nginx
启动
[root@localhost ~]# service nginx start