linux中软件的安装方式

安装包 安装方式
rpm包 rpm yum
源码 编译安装
二进制包 免安装

源码包获取方式:

可以从软件官网获取下载

# nginx官网,下载源码包
wget http://nginx.org/download/nginx-1.20.2.tar.gz
# 解压
tar xf nginx-1.20.2.tar.gz
#cd进入到解压完后的nginx目录
# 生成
./configure --prefix=/opt/nginx-1.20.2 --with-http_ssl_module --with-http_stub_status_module
# 报错1 缺少c语言
./configure: error: C compiler cc is not found
## 解决方法
yum install gcc gcc-c++ glibc -y
# 报错2 缺少pcre依赖
option, or install the PCRE library into
the system, or build the PCRE library
statically from the source with nginx by
using --with-pcre=<path> option.
# 解决方法
yum install -y pcre-devel
# 报错3 缺少openssl依赖
 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 install -y openssl-devel
# 总解决方法
yum install -y openssl-devel pcre-devel gcc gcc-c++ glibc -y
# 编译(为了让系统能识别你的代码,并且吧刚才指定的功能和路径编辑到源码中)
make
# 安装
make install
# 做软连接
ln -s /opt/nginx-1.20.2/ /opt/nginx
# 增加环境变量
vim /etc/profile.d/nginx.sh
export PATH="$PATH:/opt/nginx/sbin"
# 生效环境变量
source /etc/profile
# 关闭防火墙
systemctl stop firewalld
# 关闭selinux
vim /etc/sysconfig/selinux
改selinux=disable
#启动服务
/opt/nginx/sbin/nginx