linux 源码安装php5.6

系统centos

下载

>wget http://hk1.php.net/get/php-5.6.15.tar.gz/from/this/mirror
>tar -xzf php-5.6.15.tar.gz

安装依赖
>yum -y install libxml2 libxml2-devel
>yum -y install curl curl-devel
>yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel
>yum -y install zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel

>yum -y install libmcrypt libmcrypt-devel mcrypt mhash

这一步如果遇到No package xxx available.a

更新下yum即可

>yum  install epel-release  //扩展包更新包
>yum  update 

>yum clean all

安装mysql 略(详见另一篇文章 linux源码安装mysql)

编译安装开始

>./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-png-dir --with-jpeg-dir --with-freetype-dir --with-zlib-dir  --with-iconv --enable-libxml --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-opcache --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --enable-ctype
>make ZEND_EXTRA_LIBS='-liconv'
报错了make: *** [sapi/cli/php] Error 1
重新执行make
>make (成功)
>make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
Installing PHP CLI binary:        /usr/local/php/bin/
Installing PHP CLI man page:      /usr/local/php/php/man/man1/
Installing PHP FPM binary:        /usr/local/php/sbin/
Installing PHP FPM config:        /usr/local/php/etc/
Installing PHP FPM man page:      /usr/local/php/php/man/man8/
Installing PHP FPM status page:   /usr/local/php/php/php/fpm/
Installing PHP CGI binary:        /usr/local/php/bin/
Installing PHP CGI man page:      /usr/local/php/php/man/man1/
Installing build environment:     /usr/local/php/lib/php/build/
Installing header files:          /usr/local/php/include/php/
Installing helper programs:       /usr/local/php/bin/
  program: phpize
  program: php-config
Installing man pages:             /usr/local/php/php/man/man1/
  page: phpize.1
  page: php-config.1
/root/php-5.6.15/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers:          /usr/local/php/include/php/ext/pdo/


复制配置文件
>cp php.ini-production /usr/local/php/etc/php.ini
>cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
>cp sapi/fpm/php-fpm.conf /usr/local/php/etc/php-fpm.conf
修改启动用户(新建用户,组)
>vi /usr/local/php/etc/php-fpm.conf
约149行
user = 用户名
group = 组名


配置开机启动
>chmod 755 /etc/init.d/php-fpm
>chkconfig --add php-fpm
>chkconfig --level 345 php-fpm on


启动
>/etc/init.d/php-fpm start
Starting php-fpm  done
>/etc/init.d/php-fpm --help查看更多
Usage: ./php-fpm {start|stop|force-quit|restart|reload|status}

你可能感兴趣的:(linux 源码安装php5.6)