源码包管理

来源:互联网 发布:如何选择网络机顶盒 编辑:程序博客网 时间:2024/06/14 19:46

源码包安装以nginx为例

一、获得源码包途径

1. 官方网站,可以获得最新的软件包 例如Apache www.apache.org Nginx www.nginx.org
2. www.google.com ( pcre cacti ) //rpm包 —— http://rpmfind.net

二、安装源码包

源码包安装一般情况下分三步配置(configure)、编译(make)、安装(make install)

命令 # make  && make install

环境准备
1. 编译环境如gcc编译器、make,安装软件包组 开发工具(生产环境中不建议装)
2. 准备软件
nginx-1.4.4.tar.gz
部署Nginx
1. nginx
# useradd www //为nginx进程准备运行的用户
# tar xvf nginx-1.4.4.tar.gz -C /usr/src/
# cd nginx-1.4.4
# ./configure --help
# ./configure \
> --user=www \
> --group=www \
> --prefix=/usr/local/nginx \
> --with-http_stub_status_module \
> --with-http_sub_module \
> --with-http_ssl_module \
> --with-pcre
注:
--user指定进程运行的用户
--with-http_stub_status_module启用状态模块功能
--with-http_sub_module启用子模块功能
--with-http_ssl_module启用加密模块
--with-pcre支持正则表达式
pcre: 支持正则表达式,地址重写rewrite
# yum -y install pcre pcre-devel
# make
# make install
# /usr/local/nginx/sbin/nginx //启动nginx服务器
三、详解源码安装三步曲:
# ./configure
a. 指定安装路径,例如--prefix=/usr/local/nginx
157/335
b. 启用或禁用某项功能, 例如 --with-http_ssl_module
c. 和其它软件关联,例如--with-pcre
d. 检查安装环境,例如是否有编译器gcc,是否满足软件的依赖需求
最终生成:Makefile
# make clean //用于反复添加或者删除功能清理掉编译后产生的 *.o目标文件
# make //按Makefile文件编译,可以使用-j 2指定两颗CPU编译
# make install //安装,将相应的文件拷贝到指定的目录下
源码安装错误示例:
error1:
checking for PCRE JIT support ... found
checking for system md library ... not found
checking for system md5 library ... not found
checking for OpenSSL md5 crypto library ... not found
checking for sha1 in system md library ... not found
checking for OpenSSL sha1 crypto library ... not found
checking for zlib library ... not found
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
解决方案:
# yum -y install zlib-devel
error2:
./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.
解决方案:
# yum -y install openssl-devel
error3:
# ./configure --prefix=/usr/local/pcre-8.31
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/pcre-8.31':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
158/335
解决方案:

# LANG=C yum -y groupinstall "Development tools"


注:

如机器上所需要的工具包都齐全的话,一步到位 不报这些需要这包那包的错误。

0 0
原创粉丝点击