美文网首页中间件
NGINX快速安装

NGINX快速安装

作者: 夏胖运维 | 来源:发表于2020-11-12 20:12 被阅读0次

NGINX的下载界面会看到有三个版本

  • 开发版:Mainline version
  • 稳定版:Stable version
  • 历史版:Legacy versions

注意:企业安装NGINX需要使用稳定版本

1. 环境准备

# 查看系统版本
[root@localhost ~]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 
# 确定系统网络环境,是否可访问公网
[root@localhost ~]# ping -c 4 www.baidu.com
# 关闭防火墙
[root@localhost ~]# systemctl stop firewalld.service
[root@localhost ~]# systemctl disable firewalld.service
[root@localhost ~]# systemctl status firewalld.service
# 修改主机名称
[root@localhost ~]# hostnamectl set-hostname web-01
# 关闭selinux
[root@localhost ~]# sed -i.backup 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
# 重启系统
[root@localhost ~]# reboot

2. 开始安装NGINX

2.1. 配置NGINX YUM源

[root@web-01 ~]# cat > /etc/yum.repos.d/nginx.repo << 'EOF'
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
EOF

2.2. 安装NGINX软件

[root@web-01 ~]# yum install -y nginx
# 查看nginx版本
[root@web-01 ~]# nginx -v
nginx version: nginx/1.18.0

2.3. 启动NGINX服务

# 检查配置文件是否正确
[root@web-01 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# 启动NGINX服务
[root@web-01 ~]# systemctl start nginx.service
[root@web-01 ~]# systemctl enable nginx.service
# 检查NGINX服务运行状态
[root@web-01 ~]# systemctl status nginx.service
[root@web-01 ~]# ps aux|grep nginx
[root@web-01 ~]# ss -nlutp|grep 80

2.4. 访问网页测试

命令行访问

[root@web-01 ~]# curl 127.0.0.1
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

3. NGINX安装目录

为了让大家更加清晰的了解nginx软件的全貌,我们有必要介绍一下NGINX安装后整体的目录结构和文件功能。RPM包方式安装使用如下命令查看

[root@web-01 ~]# rpm -ql nginx

NGINX安装目录详细概述

路径 类型 作用
/etc/nginx
/etc/nginx/nginx.conf
/etc/nginx/conf.d
/etc/nginx/conf.d/default.conf
配置文件 NGINX主配置文件
/etc/nginx/fastcgi_params
/etc/nginx/scgi_params
/etc/nginx/uwsgi_params
配置文件 CGI、FastCGI、UwCGI配置文件
/etc/nginx/koi-utf
/etc/nginx/koi-win
/etc/nginx/win-utf
配置文件 NGINX编码转换映射文件
/etc/nginx/mime.types 配置文件 HTTP协议的Content-Type
/etc/sysconfig/nginx
/etc/sysconfig/nginx-debug
/usr/lib/systemd/system/nginx-debug.service
/usr/lib/systemd/system/nginx.service
配置文件 配置系统守护进程管理器
/etc/logrotate.d/nginx 配置文件 NGINX日志轮询,日志切割配置文件
/usr/sbin/nginx
/usr/sbin/nginx-debug
命令 NGINX管理命令
/usr/share/doc/nginx-1.18.0
/usr/share/doc/nginx-1.18.0/COPYRIGHT
/usr/share/man/man8/nginx.8.gz
目录 NGINX帮助手册
/var/cache/nginx 目录 NGINX资源缓存目录
/var/log/nginx 目录 NGINX日志目录
/etc/nginx/modules
/usr/lib64/nginx
/usr/lib64/nginx/modules
目录 NGINX模块目录
/usr/share/nginx
/usr/share/nginx/html
/usr/share/nginx/html/50x.html
/usr/share/nginx/html/index.html
目录 NGINX默认站点目录

相关文章

  • 一、Nginx的安装

    一、linux下安装nginx: 2、常用指令nginx -s stop 快速关闭Nginx,可能不保...

  • 阿里云快速部署Flask项目-Ubuntu+Gunicorn+N

    阿里云快速部署Flask项目-Ubuntu+Gunicorn+Nginx 一. 安装包 安装了Nginx apt-...

  • Nginx 不同端口配置多个项目

    首先安装 Nginx, 如何安装 上述方法介绍了如何快速安装配置 Nginx, 但想要配置多项目的话该怎么做呢? ...

  • nginx 反向代理实现负载均衡

    docker 快速安装nginx 设置需要代理的从服务器信息 可填多个 本机nginx配置 /etc/nginx...

  • nginx快速安装

    一、介绍 写此nginx从入门到实践系列笔记,为以教促学,让自己系统地学习掌握nginx的配置和搭建高可用架构。系...

  • Nginx 快速安装

    用途 Nginx是一款自由的、开源的、高性能的HTTP服务器和反向代理服务器;同时也是一个IMAP、POP3、SM...

  • NGINX快速安装

    NGINX的下载界面[http://nginx.org/en/download.html]会看到有三个版本 开发版...

  • linux下快速搭建nginx

    Nginx安装 本文选用apt的方式快速进行nginx的安装。 注意:阿里云的apt仓库可能不是最新的,因此,需要...

  • Nginx

    安装nginx 基本命令 nginx -s signal 其中signal可以为下列之一: 1.stop 快速停...

  • Linux 搭建Laravel环境

    PHP、Mysql和Nginx的安装请参照:CentOS7快速搭建LNMP环境 安装Composer Larave...

网友评论

    本文标题:NGINX快速安装

    本文链接:https://www.haomeiwen.com/subject/kbgpbktx.html