Build LNMP Release Ecshop system and pressure measurement to enable Opcache cache or not

Source: Internet
Author: User
Tags access properties bz2 epoll fpm mcrypt sendfile

Installation Environment: centos6.5,nginx1.6.2,php-5.5.18,mysql5.5.38

Install the Epel source before installing the software, you can install Libmcrypt,mhash,mcrypt and other PHP extensions directly with Yum.

Installing Nginx

Resolve dependencies, install the development Pack Group "Development Tools" and "Server Platform development".

#tar –XF nginx-1.6.2

./configure \

--prefix=/usr/local/nginx\

--conf-path=/etc/nginx/nginx.conf \

--error-log-path=/var/log/nginx/error.log \

--http-log-path=/var/log/nginx/access.log \

--pid-path=/var/run/nginx/nginx.pid \

--lock-path=/var/lock/nginx.lock \

--user=nginx \

--group=nginx \

--http-client-body-temp-path=/var/tmp/nginx/client/\

--http-proxy-temp-path=/var/tmp/nginx/proxy/\

--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/\

--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi\

--http-scgi-temp-path=/var/tmp/nginx/scgi\

--with-pcre

#make && make Install

Add Nginx startup script, set boot start, please see previous blog

Installing php-5.5.18

Installing PHP extensions such as MCrypt Libmcrypt Mhash

# yum–y Install MCrypt libmcrypt-devel mhash-devel

650) this.width=650; "Style=" background-image:none; border-right-0px; padding-left:0px; padding-right:0px; border-top-width:0px; border-bottom-width:0px; border-left-width:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/53/C8/ Wkiol1rwhe7wpohlaaexramuvlu007.jpg "width=" 741 "height=" 206 "/>

Installing PHP Graphic Extensions support

# yum install-y libxml2-devel libjpeg-devel libpng-devel freetype-devel openssl-devel libcurl-devel libmcrypt-devel gd-d Evel

#tar –XF php-5.5.18.tar.bz2

#cd php-5.5.18

#./configure--prefix=/usr/local/php55--with-config-file-path=/usr/local/php55/etc--with-mysql=mysqlnd-- With-zlib--enable-xml--disable-rpath--enable-bcmath--enable-shmop--enable-sysvsem--with-curl--enable-fpm--enab Le-opcache--with-mcrypt--with-gd--with-openssl--with-mhash--enable-sockets--with-xmlrpc-enable-zip-- Enable-soap--with-config-file-scan-dir=/etc/php.d--with-bz2--with-curl--with-jpeg-dir--with-png-dir

# Make && make install

# CP Php.ini-production/usr/local/php55/etc/php.ini #为php提供配置文件

#ln –s/usr/local/php55/etc/php.ini/etc/php.ini #为php. ini to create a soft link in the/etc directory

# CP SAPI/FPM/INIT.D.PHP-FPM/ETC/RC.D/INIT.D/PHP-FPM

# chmod +X/ETC/RC.D/INIT.D/PHP-FPM

# chkconfig--add php-fpm

# chkconfig PHP-FPM on #配置php-fpm, provides SYSV init script for PHP-FPM and adds it to the list of services

# cp/usr/local/php55/etc/php-fpm.conf.default/usr/local/php55/etc/php-fpm.conf #为php-FPM Provisioning profile

To edit a php-fpm configuration file:
# vim/usr/local/php55/etc/php-fpm.conf

Configure the relevant options for FPM to the value you need and enable the PID file (the last line below):
Pm.max_children = #设定php子进程最大数为50
Pm.start_servers = 5 #启动php时子进程数为52上
Pm.min_spare_servers = 2 #空闲php子进程最少为2个
Pm.max_spare_servers = 8 #空闲php子进程最大为8个
PID =/usr/local/php/var/run/php-fpm.pid #pid文件路径

These parameters can be adjusted according to the system performance and load conditions, in the production environment these parameters may be much larger than these numbers, you can also set the number of PHP child process is a static value. If you want to set a static value, you need to change PM = static, php-fpm default to dynamic PM = dynamically

# service PHP-FPM Start PHP-FPM

Nginx configuration file setup and integration Nginx and php5.5

Nginx's configuration file core modules are main and events, including standard HTTP modules, optional HTTP modules and mail modules, and support for many third-party modules. Main is used to configure parameters related to error logs, processes, and permissions, and events is used to configure I/O models such as Epoll,kqueue,select or poll. Nginx main configuration file consists of several segments, Main,http, Server,upstrean and location, called Nginx context, support nesting.

