Nginx 下载和安装

@

环境

系统环境:CentOS 7.7
Nginx:nginx/1.17.9

1.Nginx 简介

Nginx 是一个高性能的 HTTP 和反向代理 Web 服务器,同时也提供了 IMAP/POP3/SMTP 服务。

Nginx 是由伊戈尔·赛索耶夫为俄罗斯访问量第二的 Rambler.ru 站点开发的,,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。

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

2.下载

官网下载,使用世界五百强科技企业【百度】搜索引擎搜 Nginx,目前选择最新版本 nginx-1.17.9.tar.gz
步骤如下:
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

3.安装

3.1.安装依赖

[root@localhost ]# yum -y install gcc pcre-devel zlib-devel openssl openssl-devel

3.2.上传并解压

可以通过工具 Winscp,把下载好的 nginx-1.17.9.tar.gz 上传到服务器跟目录,再解压

[root@localhost /]# tar -zxvf nginx-1.17.9.tar.gz 

3.3.编译安装

[root@localhost /]# cd nginx-1.17.9
[root@localhost nginx-1.17.9]# ./configure
[root@localhost nginx-1.17.9]# make && make install

默认安装位置在 :

[root@localhost nginx]# pwd
/usr/local/nginx

服务启动:

[root@localhost nginx]# /usr/local/nginx/sbin/nginx 
[root@localhost nginx]# ps -ef | grep nginx
root      39801      1  0 15:20 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody    39802  39801  0 15:20 ?        00:00:00 nginx: worker process
root      39804  37153  0 15:20 pts/0    00:00:00 grep --color=auto nginx

现在已经起来了,但是 Linux 防火墙默认大部分端口是没开放的,现在需要放开,Nginx 端口 80(默认)

#查看防火墙状态
[root@localhost nginx]# firewall-cmd --state
running
#放开 80 端口,(--permanent永久生效,没有此参数重启后失效)
[root@localhost nginx]# firewall-cmd --zone=public --add-port=80/tcp --permanent
success
#重新加载防火墙信息
[root@localhost nginx]# firewall-cmd --reload
success

出现下图说明 Nginx 服务安装成功
在这里插入图片描述

3.4 Nginx 常用命令

[root@localhost sbin]# pwd
/usr/local/nginx/sbin
#查看 Nginx 版本
[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.17.9
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC) 
configure arguments:
#关闭 Nginx 
[root@localhost sbin]# ./nginx -s stop
#开启 Nginx 
[root@localhost sbin]# ./nginx
#重新加载 Nginx 配置
[root@localhost sbin]# ./nginx -s reload
# Nginx 配置文件
[root@localhost sbin]# vi /usr/local/nginx/conf/nginx.conf

更多的配置在 nginx.conf 中修改,Nginx 还可以和 FastDFS 做分布式文件系统部署,更多的功能继续尝试中......

如果有哪些不对的地方烦请指认,先行感谢

posted @ 2020-03-15 16:13  charmsongo  阅读(704)  评论(0编辑  收藏  举报