Simple optimization When installing Nginx

Source: Internet
Author: User

The following is simple to say when installing nginx (not related to later optimization)

First, compile and install before the optimization

1. Turn off debug mode

After the Nginx source file is decompressed, modify AUTO/CC/GCC this file

#debug

Cflags= "$CFLAGS-G"

Comment out this line, you can also delete!

2. Specify specific CPU model compilation optimizations

--with-cc-opt= '-o3 '

--with-cpu-opt=cpu #有这几种类型 Pentium,pentiumpro,pentium4,athlon OPTERON,AMD64,SPARC32,SPARC64,PPC64, etc.

How to determine:

Cat/proc/cpuinfo |grep "model name"

3. Optimize Nginx performance with Tcmalloc

Download to this station: http://mirror.yongbok.net/nongnu/libunwind/

Tar zxvf libunwind-version.tar.gz

CD libunwind-version

Cflags=-fpic./configure

Make Cflags=-fpic

Make Cflags=-fpic Install

PS: The latest version 1.0 installation may be problematic!!

Install Google-perftools Acceleration--tcmalloc

Can download from this station: http://code.google.com/p/google-perftools/

Tar zxvf gperftools-version.tar.gz

CD gperftools-version

./configure

Make && make install

echo "/usr/local/lib" >/etc/ld.so.conf.d/usr_local_lib.conf

Ldconfig

Recompile installation Nginx

Compile-time plus--with-google_perftools_module this option

./configure--with-google_perftools_module--user=www--group=www--

Prefix=/usr/local/webserver/nginx--with-http_stub_status_module--with-http_ssl_module--with-pcre--lock-path=/ Var/run/nginx.lock--pid-path=/var/run/nginx.pid

Make && make install

Adding a thread directory for Google-erftools

Mkdir/tmp/tcmalloc

chmod 0777/tmp/tcmalloc

Modify the Nginx master configuration file nginx.conf

Add the following statement at the location above the server:

Google_perftools_profiles/tmp/tcmalloc;

Reboot start Nginx and verify running status

Lsof-n | grep tcmalloc

Second, close the unused service

Slightly

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.