无法联网的情况下的安装
安装前置依赖
由于某些情况下虚拟机无法联网,导致wget,使用网络yum源安装成为奢望,只能在物理机上下载软件包传输至虚拟机进行安装
百度网盘
链接: 点我下载
https://pan.baidu.com/s/1-st7NAQP7z11W7AJdpV2sw
提取码:m9uw
软件安装包路径如下
[root@localhost FastDFS]# ll /usr/local/src/nginx/
total 7692
-rw-r--r--. 1 root root 1034586 Sep 2 12:43 nginx-1.17.3.tar.gz
-rw-r--r--. 1 root root 4432964 Sep 2 12:43 openssl-1.0.1j.tar.gz
-rw-r--r--. 1 root root 1790055 Sep 2 12:43 pcre-8.32.tar.gz
-rw-r--r--. 1 root root 607698 Sep 2 12:43 zlib-1.2.11.tar.gz
安装gcc,gcc-c++
[root@localhost FastDFS]# yum install -y gcc gcc-c++
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* c7-media:
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-28.el7 will be installed
---> Package gcc-c++.x86_64 0:4.8.5-28.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================
Installing:
gcc x86_64 4.8.5-28.el7 c7-media 16 M
gcc-c++ x86_64 4.8.5-28.el7 c7-media 7.2 M
Transaction Summary
===========================================================================================================================================================
Install 2 Packages
Total download size: 23 M
Installed size: 54 M
Downloading packages:
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Total 195 MB/s | 23 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : gcc-4.8.5-28.el7.x86_64 1/2
Installing : gcc-c++-4.8.5-28.el7.x86_64 2/2
Verifying : gcc-c++-4.8.5-28.el7.x86_64 1/2
Verifying : gcc-4.8.5-28.el7.x86_64 2/2
Installed:
gcc.x86_64 0:4.8.5-28.el7 gcc-c++.x86_64 0:4.8.5-28.el7
Complete!
安装PCRE库
首先,解压缩pcre-8.32.tar.gz
文件
[root@localhost /]# tar -zxvf /usr/local/src/nginx/pcre-8.32.tar.gz -C /opt/
然后进入到/opt/pcre-8.32/
文件夹下,编译安装
[root@localhost pcre-8.32]# ./configure
[root@localhost pcre-8.32]# make
[root@localhost pcre-8.32]# make install
安装SSL库
安装过程与上一步类似
[root@localhost /]# tar -zxvf /usr/local/src/nginx/openssl-1.0.1j.tar.gz -C /opt/
[root@localhost /]# cd /opt/openssl-1.0.1j/
[root@localhost pcre-8.32]# ./config
[root@localhost pcre-8.32]# make
[root@localhost pcre-8.32]# make install
安装zlib库
安装过程与上一步类似
[root@localhost openssl-1.0.1j]# tar -zxvf /usr/local/src/nginx/zlib-1.2.11.tar.gz -C /opt/
[root@localhost openssl-1.0.1j]# cd /opt/zlib-1.2.11/
[root@localhost zlib-1.2.11]# ./configure
[root@localhost zlib-1.2.11]# make
[root@localhost zlib-1.2.11]# make install
安装nginx
解压
[root@localhost /]# tar -zxvf /usr/local/src/nginx/nginx-1.17.3.tar.gz -C /opt/
[root@localhost /]# cd /opt/nginx-1.17.3/
[root@localhost nginx-1.17.3]# ./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module
缺少openssl
此时报错提示没有openssl(我这里是缺少openssl-devel
)
./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-openssl=<path> option.
使用本地yum源(我使用的是centos7的安装光盘)安装openssl后重新进行编译 >>>不会使用本地yum源?点我查看<<<
[root@localhost nginx-1.17.3]# yum -y install openssl openssl-devel
[root@localhost nginx-1.17.3]# ./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module
编译安装
[root@localhost nginx-1.17.3]# make
[root@localhost nginx-1.17.3]# make install
启动
[root@localhost ~]# /usr/local/nginx/sbin/nginx
直接在浏览器上访问此Centos7的地址,出现如下界面说明安装成功