Smoker-----LNP php C extension (Phalcon)

Source: Internet
Author: User
Tags epoll php script

Features of Nginx:

High-performance static Web server

As a reverse proxy server such as SMTP,HTTPD,TOMCAT,POP3

10,000 concurrent, consumes only 1 m of memory

Based on the Libevent library, the epoll edge triggering mechanism is supported for event.

Asynchronous IO, Memory-mapped

Load balancing, caching

Support SSL,HTTPS,FASTCGI Protocol

Support for non-stop upgrades, log scrolling, configuration updates


Installation method:

Compiling the installation

RPM Installation (Epel)


To compile and install Nginx:

Development environment:

CentOS 6:yum Groupinstall "Development Tools" "Server Platform Development"

CentOS 7:yum Groupinstall "Development Tools"

Dependent packages

Yum install-y pcre-devel Openssl-devel


Get the source bundle: nginx.org

Compile and install:

1. Add Nginx User

Useradd-r-G Nginx

2. Compiling

Tar XF nginx-1.12.1.tar.gz

./configure--with-debug--with-pcre--http-client-body-temp-path=/var/tmp/nginx/client-body-- Http-proxy-temp-path=/var/tmp/nginx/proxy--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi--http-scgi-temp-path=/var /tmp/nginx/scgi--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi--with-http_stub_status_module--with-http_gzip_ Static_module--with-http_ssl_module--with-threads--user=nginx--group=nginx--lock-path=/var/lock/nginx.lock-- Pid-path=/var/run/nginx/nginx.pid--error-log-path=/var/log/nginx/error.log--http-log-path=/var/log/nginx/ Access.log--conf-path=/etc/nginx/nginx.conf--prefix=/usr/local/nginx

Make-j 4 && make install

Install-d/var/tmp/nginx/{client-body,proxy,uwsgi,scgi,fastcgi}


Post-compilation improvements:

1. Environment variables

echo "Export Path=/usr/local/nginx/sbin: $PATH" >/etc/profile.d/nginx.sh

2, the configuration file optimization:

1) Optimize performance-related configurations:

Worker_processes #; The number of worker processes that [main segment] can open is "CPU physical cores-1"

Worker_cpu_affinity Auto; [Main segment] increase cache hit ratio

Worker_priority #; The lower the [main segment] data, the more time it takes to allocate the CPU, and the more it is scheduled to run on the CPU.

2) Event-related configuration:

Accept_mutex On|off; The master process rotates the scheduled request to each worker process in a rotational sequence

Use method; The method of handling user request Prefork:select,poll; Event:epoll

Worker_connections number; The maximum number of concurrent connections that a worker process can receive.

Worker_processes 3; * Worker_connections < 65536

Number of total sockets that the current system can open: 65536


Note After you modify the configuration:

Syntax for detecting configuration files: nginx-t

Overloaded configuration file: Nginx-s Reload


PHP Installation:

PHP executes PHP script code generally through the following 4 steps

1, scanning (lexing)--Convert the PHP code to a language fragment (Tokens)

2. parsing--converts tokens into simple and meaningful expressions

3. compilation--compile the expression into Opocdes

4, execution--sequential execution of opcodes, one at a time, thus realizing the function of PHP script

Phalcon Features: Low overhead

Low memory consumption and CPU compared to traditional framework

MVC & HMVC

Modules, components, models, views, and controllers

Dependency Injection

depend on the injection and location of the service and its own container.

Rest

In this case, you can use either a micro or full stack application to reach your goal. In addition, a powerful set of HTTP helpers.

Auto Load

Provides an automatic loading mechanism that complies with the PSR-4 standard

Router

The Phalcon\mvc\router provides advanced routing capabilities.


Steps to compile and install PHP:

Development environment:

# yum-y Groupinstall "Desktop Platform Development"

Package:

# yum-y Install Bzip2-devel libmcrypt-devel libxml2-devel

Get the source bundle: php.net

Compile and install:

Tar XF php-5.6.31.tar.xz

./configure--prefix=/usr/local/php--with-mysql=mysqlnd--with-pdo-mysql=mysqlnd--with-mysqli=mysqlnd-- With-openssl--enable-fpm--enable-sockets--enable-sysvshm--enable-mbstring--with-freetype-dir--with-jpeg-dir-- With-png-dir--with-zlib-dir--with-libxml-dir=/usr--enable-xml--with-mhash--with-mcrypt--with-config-file-path= /etc--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D--with-bz2--with-curl

Make-j 4 && make install


To compile and install the following configuration:

Configuration file:

# CP Php.ini-production/etc/php5/php.ini

Provide scripts

# cd/usr/local/php

# 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

To provide a configuration file:

# cp/usr/local/php5/etc/php-fpm.conf.default/usr/local/php5/etc/php-fpm.conf

Configure the relevant options for FPM to the value you need and enable the PID file (the last line below):

# vim/usr/local/php5/etc/php-fpm.conf

Pm.max_children = 50

Pm.start_servers = 5

Pm.min_spare_servers = 2

Pm.max_spare_servers = 8

PID =/usr/local/php5/var/run/php-fpm.pid

Test start PHP-FPM

Service PHP-FPM Start


Add Phalcon Module

1, access to Phalcon source code

phalconphp.com/zh/

2. Compiling:

git clone Https://github.com/phalcon/cphalcon

CD Cphalcon/build

sudo./install

3. Add PHP extensions to php.ini:

Extension=phalcon.so

4, restart the PHP-FPM, verify the module:

Php-m

Array (

[0] = + Core

[1] = Libxml

[2] = = Filter

[3] = SPL

[4] = Standard

[5] = Phalcon

[6] = Pdo_mysql

)


This article is from the "Reading" blog, make sure to keep this source http://sonlich.blog.51cto.com/12825953/1950946

Smoker-----LNP php C extension (Phalcon)

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.