LNMP Architecture: Linux + Nginx + mysql + PHP, on the static page processing, Nginx beat Apache, the basic can exceed more than one times, for high performance, high concurrency, nginx can be for 100000 concurrency (the actual may be lower), The Nginx IO mechanism uses the Epoll, while Apache uses the select mechanism. Nginx–php-fpm-mysql, replace the previous apache-mod-php-mysql;
Nginx Installation: Use a clean system, uninstall before the Apache, to compile Nginx first to install the compilation software, and then download stable version of the source code,./configure,make, during the Configure process "./configure: Error:the HTTP rewrite module requires the PCRE library. "You can install Pcre,pcre libraries First, which is the basis for implementing regular expressions, and if this library is missing, Nginx cannot support URL rewriting in HTTP. If you do not need this feature, you can do compile configuration script to add "–without-http_rewrite_module", as well as zlib, this note to the official website under the source code compilation, I went wrong in zlib 1.2.3, and the version has been updated to 1.2.8, and the pkgs is actually 1.2.3 ...
Install Nginx in the/usr/local/nginx directory, command file/sbin, configure nginx.conf, and then start./nginx,what, it went wrong: Nginx:error while loading shared Libraries:libpcre.so.1, this is mainly loaded when not found libpcre.so.1, we do a link here, in the/lib directory can be found: libpcre.so.0 libpcre.so.0.0.1, here we will libpcre.so.1 as libpcre.so.0.0.1 link and then execute nginx, you can access the normal.
PHP-FPM Installation: Download the source code of PHP first, work before compiling, install Repoforge yum source, yum clean all,yum list, refresh yum source; uninstall PHP-related programs, yum list | grep PHP, general installation we want to uninstall Yum remove PHP php-devel php-mysql, then install the library file (compile required), yum Install–y libxml2-devel libjpeg-devel Libpng-devel freetype-devel openssl-devel libcurl-devel libmcrypt-devel, install MySQL, and then enter the downloaded PHP, Telnet, in configure time note the parameters, Install path/usr/local/php, view sbin, execute file, about config file, we need a php.ini file that can be obtained from source code php-ini-production, then rename these two files, start php-fpm, All we have to do is configure nginx.conf, add support for PHP-FPM, PHP scripts to FastCGI, cancel the comment, change the/scripts to the address of the root directory of our website/usr/local/nginx/html, It is also important to note that the localtion under the index plus index.php, and Chmod–r 777 html/, and then Killall Nginx, restart Nginx, create index.php, to see if it can run properly.
LNMP Performance Evaluation: Build wordpress, test it (AB), you can find requests per second increased but not very high.
Use Eaccelerator to speed up the LNMP site: Download the extracted eaccelerator source file, and then use/usr/local/php/bin/phpize to create the Configure file (unable to find php-conf The location can be manually specified/usr/local/php/bin/php-config), and then compile the installation, reconfigure the php.ini file, add eaccelerator configuration, Killall nginx,php-fpm, and then restart ; see if the eaccelerator is installed. (Here I use is php5.5.10, but looks like after 5.5 can not use eaccelerator, good sad urge, now PHP-FPM can not start, can only put php.ini in front of eaccelerator comment out).
Optimization php-fpm:php-fpm.conf can modify the port number, you can set Pm.max_children = 5+,pm.start_server=2+, there are other can also be adjusted, and then restart the PHP-FPM. This mainly improves the delay time, requests per second is not much improved.
(2014.3.31)
LNMP, what's the big deal?