CentOS 6.5 Build PHP

Source: Internet
Author: User
Tags curl fpm install php imagemagick mcrypt mkdir zts openldap

Build PHP

CentOS 6.5 64

php:5.5.32

three. Install PHP

Configure local Yum Source first

To install a dependency pack:

Yum-y Install curl-devel mysql-devel libfreetype6-dev freetype-devel libpng libpng-devel openldap openldap-devel bzip2-d Evel Db4-devel postgresql-devel net-snmp-devel libjpeg-devel libpng-devel libxpm-devel gmp-devel pspell-devel Libxslt-devel libc-client-devel openldap-devel libxslt-devel libxml2-devel pcre-devel

To install the required dependencies for PHP:

Tar zxvf libiconv-1.14.tar.gz

CD libiconv-1.14

./configure--prefix=/usr/local

Make && make install

Cd.. /

Tar zxvf libmcrypt-2.5.8.tar.gz

CD libmcrypt-2.5.8/

./configure

Make && make install

/sbin/ldconfig

CD libltdl/

./configure--enable-ltdl-install

Make && make install

Cd.. /.. /

Tar zxvf mhash-0.9.9.9.tar.gz

CD mhash-0.9.9.9/

./configure

Make && make install

Cd.. /

# make symbolic links to shared libraries

Ln-s/usr/local/lib/libmcrypt.la/usr/lib64/libmcrypt.la

Ln-s/usr/local/lib/libmcrypt.so/usr/lib64/libmcrypt.so

Ln-s/usr/local/lib/libmcrypt.so.4/usr/lib64/libmcrypt.so.4

Ln-sf/usr/local/lib/libmcrypt.so.4/usr/lib/libmcrypt.so.4

Ln-s/usr/local/lib/libmcrypt.so.4.4.8/usr/lib64/libmcrypt.so.4.4.8

Ln-s/USR/LOCAL/LIB/LIBMHASH.A/USR/LIB64/LIBMHASH.A

Ln-s/usr/local/lib/libmhash.la/usr/lib64/libmhash.la

Ln-s/usr/local/lib/libmhash.so/usr/lib64/libmhash.so

Ln-s/usr/local/lib/libmhash.so.2/usr/lib64/libmhash.so.2

Ln-s/usr/local/lib/libmhash.so.2.0.1/usr/lib64/libmhash.so.2.0.1

Ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config

Ln-s/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib64/libmysqlclient.so.18

Tar zxvf mcrypt-2.6.8.tar.gz

CD mcrypt-2.6.8/

/sbin/ldconfig

./configure

Make && make install

Cd.. /

Install PHP:

Tar zxvf php-5.5.13.tar.gz

CD php-5.5.13

mkdir/usr/local/php

Mkdir/usr/local/php/etc

Please check your installation directory.

./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc \

--with-mysql=/opt/mysql--with-mysqli=/opt/mysql/bin/mysql_config \

--with-iconv-dir--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir=/usr \

--enable-xml--disable-rpath--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization \

--with-curl--enable-mbregex--enable-fpm--enable-mbstring--with-mcrypt--with-gd \

--with-openssl--with-mhash--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip \

--enable-opcache=no--without-pear--disable-fileinfo

The list is as follows (some of the parameters are not explained):

# Specify the PHP installation directory

--prefix=/usr/local/php

# Specify PHP.ini position

--with-config-file-path=/usr/local/php/etc

# MySQL installation directory, support for MySQL

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

MYSQLI extension technology can not only call MySQL's stored procedures, handle MySQL transactions, but also make access to the database work more stable.

--with-mysqli=/usr/local/mysql/bin/mysql_config

The consolidated APACHE,APXS function is to use the loadmodule instruction in Mod_so to load the specified module to Apache, requiring Apache to open the so module

--with-apxs2=/usr/local/apache/bin/apxs

# option Directive--with-iconv-dir is used to specify the path of the iconv in the system when PHP compiles, otherwise the default path is scanned.

--with-iconv-dir=/usr/local

#注:--disable-fileinfo can be removed if memory is large

Make zend_extra_libs= '-liconv '

Make install

CP Php.ini-development/usr/local/php/etc/php.ini

Cd.. /

Cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf

Vi/usr/local/php/etc/php-fpm.conf

Modify

user = Nobody