Nginx configuration file

 #user nobody;  #定义nginx工作进程的用户, the user Nginx was specified at the time of compiling and installing, comment out worker_processes 1;    #指定工作进程个数 #worker_cup_affinity cpumask;      #用cpu掩码位明确绑定nginx运行在某个cpu上, there is only one CPU for this virtual machine, so comment out Worker_rlimit_nofile 51200;  #nginx进程打开文件数目, can set a large point #error_log logs/error.log; #定义错误日志, the location was specified at compile time, note #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; #pid文件, Location specified at compile time events {
    Use Epoll;  #定义I/O model worker_connections 51200;              #设定每个工作进程所处理的最大连接数. The worker_processes in main determines the maximum number of connections that can be processed by the Nginx}http{include mime.types;   #设定mime类型, the type is defined by the Mime.type file Default_type application/octet-stream;  Sendfile on; #sendfile instruction Specifies whether Nginx calls the Sendfile function (zero copy mode) to output the file, for ordinary applications, must be set to ON, if used for downloading and other applications such as disk IO heavy load applications, can be set to off to balance disk and network I/O processing speed,     Reduce the uptime of the system.   Keepalive_timeout 65;                #连接超时时间 gzip on;    #开启gzip压缩 server {#server表示的是一个虚拟主机 Listen 80;  #监听端口 server_name 10.204.80.75; #虚拟主机名称 can be either IP or domain location/{#通常用于server上下文中, which is used to set the access properties of a URI.            Location can be nested.      root HTML; #定义服务器网站根目录位置 index index.php index.html index.htm;    #定义首页索引文件的名称, index.php is added after the} error_page 502 503 504/50x.html;        #定义错误提示页面 location =/50x.html {root html; } location ~ \.php$ {#定义. php ends with file parsing root HTML;    Fastcgi_pass 127.0.0.1:9000;      #定义解析php程序使用的FastCGI接口 Fastcgi_index index.php;            #定义php程序首页索引文件名称 Fastcgi_param Script_filename/usr/local/nginx/html$fastcgi_script_name;        Include Fastcgi_params; }    }}

As shown above, PHP and Nginx are combined into one piece.

MySQL Configuration

MySQL I enabled the previous blog to build the DRBD high availability MySQL server, the process see http://piao719.blog.51cto.com/287547/1562390

IP address is: 10.204.80.89

Build Ecshop

Upload to/usr/local/nginx/html/ecshop directory

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/53/C9/ Wkiol1rwhe7x3hrmaadpu8ya-8w761.jpg "" 698 "height=" 219 "/>

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M01/53/C9/ Wkiol1rwhfcaprh9aaiwfpcwmag809.jpg "" 719 "height=" 342 "/>

Strict Standards:non-static Method Cls_image::gd_version () should not be called statically in\install\includes\lib_inst aller.php on line 31

Resolution: Find the 31st line in Install/includes/lib_installer.php return Cls_image::gd_version (); and then find the Include/cls_ 678 rows in image.php, the Gd_version () method is found to not declare static statics, so an error occurs. As long as:

Change function gd_version () to static function Gd_version ().

When detecting the environment, it is not supported to support JPEG.

Solution: View found Libjpeg.lib library, GD2 Library also has, all loaded, also all normal. View Ecshop Source code Discovery install/includes/lib_installer.php in line 100th, JPEG is written in jpg, the correct should be:

