源码安装及定制rpm包

源码安装及定制rpm包


Linux中软件的安装方式


安装包 安装方式
rpm包 rpm、yum
源码包 源码安装
二进制包 解压即用

获取源码包


安装什么服务,就去什么服务的官网,下载源码包

windows安装.exe程序

1651053749262


Linux安装源码包


1651053917608

1651053982799

# 进入nginx官网,下载源码包
http://nginx.org/

# 下载
[root@localhost ~]# wget http://nginx.org/download/nginx-1.20.2.tar.gz
[root@localhost ~]# ll
total 2084
-rw-r--r--. 1 root root 1062124 Nov 16 22:51 nginx-1.20.2.tar.gz

# 解压
[root@localhost ~]# tar xf nginx-1.20.2.tar.gz
# 安装依赖包
[root@localhost nginx-1.20.2]# yum install -y pcre-devel openssl-devel gcc gcc-c++ glibc zlib-devel

# 生成(需要在nginx-1.20.2下生成)
./configure --prefix=/opt/nginx-1.20.2 --with-http_ssl_module --with-http_stub_status_module

# 报错解决
./configure: error: C compiler cc is not found
# 报错原因:缺少C语言环境 解决方法:yum install -y gcc gcc-c++ glibc

# 报错2
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
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.
# 报错原因:缺少pcre库文件 解决方法:yum install -y pcre-devel

# 报错3
./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.
# 报错原因:缺少openssl库文件 解决方法:yum install -y openssl-devel

# 编译(让系统能识别你的代码,并且把刚才指定的功能和路径编译到源码中)
[root@localhost nginx-1.20.2]# make

# 安装
[root@localhost nginx-1.20.2]# make install

# 做软连接
[root@localhost nginx-1.20.2]# ln -s /opt/nginx-1.12.2/ /opt/nginx
[root@localhost nginx-1.20.2]# ll /opt
total 0
lrwxrwxrwx. 1 root root 18 Apr 27 18:44 nginx -> /opt/nginx-1.12.2/
drwxr-xr-x. 6 root root 54 Apr 27 18:44 nginx-1.12.2
[root@localhost nginx-1.20.2]# ll /opt/nginx/
total 4
drwxr-xr-x. 2 root root 4096 Apr 27 18:44 conf
drwxr-xr-x. 2 root root   40 Apr 27 18:44 html
drwxr-xr-x. 2 root root    6 Apr 27 18:44 logs
drwxr-xr-x. 2 root root   19 Apr 27 18:44 sbin

# 系统命令为什么可以直接执行?
因为在环境变量中,有个PATH,只要是PATH所有目录下的可执行程序,都可以直接执行,不需要写绝对路径
[root@localhost nginx-1.20.2]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

# 8.添加nginx的环境变量,让nginx程序可以直接运行
[root@localhost opt]# vim /etc/profile.d/nginx.sh
export PATH="$PATH:/opt/nginx/sbin"

# 9.加载环境变量
[root@localhost opt]# source /etc/profile.d/nginx.sh 

# 启动nginx
[root@localhost opt]# nginx

# 11.检查nginx是否启动成功(端口)
[root@localhost Packages]# netstat -lntup|grep nginx
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN     10398/nginx: master 

[root@localhost Packages]# netstat -lntup

# 12.检查nginx进程
[root@localhost Packages]# ps -ef|grep nginx
root      10398      1  0 20:01 ?        00:00:00 nginx: master process nginx
nobody    10499  10398  0 20:23 ?        00:00:00 nginx: worker process
root      15845   7189  0 20:36 pts/0    00:00:00 grep --color=auto nginx
[root@localhost Packages]#  ps -ef|grep nginx|grep -v 'grep'
root      10398      1  0 20:01 ?        00:00:00 nginx: master process nginx
nobody    10499  10398  0 20:23 ?        00:00:00 nginx: worker process
[root@localhost Packages]#  ps -ef|grep [n]ginx
root      10398      1  0 20:01 ?        00:00:00 nginx: master process nginx
nobody    10499  10398  0 20:23 ?        00:00:00 nginx: worker process

# 13.关闭防火墙
[root@localhost ~]# systemctl stop firewalld

# 14.关闭selinux
[root@localhost ~]# setenforce 0

打开浏览器访问:http://10.0.0.157

1651063092879

posted @   hjx、贤  阅读(37)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· AI 智能体引爆开源社区「GitHub 热点速览」
· Manus的开源复刻OpenManus初探
· 写一个简单的SQL生成工具
点击右上角即可分享
微信分享提示