Linux under compile and install PHP

Source: Internet
Author: User
Tags gettext mcrypt pear

System environment:

    • CentOS 6.5 x86_64
Download PHP Source Package
# wget http://cn2.php.net/distributions/php-5.5.9.tar.bz2# Tar xf php-5.5.9.tar.bz2-c/usr/local/src/

Add Epel Source
# RPM-UVH http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Installation dependencies
# yum Install GCC bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel openssl-devel libxml2-devel libcurl-deve L Bzip2-devel readline-devel Libedit-devel

Create WWW user
# groupadd www# useradd-g www-s/sbin/nologin-m www
Compiling the installation
# cd/usr/local/src/php-5.5.9/#/configure--prefix=/usr/local/php--with-config-file-path=/etc-- Enable-inline-optimization--disable-debug--disable-rpath--enable-shared--enable-opcache--enable-fpm-- With-fpm-user=www--with-fpm-group=www--with-mysql=mysqlnd--with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd-- With-gettext--enable-mbstring--with-iconv--with-mcrypt--with-mhash--with-openssl--enable-bcmath--enable-soap-- With-libxml-dir--enable-pcntl--enable-shmop--enable-sysvmsg--enable-sysvsem--enable-sysvshm--enable-sockets-- With-curl--with-zlib--enable-zip--with-bz2--with-readline--without-sqlite3--without-pdo-sqlite--with-pear

Parameter description:

""" 安装路径 """
 --prefix=/usr/local/php "" PHP.ini Profile Path ""--with-config-file-path=/etc "" " Optimization option "" "--enable-inline-optimization--disable-debug--disable-rpath--enable-shared" "" Enable Opcache, default = ZendOptimizer+ (Zendopcache) "" "" "--enable-opcache" "" FPM "" "--ENABLE-FPM--with-fpm-user=www--with-fpm-group=www" "" MySQL ""--with-mysql=mysqlnd --with-mysqli=mysqlnd--with-pdo-mysql=mysqlnd "" "Internationalization with character encoding support" ""--with-gettext--enable-mbstring--with-iconv "" " Encryption extension "" "--with-mcrypt--with-mhash--with-openssl" "" Math Extension "" "--enable-bcmath" "Web Service, soap dependency libxml" ""--enable-soap- -with-libxml-dir "" "process, signal and memory" ""--enable-pcntl--enable-shmop--enable-sysvmsg--enable-sysvsem--enable-sysvshm "" " Sockets & Curl "" "--enable-sockets--with-curl" "" Compress and Archive "" "--with-zlib--enable-zip--with-bz2" "" GNU Readline command line shortcut keys Bind "" "--with-readline" "Disable SQLite Support extension" ""--without-sqlite3--without-pdo-sqlite "" "more PHP extensions and Applications Library" ""--with-pear  

If your Web Server is using Apache please add similar: --with-apxs2=/usr/local/apache/bin/apxs parameters.

See mysqlnd What is PHP's MySQL Native driver? or view MySQL official description: MySQL Native driver for PHP, or installation on Unix.

For more compilation parameters, use ./configure --help view.

# make-j4# make Install

If you want to reinstall:

# make clean# make clean all#/configure ... # make-j4# make install

Configure PHP

configuration file :

# CP Php.ini-development/etc/php.ini

PHP-FPM Service

# cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf# CP SAPI/FPM/INIT.D.PHP-FPM/ETC/INIT.D /php-fpm# chmod +x/etc/init.d/php-fpm

Start PHP-FPM

# service PHP-FPM startstarting php-fpm done  

PHP-FPM Available Parameters Start|stop|force-quit|restart|reload|status

Adding PHP commands to environment variables

Editor ~/.bash_profile , Will:

Path= $PATH: $HOME/bin change to: path= $PATH: $HOME/bin:/usr/local/php/bin

Make the PHP environment variable effective:

# . ~/.bash_profile

See PHP version

# php-vphp 5.5.9 (CLI) (Built:feb  7 15:06:34) Copyright (c) 1997-2014 the PHP groupzend Engine v2.5.0, Copyrigh T (c) 1998-2014 Zend Technologies

 

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.