Create nginx spec sharing

Source: Internet
Author: User
Tags php and mysql

I will share with you the spec file of an nginx RPM package I made on Qihoo side. I will share with you the spec of common software for PHP and MySQL. When you create an RPM package, you can refer to this document. Later, some kernel-optimized parameters, especially the fast release and reuse of TCP, are included, we can discuss the problem together. You can add this QQ Group 325525293. Next I will explain the important content.

% DEFINE _ topdir/Qihoo/centos/

% DEFINE _ specdir % {_ topdir}/spec

% DEFINE _ rpmdir % {_ topdir }/

% DEFINE _ srcrpmdir % {_ topdir}/srpms

% DEFINE _ sourcedir % {_ topdir}/sources

% DEFINE _ tmppath % {_ topdir}/tmp

% DEFINE _ builddir % {_ topdir}/build

% DEFINE _ prefix/usr/local/nginx

% DEFINE _ docroot_dir/usr/local/nginx/html

 

Summary: Qihoo custom nginx package

Name: Qihoo-ops-nginx # Name of the generated rpm

Version: 1.6.1

Release: 1_qihoo.el6

Vendor: gehailong <[email protected]>

Source: nginx-00000000version).tar.gz # source refers to the content such as the script and configuration file that you have defined.

Source1: nginx. conf # nginx has made many optimizations in the main configuration file, including CPU preemption, various cache policies, TCP, and number of processes.

Source2: sysctl. conf

Source 3: root.tar.gz

# Source4: nginx-module.tar.gz

Source5: nginx. logrotate # To prevent nginx log files from increasing gradually and affect the read/write efficiency, nginx logs are regularly cut.

Source6: nginx. init

Source7: FastCGI. conf

URL: http://w2.addops.bjt.qihoo.net: 8360

License: GPL

GROUP: Applications/Internet

Buildroot: % {_ tmppath}/% {name}-% {version}-root/

Requires: Bash OpenSSL-devel curl-develpcre PCRE-devel OpenSSL # mainly defines some RPM packages on which nginx depends. Is the dependent package when yum is installed.

Autoreq: No

% Description

Qihoo custom nginx rpm

% Prep

% Setup-Q-N nginx-% {version}

% Build # This stage is the configure stage.

 

./Configure \

-- Prefix =%{_ prefix }\

With-http_stub_status_module \

With-http_ssl_module \

 

Make % {? _ Smp_mflags} # Make stage

 

 

% Install # make install stage

 

[$ Rpm_build_root! = "/"] & Rm-RF $ rpm_build_root

 

Make destdir = $ rpm_build_root install # The following describes the directories and files to be generated.

Mkdir-p $ rpm_build_root/usr % {_ prefix}/CONF/vhosts

Mkdir-p $ {rpm_build_root} % {_ prefix}/modules

Mkdir-p $ {rpm_build_root} % {_ prefix}/PID

Mkdir-p $ {rpm_build_root} % {_ prefix}/CONF/include

 

Mkdir-p $ {rpm_build_root} % {_ docroot_dir}

% {__ Tar}-zxvf % {soure3}-C $ rpm_build_root % {_ docroot_dir}

 

Mkdir-p $ {rpm_build_root}/home/Q/PHP

Mkdir-p $ {rpm_build_root}/home/Q/System

 

# % {__ Tar}-zxvf % {source4}-C $ {rpm_build_root }%{_ prefix}/modules/

 

[-F $ {rpm_build_root} % {_ prefix}/CONF/nginx. conf] & \

Rm-fr $ {rpm_build_root} % {_ prefix}/CONF/nginx. conf

CP-RF % {source1 }$ {rpm_build_root }%{_ prefix}/CONF/

Mkdir-p $ {rpm_build_root}/etc/logrotate. d/

CP-RF % {source5 }$ {rpm_build_root}/etc/logrotate. d/nginx

Mkdir-p $ {rpm_build_root}/etc/init. d/

CP-fr % source6 $ {rpm_build_root}/etc/init. d/nginx

Rm-fr $ {rpm_build_root} % {_ prefix}/CONF/FastCGI. conf

CP-RF % {source7 }$ {rpm_build_root }%{_ prefix}/CONF/

Mkdir $ rpm_build_root % {_ prefix}/CONF/vhosts/

Touch $ rpm_build_root % {_ prefix}/CONF/vhosts/blank. conf

 

Rm-fr $ rpm_build_root % {_ prefix}/* temp

 

% Files # note that the previously compiled content must be packaged at this stage. Exclude indicates that you want to exclude the content from packaging.

 

% Defattr (-, root, root, 755)

% {_ Prefix}

% {_ Docroot_dir}

% ATTR (0655, root, root) % config % {_ sysconfdir}/init. d/nginx

% ATTR (0655, root, root) % config % {_ sysconfdir}/logrotate. d/nginx

/Home

% Exclude % DIR/home

 

% Pre # pre indicates what to do before installation, that is, set up the nginx user first.

If ["$1"-EQ "1"]; then

/Usr/sbin/useradd-c "nginx "\

-S/sbin/nologin-r-D % {_ docroot_dir} nginx 2>/dev/null |:

Fi

 

% Post # indicates the operations after the installation is complete.

If ["$1"-EQ "1"]; then

/Sbin/chkconfig -- add nginx

/Sbin/chkconfig -- level 35 nginx on

Chown-r nginx: nginx % {_ docroot_dir }%{_ prefix}

 

Echo '# Add # The following describes Kernel Parameter Optimization, including fast release and reuse of TCP.

Net. ipv4.tcp _ max_syn_backlog = 65536

Net. Core. netdev_max_backlog = 32768

Net. Core. somaxconn = 32768

 

Net. Core. wmem_default = 8388608

Net. Core. rmem_default = 8388608

Net. Core. rmem_max = 16777216

Net. Core. wmem_max = 16777216

 

Net. ipv4.tcp _ timestamps = 0

Net. ipv4.tcp _ synack_retries = 2

Net. ipv4.tcp _ syn_retries = 2

 

Net. ipv4.tcp _ tw_recycle = 1

Net. ipv4.tcp _ tw_reuse = 1

 

Net. ipv4.tcp _ mem = 94500000 915000000927000000

Net. ipv4.tcp _ max_orphans = 3276800

 

# Net. ipv4.tcp _ fin_timeout = 30

# Net. ipv4.tcp _ keepalive_time = 120

Net. ipv4.ip _ local_port_range = 1024 65535 '>/etc/sysctl. conf

Sysctl-P 2> & 1/dev/null

Fi

If ["$1"-EQ "2"]; then

If [-F/var/lock/subsys/nginx]; then

% {_ Sysconfdir}/init. d/nginx restart

Fi

Fi

Rm-fr % {_ prefix}/* temp

 

% Preun # This is preparations before uninstallation.

If ["$1"-EQ "0"]; then

% {_ Sysconfdir}/init. d/nginx stop>/dev/null 2> & 1

/Sbin/chkconfig -- del nginx

 

Fi

% Postun # This is the process of uninstalling. Pay attention to manually backing up the content that needs to be backed up before uninstalling to prevent regret for a lifetime. Sometimes O & M really cannot afford to hurt !!!

/Usr/sbin/userdel nginx

Rm-fr % {_ prefix}

% Clean

 


This article from the "Long Brother" blog, please be sure to keep this source http://gehailong.blog.51cto.com/765312/1548961

Create nginx spec sharing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.