zoukankan      html  css  js  c++  java
  • 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 \
  • 相关阅读:
    windows根据端口号杀进程
    eclipse快捷键
    Parameter 'ids' not found. Available parameters are [array]
    java 根据ip获取地区信息(淘宝和新浪)
    unicode转中文
    Maven构建项目出现No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    Spring Boot使用注解实现AOP
    java源码equals和hashCode
    SpringBoot+mybatis使用@Transactional无效
    第三十一节 用类对函数进行装饰
  • 原文地址:https://www.cnblogs.com/shihao/p/2312900.html
Copyright © 2011-2022 走看看