Chinaunix首页 | 论坛 | 博客
  • 博客访问: 284714
  • 博文数量: 37
  • 博客积分: 1296
  • 博客等级: 中尉
  • 技术积分: 481
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-24 17:00
文章分类

全部博文(37)

文章存档

2013年(1)

2011年(21)

2010年(4)

2009年(2)

2007年(9)

我的朋友

分类: LINUX

2010-09-19 18:04:47

好多机器要更新程序,跑脚本编译是方便。但是对系统的环境要求较高,准备自己打rpm包来搞定。
搞的差不多了,做个记录。 转贴留名
 
首先说一下rpm包的理念:
rpm包是把你编译成功的文件放到固定的地方,并附上一定的权限。你也能使用rpm的script 让rpm在安装前和安装后执行某些script来完成某些特殊操作。

文件位置:默认编译环境是在/usr/src/redhat目录下
          分别有 BUILD  RPMS  SOURCES  SPECS  SRPMS
          编译临时文件  rpm包 源文件 spec文件 包含源代码rpm包

下面是spec文件中的相关定义:
Summary: service    #包的定义
Name: nginx         #包的名字
Version: 0.7.19
Release: 1
License: new
Group: Applications/Internet     #有很多基本的group 可以选择像的
URL:
ExclusiveArch: ExclusiveArch: i386  #编译的cpu环境 64位是 x86_64
Requires: pcre openssl zlib         #安装之前需要的系统环境
Packager: Minming XU                #作者
Vendor: PPlive.com.cn
Source: nginx-0.7.19.tar.gz   # 这个配置很重要,系统在打包前会先解压缩源码包,写错了就会无法找到解压缩的源码。  默认是放在 /usr/src/redhat/SOURCE 下面的。
 
%description  #介绍
Nginx
 
 
%prep  # 编译前的环境修改
ls /usr/local/nginx && mv /usr/local/nginx /usr/local/nginx-old
%setup
%build #编译
export NGINX_HOME=/usr/local/nginx
./configure \
 --with-http_perl_module  \
 --with-http_sub_module \
 --with-http_stub_status_module \
 --with-http_realip_module \
 --without-http_fastcgi_module \
 --prefix=/usr/local/nginx
make
make install
#编译完成后 可以在写一些配置文件到相应的目录下。大家方便。
cat > ${NGINX_HOME}/conf/nginx.conf << "EOF"
user  nobody;
worker_processes 4;
worker_rlimit_nofile 65535 ;
pid   /home/nginx/nginx.pid;
events {
    use epoll;
    worker_connections  65535;
}
http {
    include       mime.types;
    include       proxy.conf;
    default_type  application/octet-stream;
    limit_zone one $binary_remote_addr 10m;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 16k;
    server_names_hash_bucket_size 64;
    upstream  127.0.0.1  {
         server 127.0.0.1:80 max_fails=3  fail_timeout=5s;
    }
   
    sendfile       off;
    tcp_nopush     on;
    tcp_nodelay    on;
    keepalive_timeout  120;
    include       8080.19765.conf;
    include       80.conf;
    include       81.conf;
    include       squid.conf;
}
EOF
%install
%files    # 那些编译完成的文件会被放到rpm包中,如果没有指定。只有debug-info的包。
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi/*
/usr/local/nginx/*
/etc/init.d/nginx
%attr(0755,root,root) /etc/init.d/nginx  #在文件安装完成后可以赋予单个文件相应的权限
                                         #%defattr是赋予整个rpm内文件的所有权限
                                         #如果想去除某个目录用 %exclude %{_libdir}/debug 也可以使用实际目录。
 
%pre
#在rpm安装前执行的脚本
if [ -d /usr/local/nginx ]; then
 mv /usr/local/nginx /usr/local/nginx.`/bin/date +%y-%m-%d`
fi
 
%post
#在rpm安装后执行的脚本
/usr/local/nginx/nginx_conf.sh
rm /usr/local/nginx/nginx_conf.sh # 这些脚本都要在前面定义后方能执行。
ln -s /etc/init.d/nginx /etc/rc3.d/S80nginx

%changelog  #写写日志啥的
* Thu Sep 17 2010 Minming Xu pplive Vod <> 1.1
- fix nginxu conf for squid


完成后用 rpmbuild -ba name.spec 编译生成rpm包
阅读(1420) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~