一、下载
两种安装方式:
1、yum安装软件
a 使用官方yum源进行安装 安装的是最新版本 软件目录结构比较标准 (推荐)
b 使用非官方yum源进行安装 安装的不是最新版 目录结构会发生变化
2、编译安装软件
第一个步骤:
wget http://nginx.org/download/nginx-1.16.0.tar.gz
PS: 解决软件的依赖 openssl-devel pcre-devel

[root@ lb01 ~]# wget http://nginx.org/download/nginx-1.16.0.tar.gz
--2021-05-22 14:59:38--  http://nginx.org/download/nginx-1.16.0.tar.gz
Resolving nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:edb:5702::6, ...
Connecting to nginx.org (nginx.org)|3.125.197.172|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1032345 (1008K) [application/octet-stream]
Saving to: ‘nginx-1.16.0.tar.gz’100%[===============================================================================>] 1,032,345    352KB/s   in 2.9s   2021-05-22 14:59:47 (352 KB/s) - ‘nginx-1.16.0.tar.gz’ saved [1032345/1032345]
[root@ lb01 ~]# rpm -qa nginx
nginx-1.16.1-3.el7.x86_64
[root@ lb01 ~]# yum install -y openssl-devel
[root@ lb01 ~]# yum install -y pcre-devel

二、解压相关软件进入其目录

[root@ lb01 ~]# mkdir -p /server/tools
[root@ lb01 ~]# mv nginx-1.16.0.tar.gz /server/tools
[root@ lb01 tools]# tar -xf nginx-1.16.0.tar.gz
[root@ lb01 tools]# ll
total 1012
drwxr-xr-x. 8 rsync rsync     158 Apr 23  2019 nginx-1.16.0
-rw-r--r--. 1 root  root  1032345 Apr 23  2019 nginx-1.16.0.tar.gz
[root@ lb01 tools]# cd nginx-1.16.0/

第三个步骤:编译安装
编译安装三步曲
a 进行配置操作
./configure (命令)(–prefix= PATH) (–user=USER )
用法:./configure --prefix= (写上参数信息比如:–user=USER )
–prefix=PATH set installation prefix
指定程序安装路径
–user=USER set non-privileged user for worker processes
设置一个虚拟用户管理worker进程(安全)
–group=GROUP set non-privileged group for worker processes
设置一个虚拟用户组管理worker进程(安全)

[root@ lb01 nginx-1.16.0]# ./configure --help--help                             print this message--prefix=PATH                      set installation prefix--sbin-path=PATH                   set nginx binary pathname--modules-path=PATH                set modules path--conf-path=PATH                   set nginx.conf pathname--error-log-path=PATH              set error log pathname--pid-path=PATH                    set nginx.pid pathname--lock-path=PATH                   set nginx.lock pathname
***可以看到很多具体参数的用法。***

b 进行软件的编译过程:
make
c 编译安装过程
make install
(接上nginx第二种安装方法)yum官方源安装方法:
第一个历程: 更新nginx官方yum源

[root@ lb01 nginx-1.16.0]# vim /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key

第二个历程: yum安装nginx软件

[root@ lb01 nginx-1.16.0]# yum install -y nginx
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile* base: mirrors.aliyun.com* extras: mirrors.aliyun.com* updates: mirrors.aliyun.com
nginx-stable                                 | 2.9 kB     00:00
nginx-stable/7/x86_64/primary_db               |  63 kB   00:06
Resolving Dependencies
--> Running transaction check
---> Package nginx.x86_64 1:1.16.1-3.el7 will be updated
---> Package nginx.x86_64 1:1.20.0-1.el7.ngx will be an update
--> Finished Dependency ResolutionDependencies Resolved====================================================================Package   Arch       Version                Repository        Size
====================================================================
Updating:nginx     x86_64     1:1.20.0-1.el7.ngx     nginx-stable     790 kTransaction Summary
====================================================================
Upgrade  1 PackageTotal download size: 790 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
warning: /var/cache/yum/x86_64/7/nginx-stable/packages/nginx-1.20.0-1.el7.ngx.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID 7bd9bf62: NOKEY
Public key for nginx-1.20.0-1.el7.ngx.x86_64.rpm is not installed
nginx-1.20.0-1.el7.ngx.x86_64.rpm              | 790 kB   00:13
Retrieving key from https://nginx.org/keys/nginx_signing.key
Importing GPG key 0x7BD9BF62:Userid     : "nginx signing key <signing-key@nginx.com>"Fingerprint: 573b fd6b 3d8f bc64 1079 a6ab abf5 bd82 7bd9 bf62From       : https://nginx.org/keys/nginx_signing.key
Running transaction check
Running transaction test
Transaction test succeeded
Running transactionUpdating   : 1:nginx-1.20.0-1.el7.ngx.x86_64                  1/2
warning: /etc/nginx/conf.d/default.conf created as /etc/nginx/conf.d/default.conf.rpmnew
warning: /etc/nginx/nginx.conf created as /etc/nginx/nginx.conf.rpmnewCleanup    : 1:nginx-1.16.1-3.el7.x86_64                      2/2 Verifying  : 1:nginx-1.20.0-1.el7.ngx.x86_64                  1/2 Verifying  : 1:nginx-1.16.1-3.el7.x86_64                      2/2 Updated:nginx.x86_64 1:1.20.0-1.el7.ngx                                   Complete!

