第三章:源码编译安装

第一步,执行脚本configure文件

1 ./configure --prefix=软件安装路径
2 
3 针对C、C++代码,进行编译安装,需要指定配置文件`Makefile`,需要通过`configure`脚本生成
4 通过选项传递参数,指定启用特性、安装路径等<执行时会生成makefile
5 检查依赖到的外部环境

第二步,执行make命令

make是Linux开发套件里面自动化编译的一个控制程序,他通过借助 Makefile 里面编写的编译规范进行自动化的调用 gcc 、ld 以及运行某些需要的程序进行编译的程序。一般情况下,他所使用的 Makefile 控制代码,由 configure 这个设置脚本根据给定的参数和系统环境生成。

make这一步就是编译,大多数的源代码包都经过这一步进行编译(当然有些perl或python编写的软件需要调用perl或python来进行编译)

make 的作用是开始进行源代码编译,以及一些功能的提供,这些功能由他的 Makefile 设置文件提供相关的功能,比如 make install 一般表示进行安装,make uninstall 是卸载,不加参数就是默认的进行源代码编译。

第三步,开始安装make install

开始安装软件到./configure指定的安装路径

案例:源码编译安装nigix

 1 1.准备编译环境
 2 [root@localhost opt]# yum install gcc patch libffi-devel python-devel  zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel openssl openssl-devel -y
 3 2.获取nginx源代码 
 4 [root@localhost opt]# wget http://nginx.org/download/nginx-1.2.9.tar.gz
 5 3.解压缩nginx源代码
 6 [root@localhost opt]# tar -zxvf nginx-1.2.9.tar.gz 
 7 4.进入源码目录
 8 [root@localhost opt]# cd nginx-1.2.9
 9 5.开始编译
10 [root@localhost nginx-1.2.9]# ./configure --prefix=/opt/nginx112/  --with-http_ssl_module --with-http_stub_status_module 
11 6.执行make指令,调用gcc等编译工具,make install开始安装
12 [root@localhost nginx-1.2.9]#  make && make install
13 7.安装后启动nginx软件,找到二进制程序,以绝对路径执行
14 [root@localhost opt]# /opt/nginx112/sbin/nginx
15 8.检查环境变量,需要手动配置nginx的PATH路径,否则必须绝对路径才能找到
16 9.编辑文件/etc/profile.d/nginx.sh 写入export PATH=/opt/ngx112/sbin:$PATH2
18 10.退出会话,重新登录机器logout检查环境变量
19 [root@localhost ~]# logout
21 11. [root@linux ngx112]# cat /etc/profile.d/nginx.sh
22 export PATH=/opt/ngx112/sbin:$PATH
23 12.启动nginx,可以访问页面

修改系统语言(中英文)

export LC_ALL=en_US.UTF-8
export LC_ALL=zh_CN.UTF-8

 

posted @ 2020-12-09 16:15  寒江孤影(打工仔)  阅读(143)  评论(0编辑  收藏  举报