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