不信网恋 发表于 2019-2-16 10:03:24

centos软件源码编译安装httpd

  使用CentOS软件过程中,可能需要用编译使用.src的软件源码包,有些是因为需要某些功能,有些是需要某个版本,以下以httpd为例:
  下载源码httpd并编译
# tar -xf httpd-2.4.6.tar.bz2
# cd httpd-2.4.6; ls       #看到install文件
# cat install      #查看帮助,有些软件是README
...
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start
...
#./configure --help#查看编译帮助
# ./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd2
...   #出现错误提示,如果没有此提示,则跳过错误步骤
configure: error: APR not found.Please read the documentation.
  # yum install apr apr-util
# ./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd2 --with-apr-util=/usr/local/apr-util --with-apr=/usr/local/apr
configure: error: pcre-config for libpcre not found. PCRE is required and available from      #错误提示
  # yum install pcre
# ./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/httpd2 --with-apr-util=/usr/local/apr-util --with-apr=/usr/local/apr --with-pcre=/usr/local/pcre
  # make
# make install
  # cd /usr/local/apache2;ls
binbuildcgi-binerrorhtdocsiconsincludelogslibmanmanualmodules
# bin/apachectl start   
# ss -tnl    #查看80端口出现,表示成功启动
  编译安装软件包时,如果是安装在系统默认的安装位置/usr/local则不需要配置软件(但这样不方便以后彻底删除),如果是安装在自定义的路径下,则需要进行以下后续的配置,方便软件(像rpm/yum安装那样)使用;后续配置如下
  # vim /etc/profile.d/apache2.sh#配置系统的软件启动方式
export PATH=/usr/local/apache2/bin:$PATH
  # . /etc/profile.d/apache2.sh
# echo $PATH
/usr/local/apache2/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
  # apachectl stop
# ss -tnl      #80端口关闭,表示配置apachectl命令成功,以后不需要用绝对路径启动,停止。
# vim /etc/ld.so.conf.d/apache2.conf      #导出库文件路径
/usr/local/apache2/lib
# ldconfig -v      #重新生成库文件缓存
  # ln -s /usr/loacl/apache2/include /usr/include/       #导出头文件
  # vim /etc/man_db.conf   #centos 7 ( centos6为/etc/man.conf)
MANDATORY_MANPATH         /usr/local/apache2/man#导出man手册
  一些常用参数说明:
--prefix=:                      #默认安装位置
--sysconfdir=:               #配置文件安装位置
System types:

                --disable-FEATURE               #禁用某功能
--enable-FEATURE[=ARG]      #开启某功能
--with-PACKAGE[=ARG]          #依赖某包
--without-PACKAGE               #忽略某依赖包
  其它的源码软件包类似这样编译,主要查看软件包的INSTALL或README及编译时的./configure帮助



页: [1]
查看完整版本: centos软件源码编译安装httpd