第三个历程: 启动nginx服务,检查服务是否安装正确

[root@ lb01 ~]# systemctl start nginx
[root@ lb01 ~]# systemctl status nginx
● nginx.service - nginx - high performance web serverLoaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)Active: active (running) since Sat 2021-05-22 17:15:04 CST; 11s agoDocs: http://nginx.org/en/docs/Process: 4452 ExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.conf (code=exited, status=0/SUCCESS)Main PID: 4453 (nginx)CGroup: /system.slice/nginx.service├─4453 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf└─4454 nginx: worker processMay 22 17:15:04 lb01 systemd[1]: Starting nginx - high performance web server...
May 22 17:15:04 lb01 systemd[1]: Can't open PID file /var/run/nginx.pid (yet?) after start: No such file or directory
May 22 17:15:04 lb01 systemd[1]: Started nginx - high performance web server.
[root@ lb01 ~]# systemctl enable nginx

测试访问nginx服务
在页面输入nginx的IP地址

查看软件的目录结构(不切割常年积累会很大,所以为了方便查看必须进行切割处理。)
1、/etc/logrotate.d
实现nginx日志文件定时切割处理
日志切割方法一: 利用脚本实现切割

[root@ lb01 ~]# vim /etc/logrotate.d#!/bin/bashmv /var/log/nginx/access.log  /var/log/nginx /access_$(date +%F).logsystemctl restart nginx

日志切割方法二: 利用专用文件切割程序–logrotate

