linux部署web服务器-Nginx

本文详细介绍如何在Linux环境下手动部署Nginx web服务器,包括安装必要的编译库、下载并安装PCRE库、下载及配置Nginx,并提供配置示例。

linux部署web服务器-Nginx

前言:

有很多小伙伴想要建立一个自己的web站点,今天就给大家演示一下。

准备工作:

1、Nginx安装包;

2、Linux服务器;

3、PCRE安装包;

4、手。

方式一:手动编译安装

1、安装编译库

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile

  • base: mirrors.aliyun.com
  • extras: mirrors.aliyun.com
  • updates: mirrors.aliyun.com
    软件包 1:make-3.82-24.el7.x86_64 已安装并且是最新版本
    软件包 gcc-c+±4.8.5-44.el7.x86_64 已安装并且是最新版本
    软件包 libtool-2.4.2-22.el7_3.x86_64 已安装并且是最新版本
    正在解决依赖关系
    –> 正在检查事务
    —> 软件包 openssl.x86_64.1.1.0.2k-19.el7 将被 升级
    —> 软件包 openssl.x86_64.1.1.0.2k-25.el7_9 将被 更新
    –> 正在处理依赖关系 openssl-libs(x86-64) = 1:1.0.2k-25.el7_9,它被软件包 1:openssl-1.0.2k-25.el7_9.x86_64 需要
    —> 软件包 openssl-devel.x86_64.1.1.0.2k-25.el7_9 将被 安装
    –> 正在处理依赖关系 krb5-devel(x86-64),它被软件包 1:openssl-devel-1.0.2k-25.el7_9.x86_64 需要
    —> 软件包 zlib.x86_64.0.1.2.7-18.el7 将被 升级
    —> 软件包 zlib.x86_64.0.1.2.7-20.el7_9 将被 更新
    —> 软件包 zlib-devel.x86_64.0.1.2.7-20.el7_9 将被 安装
    –> 正在检查事务
    —> 软件包 krb5-devel.x86_64.0.1.15.1-51.el7_9 将被 安装
    –> 正在处理依赖关系 libkadm5(x86-64) = 1.15.1-51.el7_9,它被软件包 krb5-devel-1.15.1-51.el7_9.x86_64 需要
    –> 正在处理依赖关系 krb5-libs(x86-64) = 1.15.1-51.el7_9,它被软件包 krb5-devel-1.15.1-51.el7_9.x86_64 需要
    –> 正在处理依赖关系 libverto-devel,它被软件包 krb5-devel-1.15.1-51.el7_9.x86_64 需要
    –> 正在处理依赖关系 libselinux-devel,它被软件包 krb5-devel-1.15.1-51.el7_9.x86_64 需要
    –> 正在处理依赖关系 libcom_err-devel,它被软件包 krb5-devel-1.15.1-51.el7_9.x86_64 需要
    –> 正在处理依赖关系 keyutils-libs-devel,它被软件包 krb5-devel-1.15.1-51.el7_9.x86_64 需要
    —> 软件包 openssl-libs.x86_64.1.1.0.2k-19.el7 将被 升级
    —> 软件包 openssl-libs.x86_64.1.1.0.2k-25.el7_9 将被 更新
    –> 正在检查事务
    —> 软件包 keyutils-libs-devel.x86_64.0.1.5.8-3.el7 将被 安装
    —> 软件包 krb5-libs.x86_64.0.1.15.1-50.el7 将被 升级
    –> 正在处理依赖关系 krb5-libs(x86-64) = 1.15.1-50.el7,它被软件包 krb5-server-1.15.1-50.el7.x86_64 需要
    –> 正在处理依赖关系 krb5-libs(x86-64) = 1.15.1-50.el7,它被软件包 krb5-workstation-1.15.1-50.el7.x86_64 需要
    –> 正在处理依赖关系 krb5-libs(x86-64) = 1.15.1-50.el7,它被软件包 krb5-pkinit-1.15.1-50.el7.x86_64 需要
    —> 软件包 krb5-libs.x86_64.0.1.15.1-51.el7_9 将被 更新
    —> 软件包 libcom_err-devel.x86_64.0.1.42.9-19.el7 将被 安装
    —> 软件包 libkadm5.x86_64.0.1.15.1-50.el7 将被 升级
    —> 软件包 libkadm5.x86_64.0.1.15.1-51.el7_9 将被 更新
    —> 软件包 libselinux-devel.x86_64.0.2.5-15.el7 将被 安装
    –> 正在处理依赖关系 libsepol-devel(x86-64) >= 2.5-10,它被软件包 libselinux-devel-2.5-15.el7.x86_64 需要
    –> 正在处理依赖关系 pkgconfig(libsepol),它被软件包 libselinux-devel-2.5-15.el7.x86_64 需要
    –> 正在处理依赖关系 pkgconfig(libpcre),它被软件包 libselinux-devel-2.5-15.el7.x86_64 需要
    —> 软件包 libverto-devel.x86_64.0.0.2.5-4.el7 将被 安装
    –> 正在检查事务
    —> 软件包 krb5-pkinit.x86_64.0.1.15.1-50.el7 将被 升级
    —> 软件包 krb5-pkinit.x86_64.0.1.15.1-51.el7_9 将被 更新
    —> 软件包 krb5-server.x86_64.0.1.15.1-50.el7 将被 升级
    —> 软件包 krb5-server.x86_64.0.1.15.1-51.el7_9 将被 更新
    base/7/x86_64/filelists_db | 7.2 MB 00:00:13
    —> 软件包 krb5-workstation.x86_64.0.1.15.1-50.el7 将被 升级
    —> 软件包 krb5-workstation.x86_64.0.1.15.1-51.el7_9 将被 更新
    —> 软件包 libsepol-devel.x86_64.0.2.5-10.el7 将被 安装
    —> 软件包 pcre-devel.x86_64.0.8.32-17.el7 将被 安装
    –> 解决依赖关系完成

