Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Nginx1.10 compilation and installation

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This is how the Nginx of tens of millions of PV has to be installed.

For more articles, please visit Tortoise Operation and maintenance wuguiyunwei.com.

It has been online for more than six months, and now it is very stable. This is the current arrangement.

Nginx download

Wget http://nginx.org/download/nginx-1.10.3.tar.gz

Openssl download

Wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz

Pcre download

Wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz

Download jemalloc

Wget https://github.com/jemalloc/jemalloc/releases/download/4.5.0/jemalloc-4.5.0.tar.bz2

After decompressing the source code package, the following figure

Optimize Nginx using the ljemalloc memory optimization tool

Jemalloc is a generic malloc (3) implementation that emphasizes fragmentation avoidance and scalable concurrency support. Jemalloc was first used as a FreeBSD libc allocator in 2005, and since then it has discovered many applications that rely on its predictable behavior. In 2010, jemalloc development efforts expanded to include developer support features, such as heap analysis and extensive monitoring / tuning hooks. Modern versions of jemalloc continue to be integrated back into FreeBSD, so versatility is still critical. Ongoing development efforts tend to make jemalloc the best allocator for a wide range of demanding applications and to eliminate / mitigate weaknesses that have a real impact on real-world applications.

Install jemalloc

Next install Nginx

Install some dependencies on yum-y install zlib-devel gcc gcc-c++

Create user useradd-M-s / sbin/nologin www

. / configure-- prefix=/usr/local/nginx-- user=www-- group=www-- with-http_stub_status_module-- with-http_v2_module-- with-http_ssl_module-- with-http_gzip_static_module-- with-http_realip_module-- with-http_flv_module-- with-http_mp4_module-- with-openssl=../openssl-1.1.0e-- with-pcre=../pcre-8.39-- with-pcre-jit -- introduction to with-ld-opt=-ljemalloc module

-with-http_stub_status_module / / Nginx status monitoring module

-with-http_v2_module / / configure Nginx to support HTTP2.0

-with-http_ssl_module / / configure Nginx to support HTTPS

-with-http_gzip_static_module / / enable Gzip static compression

-with-http_realip_module / / getting the client is really ip

-with-http_flv_module / / provides pseudo-streaming server-side support for Flash video (FLV) files

-with-http_mp4_module / / provides pseudo-streaming server-side support for MP4 files. With the .mp4, .m4v or .m4a file extension

-with-openssl=../openssl-1.1.0e / / specifies the ssl library on which the Nginx ssl module depends

-with-pcre=../pcre-8.39 / / specifies the pcre library on which the Nginx pcre module depends

-with-pcre-jit / / build a PCRE library with just-in-time compilation support

-with-ld-opt= / / other parameters passed to the C linker

Start Nginx to check port snooping status successfully as shown below

Next, write a startup script to configure nginx (Centos "6-7" generic)

Installation tool yum-y install coreutils

Install daemontools daemontools is a collection of tools for managing UNIX services

The following installation method is from the official website http://cr.yp.to/daemontools/install.html

Mkdir-p / package

Chmod 1755 / packagecd / package

Download wget http://cr.yp.to/daemontools/daemontools-0.76.tar.gz

Gunzip daemontools-0.76.tar

Tar-xpf daemontools-0.76.tar

Rm-f daemontools-0.76.tar

Cd admin/daemontools-0.76

Installation

Sed-I 's/extern int errno;/#include / 1'. / src/error.h

Package/install

The content of the script can be directly copied and pasted as follows (please configure the environment above)

Vim / etc/init.d/nginx

Chmode + x / etc/init.d/nginx

Cent7 is as follows

Cent6 is as follows

#! / bin/sh# chkconfig:-86 "http://goyun.org. / etc/rc.d/init.d/functions. / etc/sysconfig/network ["$NETWORKING" = "no"] & & exit 0nginx = "/ usr/local/nginx/sbin/nginx" prog=$ (basename $nginx) NGINX_CONF_FILE= "/ usr/local/nginx/conf/nginx.conf" [- f / etc/sysconfig/nginx] & &. / etc/sysconfig/nginxlockfile=/var/lock/subsys/nginxmake_dirs () {if [- z "`grep $user / etc/ passwd`]; then useradd-M-s / bin/nologin $user fi options= `$ nginx-V 2 > & 1 | grep 'configure arguments:' `for opt in $options; do if [`echo $opt | grep'. *-temp-path' `]; then value= `echo $opt | cut-d" = "- f 2`if [!-d" $value "] Then # echo "creating" $value mkdir-p $value & & chown-R $user $value fi fi done} start () {[- x $nginx] | | exit 5 [- f $NGINX_CONF_FILE] | | exit 6 make_dirs echo-n $"Starting $prog:" daemon $nginx-c $NGINX_CONF_FILE retval=$? Echo [$retval-eq 0] & & touch $lockfile return $retval} stop () {echo-n $"Stopping $prog:" $nginx-s stop retval=$? Echo [$retval-eq 0] & & rm-f $lockfile return $retval} restart () {configtest | | return $? Stop sleep 3 start} reload () {configtest | | return $? Echo-n $"Reloading $prog:" $nginx-s reload RETVAL=$? Echo} force_reload () {restart} configtest () {$nginx-t-c $NGINX_CONF_FILE} rh_status () {status $prog} rh_status_q () {rh_status > / dev/null 2 > & 1} case "$1" in start) rh_status_q & & exit 0 stop) rh_status_q | | exit 0 $1;; restart | configtest) $1; reload) rh_status_q | | exit 7 $1 | Force-reload) force_reload;; status) rh_status;; condrestart | try-restart) rh_status_q | | exit 0;; *) echo $"Usage: $0 {start | stop | status | restart | condrestart | try-restart | reload | configtest}" exit 2esac adds Nginx for system service startup

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report