Lamp compile and install PHP and XCache

Source: Internet
Author: User
Tags config php mcrypt php and mysql script php zts

Php:

0. Install the relevant extended RPM packages and dependencies

Encryption Features:

#tar-XF libmcrypt-xxx.tar.gz

#cd libmcrypt-xx

#./configure

#make && make Install



Supports large character sets:

#yum-y install php-mbstring supports Chinese and other characters


Supports XML and compression:

#yum-y Install libxml2-devel bzip2-devel


1. Unzip the installation package

#tar XF php.xxx.tar.bz2 php.xxx

#cd php.xxx


2. Compile and install:

Modules compiled as httpd:

#./configure--prefix=/usr/local/phpxx--with-config-file-path=/etc--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D-- With-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--with-apxs2=/usr/local/httpd/bin/ Apxs--with-openssl--enable-mbstring--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib-- with-libxml-dir=/usr/lib64--enable-sockets--with-mcrypt--with-bz2--enable-maintainer-zts

#make

#make Install


Compile to FPM mode:

Replace the--WITH-APXS2=/USR/LOCAL/HTTPD/BIN/APXS with the

--enable-fpm

Delete--enable-maintainer-zts


Common options for compiling:

--prefix=/usr/local/php


--with-config-file-path=/etc Specify a folder for the profile


--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D specifying the configuration folder fragment directory


--with-mysql=/usr/local/mysql


--WITH-OPENSSL support for OpenSSL features


--with-mysqli=/usr/local/mysql/bin/mysql_config another interface for PHP and MySQL interaction, binary program Mysql_config


--enable-mbstring multi-byte string, support Chinese and other multibyte, need to install php-mbstring package.


--with-freetype-dir FreeType font engine, referencing a specific font


--with-jpeg-dir


--with-png-dir


--with-zlib enable zlib Compression library support


--WITH-LIBXML-DIR=/USR/LIB64 enables XML support and specifies the XML library file location, which requires the installation of the Libxml2-devel package.


--enable-sockets to start socket-based communication


--WITH-APXS2=/USR/LOCAL/HTTPD/BIN/APXS uses APSX to compile PHP into a httpd module.


--with-mcrypt enable additional encryption libraries, you need to Libmcrypt-devel


--WITH-CONFIG-FILE-PATH=/ETC Specifies the directory where the PHP master configuration file resides. Configuration file is php.ini


--WITH-CONFIG-FILE-SCAN-DIR=/ETC/PHP.D the configuration fragment location of PHP.


--WITH-BZ2 start the compression library, you need to install the appropriate Bzip2-devel package


--enable-maintainer-zts This is required if httpd is working in a threaded manner. That is, MPM is profork, and you do not need to start the secondary. This support is required for event or worker.



3. Provide configuration files

#cp Php.ini-production/etc/php.ini


4. Edit the httpd configuration file to add support for PHP:

#vim/etc/httpd/httpd.conf

DirectoryIndex index.php index.html

AddType application/x-httpd-php. php

AddType application/x-httpd-php-source. Phps PHP Source support.



5. If PHP is compiled in FPM mode, it needs to be executed:

1. Provide sysv style script for PHP-FPM

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

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


2. Provide configuration files for PHP-FPM

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


3. Modify the configuration file

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

Pm.max_children = 50 Maximum number of child processes

Pm.start_servers = 5 Number of idle processes at service startup

Pm.min_spare_servers = 2 Minimum number of idle processes

Pm.max_spare_servers = 8 Maximum number of idle processes

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

Specifies the PID file location, which is defined in the service script php-fpm, where 2 remains consistent.


Start PHP-FPM

#systemctl Start PHP-FPM


Verify:

#ps-aux|grep PHP-FPM

#netsta-tnlp|grep PHP-FMP


By default, FPM listens on port 9000.


Xcache

1. Unpack the package:

#tar XF xcache.xxx.tar.gz xcache.xxx

#cd xcacahe.xxx


2. Installation:

#/usr/local/php/bin/phpize run phpize in the current directory. Phpize is the program that prepares the PHP extension before compiling it.

#./configure \

--enable-xcache\ Enabling the XCache feature

--with-php-config=/usr/local/php/bin/php-config Php-config is a small script that can get information about PHP configuration and compilation options.


#make && make Install



At the end of the installation, a line similar to the following appears:

Installing Shared extensions:/usr/local/php/lib/php/extensions/no-debug-[non]-zts-20100525/


3. Append the contents of the XCache configuration file sample to the PHP configuration file

#cat Xcache.ini >>/etc/php.ini

Or

#cp xcache.ini/etc/php.d/


It is recommended to use the second method.


4. Modify Xcache.ini

#vim/etc/php.d/xcache.ini

Zend_extension =/usr/local/php/lib/php/extensions/no-debug-zts-xxx/xcache.so


Replace with the path that was generated at the end of the installation.


Zend_extension =/usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so


Note: If you append Xcache.ini to the php.ini file, there are multiple zend_extension lines to ensure that this new row is ranked first.



Note: If PHP is compiled in FPM, you do not need to modify the configuration file to restart the PHP-FPM service directly.



Xcache.ini

[Xcache.common]

Zend_extension =/usr/local/php/lib/php/extensions/no-debug-zts-xxx/xcache.so

...

[Xcache.admin]

...

[XCache]

Xcache.shm_schem= "Mmap" specifies how memory is shared between each PHP process. Mamp is memory-mapped and can be accessed by multiple processes in memory.

xcache.size=60m the size of the cache opcode. Set to 0 to disable this feature.


Xcache.count=1 setting the number of CPUs

xcache.slots=8k slot setting, hash-related

Xcache.ttl=0 the expiration time of the cached item, 0 means never expires and is managed by XCache itself.

Xcache.gc_intrval=0 the garbage collector work cycle. 0 means no scanning, and the other numeric units are seconds.

XCACHE.VAR_SIZE=4M variable Cache

Xcache.var_count=1 Cache Count

xcache_var_slots=8k

Xcache_var_ttl=0

Xcache_var-maxttl=0

xcache.var_gc_intrval=300


Xcache.cather=on XCache Cache function

Xcache.stat=on

Xcache.optimizer=off XCache's own optimizer


Xcache.test=off

Xcache.experimental=off


This article is from "Small Private blog" blog, please be sure to keep this source http://ggvylf.blog.51cto.com/784661/1654513

Lamp compile and install PHP and XCache

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.