Linux获取程序编译参数

作为系统管理员,经常会碰到这样一个场景:刚接手应用系统不久,业务扩展迅速,老板要求你再搭建N个应用环境,并希望尽量与运行中的平台一致。
犯难的是,前同事留下的文档不详细,没有关于几个主要Service的编译参数。这时你就必须设法取得信息。

1.通过软件包自己的version参数或者debug工具
例如,MySQL软件包中的mysqlbug,执行该工具,将返回debug信息,过滤出其中的Configure command代码块即可

1
2
3
4
5
6
7
8
9
10
Configure command: ./configure  '--disable-shared' '--with-server-suffix=-community' '--without-plugin-ndbcluster' '--with-plugin-innobase' '
--with-plugin-partition' '--with-plugin-csv' '--with-plugin-archive' '--with-plugin-blackhole' '--with-plugin-federated' '--without-plugin-da
emon_example' '--without-plugin-ftexample' '--without-plugin-example' '--with-embedded-server' '--without-bench' '--with-big-tables' '--enabl
e-assembler' '--enable-local-infile' '--with-mysqld-user=mysql' '--with-unix-socket-path=/var/lib/mysql/mysql.sock' '--with-pic' '--prefix=/'
'--with-extra-charsets=complex' '--with-ssl' '--exec-prefix=/usr' '--libexecdir=/usr/sbin' '--libdir=/usr/lib' '--sysconfdir=/etc' '--datadi
r=/usr/share' '--localstatedir=/var/lib/mysql' '--infodir=/usr/share/info' '--includedir=/usr/include' '--mandir=/usr/share/man' '--enable-th
read-safe-client' '--with-comment=MySQL Community Server (GPL)' '--with-readline' '--with-zlib-dir=bundled' 'CC=gcc' 'CFLAGS=-O2 -g -pipe -Wa
ll -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32 -march=i386 -mtune=generic -fasynchronous-unwind-tab
les' 'LDFLAGS=' 'CXX=gcc' 'CXXFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m32
-march=i386 -mtune=generic -fasynchronous-unwind-tables -felide-constructors -fno-exceptions -fno-rtti '

附上其他常用service编译参数的查看方法

1
2
3
4
查看nginx编译参数:nginx -V
查看apache编译参数:cat /usr/local/apache/build/config.nice
查看mysql编译参数:mysqlbug
查看php编译参数:php -i | grep configure

All Tested OK!

2.利用SRPM包的spec文件获取build信息
以上查看Apache编译的方法,只能service是采用tar.gz安装的环境。如果是rpm安装,利用该方法是行不通的,rpm安装的service,并不会留下config.nice。
解决办法就是搜索该软件是否有发布SRPM(.src.rpm后缀),将其解压,查看spec文件中的%build代码块。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
%build
......
../configure -C \
--prefix=%{_sysconfdir}/httpd \
--with-apr=/usr/bin/apr-config \
--with-apr-util=/usr/bin/apu-config \
--exec-prefix=%{_prefix} \
--bindir=%{_bindir} \
--sbindir=%{_sbindir} \
--mandir=%{_mandir} \
--libdir=%{_libdir} \
--sysconfdir=%{_sysconfdir}/httpd/conf \
--includedir=%{_includedir}/httpd \
--libexecdir=%{_libdir}/httpd/modules \
--datadir=%{contentdir} \
--with-mpm=$mpm \
--enable-suexec --with-suexec \
--with-suexec-caller=%{suexec_caller} \
--with-suexec-docroot=%{contentdir} \
--with-suexec-logfile=%{_localstatedir}/log/httpd/suexec.log \
--with-suexec-bin=%{_sbindir}/suexec \
--with-suexec-uidmin=500 --with-suexec-gidmin=500 \
--with-devrandom \
--with-ldap --enable-ldap --enable-auth-ldap \
--enable-cache --enable-disk-cache --enable-mem-cache --enable-file-cache \
--enable-ssl --with-ssl \
--enable-deflate --enable-cgid \
--enable-proxy --enable-proxy-connect \
--enable-proxy-http --enable-proxy-ftp \
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值