依赖关系解决

=======================================================================================

Package 架构 版本 源 大小

正在安装:
openssl-devel x86_64 1:1.0.2k-25.el7_9 updates 1.5 M
zlib-devel x86_64 1.2.7-20.el7_9 updates 50 k
正在更新:
openssl x86_64 1:1.0.2k-25.el7_9 updates 494 k
zlib x86_64 1.2.7-20.el7_9 updates 90 k
为依赖而安装:
keyutils-libs-devel x86_64 1.5.8-3.el7 base 37 k
krb5-devel x86_64 1.15.1-51.el7_9 updates 273 k
libcom_err-devel x86_64 1.42.9-19.el7 base 32 k
libselinux-devel x86_64 2.5-15.el7 base 187 k
libsepol-devel x86_64 2.5-10.el7 base 77 k
libverto-devel x86_64 0.2.5-4.el7 base 12 k
pcre-devel x86_64 8.32-17.el7 base 480 k
为依赖而更新:
krb5-libs x86_64 1.15.1-51.el7_9 updates 809 k
krb5-pkinit x86_64 1.15.1-51.el7_9 updates 167 k
krb5-server x86_64 1.15.1-51.el7_9 updates 1.0 M
krb5-workstation x86_64 1.15.1-51.el7_9 updates 820 k
libkadm5 x86_64 1.15.1-51.el7_9 updates 179 k
openssl-libs x86_64 1:1.0.2k-25.el7_9 updates 1.2 M

事务概要

安装 2 软件包 (+7 依赖软件包)
升级 2 软件包 (+6 依赖软件包)

总计:7.3 M
总下载量:5.0 M
Downloading packages:
No Presto metadata available for updates
(1/13): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm | 37 kB 00:00:00
(2/13): krb5-devel-1.15.1-51.el7_9.x86_64.rpm | 273 kB 00:00:00
(3/13): libcom_err-devel-1.42.9-19.el7.x86_64.rpm | 32 kB 00:00:00
(4/13): krb5-pkinit-1.15.1-51.el7_9.x86_64.rpm | 167 kB 00:00:00
(5/13): libsepol-devel-2.5-10.el7.x86_64.rpm | 77 kB 00:00:00
(6/13): libverto-devel-0.2.5-4.el7.x86_64.rpm | 12 kB 00:00:00
(7/13): libkadm5-1.15.1-51.el7_9.x86_64.rpm | 179 kB 00:00:00
(8/13): libselinux-devel-2.5-15.el7.x86_64.rpm | 187 kB 00:00:00
(9/13): krb5-libs-1.15.1-51.el7_9.x86_64.rpm | 809 kB 00:00:02
(10/13): pcre-devel-8.32-17.el7.x86_64.rpm | 480 kB 00:00:01
(11/13): openssl-devel-1.0.2k-25.el7_9.x86_64.rpm | 1.5 MB 00:00:03
(12/13): zlib-devel-1.2.7-20.el7_9.x86_64.rpm | 50 kB 00:00:00