[root@ lb01 ~]# vim /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files weekly
weekly# see "man logrotate" for details
# rotate log files weekly
weekly      --- 定义默认日志切割的周期# keep 4 weeks worth of backlogs
rotate 4    --- 定义只保留几个切割后的文件# create new (empty) log files after rotating old ones
create      --- 创建出一个相同的源文件# use date as a suffix of the rotated file
dateext     --- 定义角标(扩展名称信息)# uncomment this if you want your log files compressed
#compress   --- 是否对切割后的文件进行压缩处理# RPM packages drop log rotation information into this directory
include /etc/logrotate.d    --- 加载包含/etc/logrotate.d/目录中文件配置
# no packages own wtmp and btmp -- we'll rotate them here
/var/log/wtmp {             --- 单独对某个文件进行切割配置monthly                    *(主要就在这块代码切割。)*create 0664 root utmpminsize 1M          --- 最小大小为1M,小于1M不进行切割rotate 1
}/var/log/btmp {missingokmonthlycreate 0600 root utmp

总结:
01. /etc/nginx 配置文件
02. /var/log/nginx 日志文件
03. /usr/bin/nginx 命令文件
04. /usr/share/nginx/html 站点目录
图片 附件信息 音频 视频等

nginx服务配置文件

[root@ lb01 ~]# vim /etc/nginx/nginx.conf        --- 主配置文件
user  nginx;         --- 定义worker进程管理的用户
worker_processes  auto;error_log  /var/log/nginx/error.log notice;    --- 定义错误日志路径信息
pid        /var/run/nginx.pid;                --- 定义pid文件路径信息events {worker_connections  1024;                ---一个worker进程可以同时接收1024访问请求
}http {include       /etc/nginx/mime.types;   --- 加载一个配置文件default_type  application/octet-stream;     --- 指定默认识别文件类型log_format  main  '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" "$http_x_forwarded_for"';     --- 定义日志的格式 access_log  /var/log/nginx/access.log  main;  --- 指定日志路径 sendfile        on;#tcp_nopush     on;keepalive_timeout  65;       --- 超时时间#gzip  on;include /etc/nginx/conf.d/*.conf;  --- 加载一个配置文件}

server区域信息

/etc/nginx/conf.d/default.conf  ------ 扩展配置(虚拟主机配置文件)[root@ lb01 conf.d]# cat default.conf
server {listen       80;            --- 指定监听的端口server_name  localhost;      --- 指定网站域名#access_log  /var/log/nginx/host.access.log  main;location / {root   /usr/share/nginx/html;   --- 定义站点目录的位置index  index.html index.htm;   --- 定义首页文件(访问的时候显示的页面)}#error_page  404              /404.html;# redirect server error pages to the static page /50x.html#error_page   500 502 503 504  /50x.html;--- 优雅显示页面信息location = /50x.html {root   /usr/share/nginx/html;}# proxy the PHP scripts to Apache listening on 127.0.0.1:80##location ~ \.php$ {#    proxy_pass   http://127.0.0.1;#}# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000##location ~ \.php$ {#    root           html;#    fastcgi_pass   127.0.0.1:9000;#    fastcgi_index  index.php;#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;#    include        fastcgi_params;#}# deny access to .htaccess files, if Apache's document root# concurs with nginx's one##location ~ /\.ht {#    deny  all;#}
}

切换到站点目录下

[root@ lb01 conf.d]# cd /usr/share/nginx/html
添加一张图片
[root@ lb01 html]# rz -E
rz waiting to receive.
[root@ lb01 html]# ll
total 264
-rw-r--r--. 1 root root    494 Apr 21 00:09 50x.html
-rw-r--r--. 1 root root 260468 May 22 13:43 http.png
-rw-r--r--. 1 root root    612 Apr 21 00:09 index.html

站点目录下存在了一张图片,我们尝试访问一下
成功!!

nginx软件安装部署相关推荐

  1. ad域控服务器如何允许软件安装,AD域服务器实现软件安装部署

    <AD域服务器实现软件安装部署>由会员分享,可在线阅读,更多相关<AD域服务器实现软件安装部署(3页珍藏版)>请在人人文库网上搜索. 1.AD域服务器实现软件安装部署一.发布应 ...

  2. ad域控服务器如何允许软件安装,AD域服务器实现软件安装部署.doc

    AD域服务器实现软件安装部署 AD域服务器实现软件安装部署 一.发布应用程序 建立安装WINDOWS安装程序包的文件夹 1.请在任何一台服务器上内建立一个文件夹,例如:C:\packages,这个文件 ...

  3. Nginx详细安装部署教程

    一.Nginx简介 Nginx是一个web服务器也可以用来做负载均衡及反向代理使用,目前使用最多的就是负载均衡,具体简介我就不介绍了百度一下有很多,下面直接进入安装步骤 二.Nginx安装 1.下载N ...

  4. Nginx windows安装部署

    一.Nginx简介 Nginx (engine x) 是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP服务器.Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Ramble ...

  5. nginx - nginx的安装部署

    目录 什么是nginx? 1. nginx的安装 1.1  yum安装和编译安装的区别 1.1.1  yum安装的优点和缺点 1.1.2 编译安装的优点和缺点 1.2  nginx编译安装脚本 1.3 ...

  6. nginx的安装部署,热升级与回退,日志切割以及gzip(文字压缩)

    1.安装部署nginx (1)安装 tar zxf nginx-1.14.0.tar.gz vim auto/cc/gcc #CFLAGS="$CFLAGS -g"##注销日志的d ...

  7. Linux软件安装部署文档,MetaQ安装部署文档

    一.MetaQ安装部署情况: 地点 IP Broker ID Master/Slave Slave ID:Group 合肥 192.168.52.23 1 Slave 1:meta-slave-gro ...

  8. nginx的安装部署

    首先切换到nginx用户(确定已经在Linux服务器上新建了一个nginx用户) su nginx 进行安装前的检查,检查服务器上是否安装了gcc-c++ rpm -qa|grep gcc-c++ 如 ...

  9. Nginx+Supervisor安装部署.NET Core项目

    部署环境  OS:CentOS7  .NET Core SDK:2.2.402  安装.NET Core SDK  1.1 安装依赖yum install libunwind libicudotnet ...

最新文章

  1. python 分词包_NLP相关python包
  2. 在8086模拟器中运行汇编求平均值程序
  3. 近6年语音合成领域都有哪些论文?
  4. python关键字参数可以避免什么问题_python入门课|Python关键字参数使用方法公布,能解决80%的python函数问题...
  5. 主板网卡灯关机后还亮_achair的电脑桌面2019 第2集 (机箱风道,Intel无线网卡……)...
  6. ArcGIS中栅格数据的金字塔详解
  7. 屏幕旋转后_网易哒哒H5又又叒刷屏了,TCL·XESS 旋转智屏竟然是一大亮点
  8. C++中默认选中预编译头#includestdafx.h作用
  9. linux系统自行清理归档日志_Linux下自动删除归档日志文件的方法
  10. Jeecg Boot连接人大金仓数据库步骤及常见问题
  11. 最快的 Hexo 博客搭建方法
  12. Retrofit的使用详解(一)
  13. 一键获取graphpad同款主题
  14. wireshark抓包:分析阿里小蜜网络通信方式
  15. android 自定义locale,android – 以编程方式设置Locale
  16. 17 张程序员专属壁纸(使用频率很高)
  17. PIC18f46j50单片机里SPI部分的一点程序
  18. excel表格拆分为多个工作表的操作方法
  19. DCB value for SVN 77 not found on dcb.dat
  20. linux-防火墙开放端口

热门文章

  1. L1正则化与L2正则化
  2. 任务调度框架Quartz用法指南(超详细)
  3. 超级详细的HTML5讲解
  4. 【c++/c】C语言“小小计算器”基本功能实现(包含12个实验一篇足以)【期末大作业】
  5. 吴军亲述编程生涯:不用低效率的算法做事情
  6. 严蔚敏《数据结构》——导航
  7. ethz-asl的catkin simple
  8. C语言读写BMP图片(附Github下载链接和视频讲解地址)
  9. 电子入门基础知识之:电阻读数方法
  10. hp台式计算机怎么进bois,hp台式机怎么进bios图解