Linux安装Nginx(Yum方式)

小柒博客 Nginx评论5682字数 2948阅读9分49秒阅读模式

一、Nginx简介

Nginx(engine x)是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日。

Nginx是一款轻量级的Web服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上Nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用Nginx网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。

Nginx相对于Apache优点如下:

1)高并发响应性能非常好,官方Nginx处理静态文件并发5w/s;

2)负载均衡及反向代理性能非常强;

3)系统内存和CPU占用率低;

4)可对后端服务进行健康检查;

5)支持PHP cgi方式和FastCGI方式;

6)可以作为缓存服务器、邮件代理服务器;

7)配置代码简洁且容易上手;

8)支持 SSL 和 TLSSNI。

二、Centos 7安装Nginx

1、配置Centos 7 Nginx Yum源仓库

[root@localhost ~]# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

Retrieving http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

warning: /var/tmp/rpm-tmp.PiXlZn: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY

Preparing... ################################# [100%]

Updating / installing...

     1:nginx-release-centos-7-0.el7.ngx ################################# [100%]

2、安装Nginx

[root@localhost ~]# yum -y install nginx

3、启动Nginx

[root@localhost ~]# systemctl start nginx

4、访问Nginx

5、Nginx默认地址和配置

/etc/nginx/nginx.conf          # Yum安装Nginx默认主配置文件

/usr/share/nginx/html        # Nginx默认存放目录

/usr/share/nginx/html/index.html        # Nginx默认主页路径

6、常用基本操作

1)启动Nginx

[root@localhost ~]# systemctl start nginx

2)停止Nginx

[root@localhost ~]# systemctl stop nginx

3)重载Nginx

[root@localhost ~]# systemctl reload nginx

4)重启Nginx

[root@localhost ~]# systemctl restart nginx

5)查询Nginx运行状态

[root@localhost ~]# systemctl status nginx

6)查询Nginx进程

[root@localhost ~]# ps -ef |grep nginx

7)查询Nginx监听端口

[root@localhost ~]# netstat -lntup |grep nginx

8)卸载Nginx

[root@localhost ~]# yum -y remove nginx

9)RPM方式安装升级指定版本Nginx

[root@localhost ~]# rpm -Uvh http://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.22.0-1.el7.ngx.x86_64.rpm

三、Centos 6安装Nginx

1、配置Centos 6 Nginx Yum源仓库

[root@localhost ~]# rpm -Uvh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

Retrieving http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

warning: /var/tmp/rpm-tmp.xRiIYI: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY

Preparing... ########################################### [100%]

     1:nginx-release-centos ########################################### [100%]

2、安装Nginx

[root@localhost ~]# yum -y install nginx

3、启动Nginx

[root@localhost ~]# /etc/init.d/nginx start

4、访问Nginx

5、Nginx默认地址和配置

/etc/nginx/nginx.conf          # Yum安装Nginx默认主配置文件

/usr/share/nginx/html        # Nginx默认存放目录

/usr/share/nginx/html/index.html        # Nginx默认主页路径

6、常用基本操作

1)启动Nginx

[root@localhost ~]# /etc/init.d/nginx start

2)停止Nginx

[root@localhost ~]# /etc/init.d/nginx stop

3)重载Nginx

[root@localhost ~]# /etc/init.d/nginx reload

4)重启Nginx

[root@localhost ~]# /etc/init.d/nginx restart

5)查询Nginx运行状态

[root@localhost ~]# /etc/init.d/nginx status

6)查询Nginx进程

[root@localhost ~]# ps -ef |grep nginx

7)查询Nginx监听端口

[root@localhost ~]# netstat -lntup |grep nginx

8)卸载Nginx

[root@localhost ~]# yum -y remove nginx

9)RPM方式安装升级指定版本Nginx

[root@localhost ~]# rpm -Uvh http://nginx.org/packages/centos/6/x86_64/RPMS/nginx-1.18.0-1.el6.ngx.x86_64.rpm

若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!

继续阅读
Wechat
微信扫一扫,加我!
weinxin
微信公众号
微信扫一扫,关注我!
weinxin
Nginx最后更新:2023-10-11
小柒博客
  • 本文由 小柒博客 发表于 2023年3月7日11:17:12
  • 声明:本站所有文章,如无特殊说明或标注,本站文章均为原创。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。转载请务必保留本文链接:https://www.yangxingzhen.com/8692.html
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

拖动滑块以完成验证