linux环境下手工方式安装php 5.5.29,5.x版本通用。 – 21运维
通知: .-...

linux环境下手工方式安装php 5.5.29,5.x版本通用。

linux 21运维 2160浏览 0评论

一,安装php

1,安装前准备下服务器环境。centos下执行

yum -y install gcc automake autoconf libtool make >/dev/null
yum -y install gcc gcc-c++ glibc >/dev/null
yum -y install libmcrypt-devel mhash-devel libxslt-devel \
libjpeg libjpeg-devel libicu-devel libc-client-devel bzip2-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \
zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \
ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \
krb5 krb5-devel libidn libidn-devel openssl openssl-devel



wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz
tar -zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.13.1
./configure --prefix=/usr/local/libiconv
make
make install

2,下载 。这里以php 5.5为例,如要其他版本,请自行到http://php.net/downloads.php 下载。

wget  -O /usr/local/src/php-5.5.29.tar.gz  http://cn2.php.net/distributions/php-5.5.29.tar.gz
tar zxf /usr/local/src/php-5.5.29.tar.gz -C /usr/local/src
cd /usr/local/src/php-5.5.29
 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mcrypt=/usr/include --with-openssl --with-mhash --with-zlib --with-mysql --enable-mysqlnd --with-mysqli --with-pdo-mysql --with-gd --with-iconv --enable-inline-optimization --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache=no --enable-fpm --enable-fastcgi --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --enable-maintainer-zts --enable-intl >/dev/null 2>&1
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-development /usr/local/php/etc/php.ini && cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf && sed -i "s/nobody/nginx/g" /usr/local/php/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm && chmod +x /etc/init.d/php-fpm && chkconfig php-fpm on
echo "export PATH=/usr/local/php/bin:/usr/local/php/sbin:$PATH">> /etc/profile && source /etc/profile
/etc/init.d/php-fpm restart && netstat -tunlp | grep php-fpm


这里要说明的一点是,我这里是以nginx用户来运行的php,请根据自己实际情况来选择运行php的用户。如果nginx没有安装,那么nginx不存在,需要自己先useradd nginx添加nginx用户和组。另外,后续需要什么扩展,自己安装就是了,这里只写了常用的扩展。扩展安装可以参考关于php组件扩展phpize的深入理解
注意
编译过程可能会遇到报错configure: error: Don’t know how to define struct flock on this system, set –enable-opcache=no 解决办法 请点击连接根据实际生成环境来处理。

转载请注明:21运维 » linux环境下手工方式安装php 5.5.29,5.x版本通用。

发表我的评论
取消评论
表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

网友最新评论 (1)

  1. ./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --bindir=/usr/local/php/bin \ --sbindir=/usr/local/php/sbin --includedir=/usr/local/php/include --libdir=/usr/local/php/lib/php \ --mandir=/usr/local/php/php/man --with-config-file-path=/usr/local/php/etc \ --with-mysql-sock=/data/mysql/mysql.sock --with-mcrypt=/usr/include --with-mhash --with-openssl \ --with-zlib --enable-zip --enable-mysqlnd --with-mysqli --with-pdo-mysql \ --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug \ --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem \ --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --enable-pcntl \ --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session \ --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm \ --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --enable-fileinfo \ --with-bz2 --enable-maintainer-zts --with-imap --with-imap-ssl --with-kerberos \
    21运维2017-01-10 16:20 回复