$jpeg _enabled = ($gd _info[' jpeg support '        = = = True)? $_lang[' Support ': $_lang[' not_support '];

Add 777 permissions to cert, data, images, includes, temp, themes directories

# Cd/usr/local/nginx/html/ecshop

# Chmod-r 777 Themes/temp/includes/data/cert/images/

Check the environment for completion

Configuring the System

First create the Ecshop database on the MySQL server 10.204.80.89, and then add an account to manage the database

Mysql>create database ecshop;

Mysql>grant all on ecshop.* to ' ecsuser ' @ ' 10.204.%.% ' identified by ' ecspass ';

Mysql>flush privileges;

Then follow the prompts to complete all the information

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M02/53/C9/ Wkiol1rwhfgjltaaaaicarabb14663.jpg "" 455 "height=" 557 "/>

Failed to install database, prompting Date.timezone time zone setting.

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/53/C9/ Wkiol1rwhflcpp7baalzy6jqakc417.jpg "" 302 "height=" 504 "/>

Modify the Date.timezone = "Asia/shanghai" time zone inside the/etc/php.ini, or add <?php date_default_timezone_set ("PRC") in the PHP code;?> This sentence can be. Installation Complete

650) this.width=650; "Style=" background-image:none; border-bottom:0px; border-left:0px; margin:0px; padding-left:0px; padding-right:0px; border-top:0px; border-right:0px; padding-top:0px "title=" image "border=" 0 "alt=" image "src=" http://s3.51cto.com/wyfs02/M00/53/CB/ Wkiom1rwg9fzueq-aab1x6mbpim483.jpg "" 396 "height=" 129 "/>

Stress test, this is just a simple test of enabling the Opcache cache and not enabling caching with the AB tool that comes with HTTP.

The test results for the PHP opcache cache are not enabled first:

# ab-n 1000-c http://10.204.80.75/ecshop/index.phpThis is apachebench, Version 2.0.40-dev < $Revision: 1.146 $> Apache-2.0copyright 1996 Adam Twiss, Zeus technology LTD, Http://www.zeustech.net/Copyright 2006 the Apache software Found ation, http://www.apache.org/Benchmarking 10.204.80.75 (Be patient) completed 200 requestscompleted requestscompleted requestscompleted requestscompleted requestscompleted 700 requestscompleted requestscompleted requestscompleted requestsfinished requestsserver software:nginx/1.6.2server Hostna Me:10.204.80.75server port:80document Path:/ecshop/index.phpdocument length:35726 by        Tesconcurrency Level:10time taken for tests:53.620991 Secondscomplete requests:1000failed requests:     0Write errors:0total transferred:36078000 byteshtml transferred:35726000 bytesrequests per second: 18.65 [#/sec] (mean) time per request:536.210 [MS] (mean) Time per request:53.621 [MS] (mean, across all concurrent requests) Transfer rate:657.06 [kbytes/sec] Rece    Ivedconnection times (ms) min MEAN[+/-SD] Median maxconnect:0 250.2 1 3000Processing: 135 513 103.2 544 887waiting:129 499 101.0 531 868total:136 535 271.5 545 3754Perc    Entage of the requests served within a certain time (ms) 50% 545 66% 561 75% 571 80% 577 90% 597 95% 618 98% 645 99% 739 100% 3754 (longest request)

Enable Opcache, add in [Opcache] in the/etc/php.ini file

Zend_extension=/usr/local/php55/lib/php/extensions/no-debug-non-zts-20121212/opcache.so

and turn on the following parameters

Opcache.enable=1

Opcache.enable_cli=1

opcache.memory_consumption=256

Opcache.interned_strings_buffer=16

opcache.max_accelerated_files=5000

Opcache.revalidate_freq=60

Opcache.load_comments=1

The above parameters can be modified according to the actual needs in the production environment.

Restart the PHP-FPM and test again.

Ab-n 1000-c Http://10.204.80.75/ecshop/index.phpThis is apachebench, Version 2.3 < $Revision: 655654 $>copyright 1996 Adam Twiss, Zeus technology LTD, http://www.zeustech.net/Licensed to the Apache software Foundation, Http://www.apac He.org/benchmarking 10.204.80.75 (Be patient) completed requestscompleted 300 requestscompleted requestscompleted requestscompleted requestscompleted requestscompleted 800 requestscompleted requestscompleted requestsfinished requestsserver software:nginx/1.6.2server Hostn Ame:10.204.80.75server port:80document Path:/ecshop/index.phpdocument length:35733 B Ytesconcurrency Level:10time taken for tests:16.035 secondscomplete requests:1000failed requests:0w    Rite errors:0total transferred:36085000 byteshtml transferred:35733000 bytesrequests per second: 62.36 [#/sec] (mean) time per request:160.347 [MS] (mean) time per request:16.035 [MS] (mean, across all concurrent requests) Transfer rate:2197.69 [Kbyte S/SEC] receivedconnection times (ms) min MEAN[+/-SD] Median maxconnect:0 2 1.7 1 10     PROCESSING:66 158 73.7 155 885waiting:53 148 72.9 145 873total:66 160 73.7 157    886Percentage of the requests served within a certain time (ms) 50% 157 66% 168 75% 173 80% 176 90% 186 95% 195 98% 208 99% 739 100% 886 (Longest reque

As you can see, the effect of enabling the Opcache cache is less than 70% of the results that are not enabled, so it is necessary for PHP to turn on opcode.

Build LNMP Release Ecshop system and pressure measurement to enable Opcache cache or not

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.