(13/13): openssl-libs-1.0.2k-25.el7_9.x86_64.rpm | 1.2 MB 00:00:03

总计 843 kB/s | 5.0 MB 00:06
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
正在更新 : zlib-1.2.7-20.el7_9.x86_64 1/25
正在更新 : 1:openssl-libs-1.0.2k-25.el7_9.x86_64 2/25
正在更新 : krb5-libs-1.15.1-51.el7_9.x86_64 3/25
正在更新 : libkadm5-1.15.1-51.el7_9.x86_64 4/25
正在安装 : zlib-devel-1.2.7-20.el7_9.x86_64 5/25
正在安装 : libcom_err-devel-1.42.9-19.el7.x86_64 6/25
正在安装 : libverto-devel-0.2.5-4.el7.x86_64 7/25
正在安装 : libsepol-devel-2.5-10.el7.x86_64 8/25
正在安装 : keyutils-libs-devel-1.5.8-3.el7.x86_64 9/25
正在安装 : pcre-devel-8.32-17.el7.x86_64 10/25
正在安装 : libselinux-devel-2.5-15.el7.x86_64 11/25
正在安装 : krb5-devel-1.15.1-51.el7_9.x86_64 12/25
正在安装 : 1:openssl-devel-1.0.2k-25.el7_9.x86_64 13/25
正在更新 : krb5-workstation-1.15.1-51.el7_9.x86_64 14/25
正在更新 : krb5-server-1.15.1-51.el7_9.x86_64 15/25
正在更新 : 1:openssl-1.0.2k-25.el7_9.x86_64 16/25
正在更新 : krb5-pkinit-1.15.1-51.el7_9.x86_64 17/25
清理 : 1:openssl-1.0.2k-19.el7.x86_64 18/25
清理 : krb5-pkinit-1.15.1-50.el7.x86_64 19/25
清理 : krb5-server-1.15.1-50.el7.x86_64 20/25
清理 : krb5-workstation-1.15.1-50.el7.x86_64 21/25
清理 : libkadm5-1.15.1-50.el7.x86_64 22/25
清理 : 1:openssl-libs-1.0.2k-19.el7.x86_64 23/25
清理 : krb5-libs-1.15.1-50.el7.x86_64 24/25
清理 : zlib-1.2.7-18.el7.x86_64 25/25
验证中 : libselinux-devel-2.5-15.el7.x86_64 1/25
验证中 : krb5-libs-1.15.1-51.el7_9.x86_64 2/25
验证中 : krb5-workstation-1.15.1-51.el7_9.x86_64 3/25
验证中 : 1:openssl-1.0.2k-25.el7_9.x86_64 4/25
验证中 : pcre-devel-8.32-17.el7.x86_64 5/25
验证中 : keyutils-libs-devel-1.5.8-3.el7.x86_64 6/25
验证中 : libsepol-devel-2.5-10.el7.x86_64 7/25
验证中 : libkadm5-1.15.1-51.el7_9.x86_64 8/25
验证中 : libverto-devel-0.2.5-4.el7.x86_64 9/25
验证中 : krb5-server-1.15.1-51.el7_9.x86_64 10/25
验证中 : 1:openssl-libs-1.0.2k-25.el7_9.x86_64 11/25
验证中 : krb5-pkinit-1.15.1-51.el7_9.x86_64 12/25
验证中 : 1:openssl-devel-1.0.2k-25.el7_9.x86_64 13/25
验证中 : krb5-devel-1.15.1-51.el7_9.x86_64 14/25
验证中 : zlib-devel-1.2.7-20.el7_9.x86_64 15/25
验证中 : zlib-1.2.7-20.el7_9.x86_64 16/25
验证中 : libcom_err-devel-1.42.9-19.el7.x86_64 17/25
验证中 : krb5-pkinit-1.15.1-50.el7.x86_64 18/25
验证中 : zlib-1.2.7-18.el7.x86_64 19/25
验证中 : libkadm5-1.15.1-50.el7.x86_64 20/25
验证中 : krb5-workstation-1.15.1-50.el7.x86_64 21/25
验证中 : 1:openssl-1.0.2k-19.el7.x86_64 22/25
验证中 : 1:openssl-libs-1.0.2k-19.el7.x86_64 23/25
验证中 : krb5-libs-1.15.1-50.el7.x86_64 24/25
验证中 : krb5-server-1.15.1-50.el7.x86_64 25/25

