php 源码安装

1)、php 编译安装:(在安装 php 之前需要安装 mysql)
# cd /usr/local/src
# wget  http://cn2.php.net/distributions/php-5.6.17.tar.bz2
# tar jxf php-5.6.17.tar.bz2
# cd php-5.6.17
# wget  www.lishiming.net/data/attachment/forum/ epel-release-6-8_64.noarch.rpm 
# rpm -ivh  epel-release-6-8_64.noarch.rpm 
# yum -y install gcc* openssl*  libjpeg* bzip2* libtool-ltdl-devel libcurl-devel  libpng*  gd*  flex*  libssl*  libxpm*  gmp*  freetype*  pspell*  ncurses* libmcrypt* mhash* mcrypt*
# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm  --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-sockets --enable-exif --disable-ipv6 --with-pear --with-curl --with-openssl

# make
如果已经安装过php ,最好删除 /usr/local/php  # rm -rf /usr/local/php/*
# make install

创建用户:
# useradd -s /sbin/nologin php-fpm

修改配置文件:
# cp php.ini-production /usr/local/php/etc/php.ini
# vim /usr/local/php/etc/php-fpm.conf

[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log

[www]
listen = /tmp/php-fcgi.sock
user = php-fpm
group = php-fpm
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024

# /usr/local/php/sbin/php-fpm -t

启动:
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod 755 /etc/init.d/php-fpm
# service php-fpm start
# chkconfig php-fpm on
# ps aux | grep php-fpm  (大概有20多个进程)

你可能感兴趣的:(PHP,源码安装)