Group = Nobody

For

user = www

Group = www

# will; pid = Run/php-fpm.pid before, remove and repair to

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

Start PHP-FPM

/usr/local/php/sbin/php-fpm

Add Nginx and fpm to self-boot

Vi/etc/rc.local

# input

Ulimit-shn 65535

/usr/local/php/sbin/php-fpm

/usr/local/nginx/sbin/nginx

compiling PHP extension Modules memcache, Pdo_mysql, Imagick

Tar zxvf memcache-3.0.8.tgz

CD memcache-3.0.8

/usr/local/php/bin/phpize

./configure--with-php-config=/usr/local/php/bin/php-config

Make && make install

Cd.. /

Tar zxvf pdo_mysql-1.0.2.tgz

CD PDO_MYSQL-1.0.2/

/usr/local/php/bin/phpize

./configure--with-php-config=/usr/local/php/bin/php-config--with-pdo-mysql=/opt/mysql

/usr/include/mysql is the MySQL header file location

Ln-s/usr/include/mysql/*/usr/local/include/

Make && make install

Cd.. /

Tar zxvf ImageMagick.tar.gz

CD imagemagick-6.5.1-2/

./configure

Make && make install

Cd.. /

Tar zxvf imagick-3.2.0rc1.tgz

CD IMAGICK-3.2.0RC1

/usr/local/php/bin/phpize

Export Pkg_config_path=/usr/local/lib/pkgconfig

./configure--with-php-config=/usr/local/php/bin/php-config

Make && make install

Cd.. /

modifying php.ini configuration Files

Vi/usr/local/php/etc/php.ini

#查找; Extension_dir = "/" to be preceded by removing and repairing

Extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/"

#并加入

Extension=memcache.so

Extension=pdo_mysql.so

Extension=imagick.so

Execute the following command to make the configuration file effective immediately:

KILL-USR2 ' Cat/usr/local/php/var/run/php-fpm.pid '

Other (optional):

Optimizing Linux Kernel Parameters

Vi/etc/sysctl.conf

Add the following at the end:

# ADD

Net.ipv4.tcp_max_syn_backlog = 65536

Net.core.netdev_max_backlog = 32768

Net.core.somaxconn = 32768

Net.core.wmem_default = 8388608

Net.core.rmem_default = 8388608

Net.core.rmem_max = 16777216

Net.core.wmem_max = 16777216

Net.ipv4.tcp_timestamps = 0

Net.ipv4.tcp_synack_retries = 2

Net.ipv4.tcp_syn_retries = 2

Net.ipv4.tcp_tw_recycle = 1

#net. Ipv4.tcp_tw_len = 1

Net.ipv4.tcp_tw_reuse = 1

Net.ipv4.tcp_mem = 94500000 915000000 927000000

Net.ipv4.tcp_max_orphans = 3276800

#net. ipv4.tcp_fin_timeout = 30

#net. Ipv4.tcp_keepalive_time = 120

Net.ipv4.ip_local_port_range = 1024 65535

To have the configuration take effect immediately:

/sbin/sysctl-p

Install Opcache (because PHP 5.5 is already integrated Zend Opcache, can replace Eaccelerator)

Tar zxvf zendopcache-7.0.3.tgz

CD zendopcache-7.0.3

/usr/local/php/bin/phpize

./configure--with-php-config=/usr/local/php/bin/php-config

Make && make install

Cd.. /

In php.ini, add the following configuration:

[Opcache]

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

opcache.memory_consumption=128

Opcache.interned_strings_buffer=8

opcache.max_accelerated_files=4000

Opcache.revalidate_freq=60

Opcache.fast_shutdown=1

Opcache.enable_cli=1

# make php.ini configuration file effective immediately

KILL-USR2 ' Cat/usr/local/php/var/run/php-fpm.pid '

Common commands:

#修改完php. INI is performed after:

KILL-USR2 ' Cat/usr/local/php/var/run/php-fpm.pid '

#修改完nginx. conf Post execution

/usr/local/nginx/sbin/nginx-s Reload

#重启mysql服务执行:

Service Mysqld (Start|stop|restart)

Ln-s/usr/local/php/bin/php/usr/bin/php

Link to/usr/bin under

Also follow the steps above to install on the slave.

Please give me more advice.

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.