已安装:
openssl-devel.x86_64 1:1.0.2k-25.el7_9 zlib-devel.x86_64 0:1.2.7-20.el7_9

作为依赖被安装:
keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-51.el7_9
libcom_err-devel.x86_64 0:1.42.9-19.el7 libselinux-devel.x86_64 0:2.5-15.el7
libsepol-devel.x86_64 0:2.5-10.el7 libverto-devel.x86_64 0:0.2.5-4.el7
pcre-devel.x86_64 0:8.32-17.el7

更新完毕:
openssl.x86_64 1:1.0.2k-25.el7_9 zlib.x86_64 0:1.2.7-20.el7_9

作为依赖被升级:
krb5-libs.x86_64 0:1.15.1-51.el7_9 krb5-pkinit.x86_64 0:1.15.1-51.el7_9
krb5-server.x86_64 0:1.15.1-51.el7_9 krb5-workstation.x86_64 0:1.15.1-51.el7_9
libkadm5.x86_64 0:1.15.1-51.el7_9 openssl-libs.x86_64 1:1.0.2k-25.el7_9

完毕!

2、下载 安装PCRE

下载地址: http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

[ooyy1102@localhost ~]$ cd /usr/local/src/
[ooyy1102@localhost src]$ su
密码:
[root@localhost src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz

–2022-05-25 13:47:53-- http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
正在解析主机 downloads.sourceforge.net (downloads.sourceforge.net)… 204.68.111.105
正在连接 downloads.sourceforge.net (downloads.sourceforge.net)|204.68.111.105|:80… 已连接。
已发出 HTTP 请求,正在等待回应… 302 Found
位置:http://nchc.dl.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz [跟随至新的 URL]
–2022-05-25 13:47:53-- http://nchc.dl.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
正在解析主机 nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)… 140.110.96.69
正在连接 nchc.dl.sourceforge.net (nchc.dl.sourceforge.net)|140.110.96.69|:80… 已连接。
已发出 HTTP 请求,正在等待回应… 200 OK
长度:1996552 (1.9M) [application/x-gzip]
正在保存至: “pcre-8.35.tar.gz”

100%[=============================================>] 1,996,552 388KB/s 用时 5.0s

2022-05-25 13:47:59 (388 KB/s) - 已保存 “pcre-8.35.tar.gz” [1996552/1996552])

[root@localhost src]# tar zxvf pcre-8.35.tar.gz
[root@localhost src]# cd pcre-8.35/
[root@localhost pcre-8.35]# ./configure
[root@localhost pcre-8.35]# make && make install

checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for a thread-safe mkdir -p… /usr/bin/mkdir -p
checking for gawk… gawk
checking whether make sets $(MAKE)… yes
checking whether make supports nested variables… yes
checking whether make supports nested variables… (cached) yes
checking for style of include used by make… GNU
checking for gcc… gcc
checking whether the C compiler works… yes
checking for C compiler default output file name… a.out
checking for suffix of executables…
checking whether we are cross compiling… no
checking for suffix of object files… o
checking whether we are using the GNU C compiler… yes
checking whether gcc accepts -g… yes
checking for gcc option to accept ISO C89… none needed
checking whether gcc understands -c and -o together… yes
checking dependency style of gcc… gcc3
checking for ar… ar
checking the archiver (ar) interface… ar
checking for gcc… (cached) gcc
checking whether we are using the GNU C compiler… (cached) yes
checking whether gcc accepts -g… (cached) yes
checking for gcc option to accept ISO C89… (cached) none needed
checking whether gcc understands -c and -o together… (cached) yes
checking dependency style of gcc… (cached) gcc3
checking for g++… g++
checking whether we are using the GNU C++ compiler… yes
checking whether g++ accepts -g… yes
checking dependency style of g++… gcc3
checking how to run the C preprocessor… gcc -E
checking for grep that handles long lines and -e… /usr/bin/grep
checking for egrep… /usr/bin/grep -E
checking for ANSI C header files… yes
checking for sys/types.h… y

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值