%define nginx_user admin%define nginx_group %{nginx_user}%define nginx_home /export/servers/nginx%define nginx_temp_path /dev/shm/nginx_temp%define nginx_sbin_path %{nginx_home}/sbin%define nginx_sbin_file_path %{nginx_sbin_path}/nginx%define nginx_conf_path %{nginx_home}/conf%define nginx_log_path %{nginx_home}/logs%define nginx_var_path %{nginx_home}/var%define nginx_run_path %{nginx_home}/run%define nginx_temp_proxy_path %{nginx_temp_path}/proxy%define nginx_temp_client_path %{nginx_temp_path}/client_body%define nginx_temp_fastcgi_path %{nginx_temp_path}/fastcgi%define nginx_temp_uwsgi_path %{nginx_temp_path}/uwsgi%define nginx_temp_scgi_path %{nginx_temp_path}/scgiName: nginxVersion: 1.7.2.1Release: 1%{?dist}Summary: nginx, small and high performance http and reverse proxy serverGroup: System Environment/DaemonsLicense: GPLURL: http://nginx.orgSource0: nginx-1.7.2.tar.gzSource1: nginxSource2: logrotate.shSource3: nginx.confSource4: pickingplan_taskassign.location.confSource5: lua.tar.gzSource6: pcre-8.31.zipBuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-%(%{__id_u} -n)BuildRequires: gcc,openssl-devel,pcre-devel,zlib-devel,libtool,gcc-c++Requires: pcre,zlib,opensslRequires: perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))%descriptionNginx [engine x] is an HTTP(S) server, HTTP(S) reverse proxy and IMAP/POP3proxy server written by Igor Sysoev.%prep%setup -q%buildcd %{_builddir}/%{name}-%{version}/bundle/LuaJIT-2.1-20140707make cleanmake -j32make installln -sf luajit-2.1.0-alpha /usr/local/bin/luajitexport DESTDIR=%{buildroot}cd %{_builddir}/%{name}-%{version}mkdir -p %{buildroot}%{nginx_conf_path}./configure --prefix=%{nginx_home} \ --sbin-path=%{nginx_sbin_file_path} \ --conf-path=%{nginx_conf_path}/nginx.conf \ --error-log-path=%{nginx_log_path}/error.log \ --http-log-path=%{nginx_log_path}/access.log \ --pid-path=%{nginx_run_path}/nginx.pid \ --lock-path=%{nginx_var_path}/nginx.lock \ --http-client-body-temp-path=%{nginx_temp_client_path} \ --http-proxy-temp-path=%{nginx_temp_proxy_path} \ --http-fastcgi-temp-path=%{nginx_temp_fastcgi_path} \ --http-uwsgi-temp-path=%{nginx_temp_uwsgi_path} \ --http-scgi-temp-path=%{nginx_temp_scgi_path} \ --user=%{nginx_user} \ --group=%{nginx_group} \ --with-cpu-opt=pentium4F \ --without-select_module \ --without-poll_module \ --with-http_realip_module \ --with-http_sub_module \ --with-http_gzip_static_module \ --without-http_ssi_module \ --without-http_userid_module \ --without-http_geo_module \ --without-http_map_module \ --without-mail_pop3_module \ --without-mail_imap_module \ --without-mail_smtp_module \ --with-http_stub_status_module \ --with-luajit \ --with-http_spdy_module \ --with-pcre=/usr/local/src/pcre-8.31make %{?_smp_mflags}%installrm -rf %{buildroot}make install DESTDIR=%{buildroot}mkdir -p %{buildroot}/dev/shm/nginx_tempmkdir -p %{buildroot}%{nginx_conf_path}/domainsmkdir -p %{buildroot}%{nginx_run_path}mkdir -p %{buildroot}%{nginx_var_path}mkdir -p %{buildroot}%{nginx_var_path}/lua%{__install} -p -D -m 0755 $RPM_SOURCE_DIR/logrotate.sh %{buildroot}%{nginx_sbin_path}%{__install} -p -D -m 0644 $RPM_SOURCE_DIR/nginx.conf %{buildroot}%{nginx_conf_path}%{__install} -p -D -m 0644 $RPM_SOURCE_DIR/pickingplan_taskassign.location.conf %{buildroot}%{nginx_conf_path}/domains%{__install} -p -D -m 0755 $RPM_SOURCE_DIR/nginx %{buildroot}/etc/rc.d/init.d/nginx%{__tar} zxvf $RPM_SOURCE_DIR/lua.tar.gz -C %{buildroot}%{nginx_var_path}/lua%cleanrm -rf %{buildroot}%preif [ $1 == 1 ];then egrep "^admin" /etc/group >& /dev/null if [ $? -ne 0 ];then groupadd -g 600 admin fi egrep "^admin" /etc/passwd >& /dev/null if [ $? -ne 0 ];then useradd -u 600 -g 600 admin fifi%postif [ $1 == 1 ];then /sbin/chkconfig --add %{name} /sbin/chkconfig %{name} onecho '# Add #下面主要是内核参数的优化,包括tcp的快速释放和重利用等。 net.core.somaxconn = 32768net.core.wmem_default = 8388608net.core.rmem_default = 8388608net.core.rmem_max = 16777216net.core.wmem_max = 16777216net.ipv4.tcp_timestamps = 1net.ipv4.tcp_synack_retries = 1net.ipv4.tcp_syn_retries = 0net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_mem = 94500000 915000000 927000000net.ipv4.tcp_max_orphans = 3276800net.ipv4.ip_local_port_range = 1024 65535net.ipv4.tcp_fin_timeout = 10net.ipv4.tcp_keepalive_time = 100net.ipv4.tcp_syncookies = 1net.ipv4.tcp_max_syn_backlog = 8192net.ipv4.tcp_max_tw_buckets = 20000' >> /etc/sysctl.conf sysctl -p > /dev/null 2>&1fiif [ $1 == 1 ];then /sbin/service %{name} restart > /dev/null 2>&1fi%preunif [ $1 == 0 ];then /sbin/service %{name} stop > /dev/null 2>&1 /sbin/chkconfig --del %{name}fi%postunif [ $1 == 0 ];then rm -rf %{nginx_home} sed -i '/# Add #下面主要是内核参数的优化/,$d' /etc/sysctl.conffi%files%defattr(-,root,root,-)%doc/export/dev/etc/usr/local%changelog* Wed Feb 3 2016 Created by lihui-RPMBUILD OpenResty