Name: nginx
Version: 1.7.3
Release: 12%{?dist}
Summary: A free,open-source,high-performance HTTP server
Group: System Environment/Daemons
License: BSD
URL: http://rolin.com/
Source0: http://aa.com/nginx/%{name}-%{version}.tar.gz
Source1: nginx.sysinit
Source2: fastcgi_params
Source3: nginx.conf
Source4: ngx_cache_purge-2.3.tar.gz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
BuildRequires: pcre-devel,zlib-devel,openssl-devel,libxslt-devel,gd-devel,gcc,make
Requires: pcre,openssl,gd
%description
Nginx is a free,open-source,high-performanc HTTP sever and reverse proxy.
%prep
%setup -q
#cd %_topdir/SOURCES/
#tar xf nginx-1.7.3.tar.gz
#cd nginx-1.7.3
%build
export DESTDIR=%{buildroot}
#cd $RPM_SOURCE_DIR/nginx-1.7.3
./configure --prefix=/usr/local/nginx --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-mail --with-mail_ssl_module --with-file-aio --with-ipv6 --with-http_spdy_module --with-cc-opt=‘-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic‘ --add-module=$RPM_SOURCE_DIR/ngx_cache_purge-2.3
#./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module
sudo make %{?_smp_mflags}
%install
sudo rm -rf %{buildroot}
#sudo cp -f ${sources}/nginx.conf /usr/local/nginx/conf
sudo make install DESTDIR=%{buildroot}
#cd $RPM_SOURCE_DIR/nginx-1.7.3
#make DESTDIR=%{buildroot} install
%{__install} -p -D -m 0755 %{SOURCE1} %{buildroot}/usr/local/nginx/sbin
mv %{buildroot}/usr/local/nginx/conf/fastcgi_params %{buildroot}/usr/local/nginx/conf/fastcgi_params.origin
%{__install} -p -D -m 0644 %{SOURCE2} %{buildroot}/usr/local/nginx/conf
mv %{buildroot}/usr/local/nginx/conf/nginx.conf %{buildroot}/usr/local/nginx/conf/nginx.conf.origin
%{__install} -p -D -m 0644 %{SOURCE3} %{buildroot}/usr/local/nginx/conf
%pre
#if [ $1 == 1 ];then
# /usr/sbin/useradd -r www -s /sbin/nologin 2 > /dev/null
#fi
%post
#if [ $1 == 1 ];then
# /sbin/chkconfig --add %{name}
# /sbin/chkconfig %{name} on
#fi
chroot_dir=/data/web_chroot
mkdir -p $chroot_dir/{etc,dev,var,usr,usr/local/nginx,tmp,var/tmp,lib64,lib,bin}
/bin/mknod -m 0666 $chroot_dir/dev/null c 1 3
/bin/mknod -m 0666 $chroot_dir/dev/random c 1 8
/bin/mknod -m 0444 $chroot_dir/dev/urandom c 1 9
/bin/cp -farvp /usr/local/nginx/* $chroot_dir/usr/local/nginx
/bin/cp -rfv /lib64/* $chroot_dir/lib64/
/bin/cp -rvf /lib/* $chroot_dir/lib/
/bin/cp -rfv /bin/{bash,sh} $chroot_dir/bin/
/bin/cp -rf n2chroot /usr/bin/ && chmod +x /usr/bin/n2chroot
n2chroot /usr/local/nginx/sbin/nginx
cp -fv /etc/{group,prelink.cache,services,adjtime,shells,gshadow,shadow,hosts.deny,localtime,nsswitch.conf,nscd.conf,prelink.conf,protocols,hosts,passwd,ld.so.cache,ld.so.conf,resolv.conf,host.conf} $chroot_dir/etc
cp -avr /etc/{ld.so.conf.d,prelink.conf.d} $chroot_dir/etc
/bin/sed -i ‘/\/home\/www/!d‘ $chroot_dir/etc/passwd
/bin/sed -i ‘/www/!d‘ $chroot_dir/etc/group
/bin/sed -i ‘/www/!d‘ $chroot_dir/etc/shadow
/bin/sed -i ‘/www/!d‘ $chroot_dir/etc/gshadow
killall nginx
htpasswd -m -b -c $chroot_dir/usr/local/nginx/.passwd.db s6umfc1kLS qKdDl5C0qdok3dle8eed9EvfaikLkg
/usr/sbin/chroot /$chroot_dir /usr/local/nginx/sbin/nginx
echo ‘/usr/sbin/chroot /data/web_chroot/ /usr/local/nginx/sbin/nginx‘ >> /etc/rc.local
%preun
MSG=`ps aux|grep nginx|grep -v "grep"`
if [ -z MSG ];then
killall nginx 1 >/dev/null 2>/dev/null
fi
%postun
rm -rf %{prefix}
%clean
sudo rm -rf %{buildroot}
%files
%defattr(-,root,root,-)
/usr/local/nginx
%doc LICENSE CHANGES README
%dir /usr/local/nginx/logs
%dir /usr/local/nginx
%config(noreplace) /usr/local/nginx/conf/win-utf
%config(noreplace) /usr/local/nginx/conf/mime.types.default
%config(noreplace) /usr/local/nginx/conf/fastcgi.conf
%config(noreplace) /usr/local/nginx/conf/fastcgi.conf.default
%config(noreplace) /usr/local/nginx/conf/fastcgi_params
%config(noreplace) /usr/local/nginx/conf/fastcgi_params.default
%config(noreplace) /usr/local/nginx/conf/%{name}.conf
%config(noreplace) /usr/local/nginx/conf/mime.types
%config(noreplace) /usr/local/nginx/conf/scgi_params
%config(noreplace) /usr/local/nginx/conf/scgi_params.default
%config(noreplace) /usr/local/nginx/conf/uwsgi_params
%config(noreplace) /usr/local/nginx/conf/uwsgi_params.default
%config(noreplace) /usr/local/nginx/conf/koi-win
%config(noreplace) /usr/local/nginx/conf/koi-utf
%config(noreplace) /usr/local/nginx/conf/%{name}.conf.default
%config(noreplace) /usr/local/nginx/conf/fastcgi_params.origin
%config(noreplace) /usr/local/nginx/conf/nginx.conf.origin
/usr/local/nginx/html/50x.html
/usr/local/nginx/html/index.html
/usr/local/nginx/sbin/nginx
#%attr(0755,root,root) %{_initrddir}/%{name}
%attr(0755,root,root) /usr/local/nginx/sbin
%changelog
* Wed Apr 04 2015 rolin <rolin@rolin.com> - 1
- add nginx.sysinit
* Wed Apr 04 2015 rolin <rolin@rolin.com> - 1
- add paramscgi
* Wed Apr 04 2015 rolin <rolin@rolin.com> - 1
- add nginx.conf
Wed Apr 04 2015 rolin <rolin@rolin.com> - 1.7.3
本文出自 “自动化rolin” 博客,请务必保留此出处http://luoguoling.blog.51cto.com/1568501/1639291
原文地址:http://luoguoling.blog.51cto.com/1568501/1639291