手动安装php环境_手动编译安装PHP环境

Centos安装PHP版本:5.5.26 旧版本的可能要安装 php-fpm 补丁

如果是全新环境, 需要安装以下依赖组件:

yum -y install gcc automake autoconf libtool make gcc gcc-c++ glibc

yum -y install libmcrypt-devel mhash-devel libxslt-devel \

libjpeg libjpeg-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

php官网下载 php-5.5.26

解压到本地后,进入目录编译安装

编译参数:

./configure --prefix=/data/app/php-5.5.26 --enable-fpm --with-mcrypt \

--enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath \

--enable-inline-optimization --with-bz2 --with-zlib --enable-sockets \

--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \

--with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli \

--with-gd --with-jpeg-dir \

--enable-maintainer-zts \

--with-apxs2=/data/app/apache/bin/apxs ## 添加 Apache 支持

如果要开启 PDO 扩展, 使用下面的编译参数

yum install php-pdo

./configure --prefix=/data/app/php-5.5.26 --enable-fpm --with-mcrypt \

--enable-mbstring --enable-pdo --with-curl --disable-debug --disable-rpath \

--enable-inline-optimization --with-bz2 --with-zlib --enable-sockets \

--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \

--with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli \

--with-gd --with-jpeg-dir \

--enable-maintainer-zts \

--disable-fileinfo

完整编译

./configure --prefix=/data/app/php-5.5.26 --with-curl --with-freetype-dir \

--with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 \

--with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql \

--with-pdo-sqlite --with-pear --with-png-dir --with-jpeg-dir --with-xmlrpc \

--with-xsl --with-zlib --with-bz2 --with-mhash --enable-fpm --enable-bcmath \

--enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex \

--enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap \

--enable-sockets --enable-sysvsem --enable-sysvshm --enable-xml --enable-zip \

--disable-fileinfo

安装

make

make install

报错的话

yum install libxml2-devel bzip2-devel curl-devel验证码成功的一个编译参数

其它完整编译参数,

./configure --prefix=/data/app/php-5.6.36 --with-config-file-path=/data/app/php-5.6.36/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear --with-zlib --enable-pdo --with-pdo-mysql --with-mysql

安装后配置:

cd /data/app/php-5.6.36/etc

cp php-fpm.conf.default php-fpm.conf

cp /data/software/php-5.6.36/php.ini-production /data/app/php-5.6.36/etc/php.ini

cd /tmp

mkdir session

修改 php.ini 配置session 位置路径

session.save_path = "/tmp/session"

启动:

/data/app/php-5.6.36/sbin/php-fpmend

报错libmcrypt 的话, 先yum 安装,

yum install libmcrypt-devel mhash-devel libxslt-devel

yum安装找不到的话, 添加yum源扩展 并且更新

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

yum update //更新yum源

不行的话, 编译安装

使用wget可以通过以下路径下载

wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz

解压

tar -zxvf libmcrypt-2.5.7.tar.gz

进入目录

cd libmcrypt-2.5.7

编译(默认安装到/usr/local/lib/)

--prefix=/usr/local/libmcrypt

执行安装

装完成后修改 php 编译参数 --with-libmcrypt=/usr/lib/libmcrypt

make

make install

所有组件安装好后, 编译安装php

php安装好后,进入目录配置

cd /data/app/php-5.5.26

cp etc/php-fpm.conf.default etc/php-fpm.conf

编辑nginx 配置文件

添加

pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

location ~ .php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

如果网站路径有变动,需要更改下列东西

pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

location ~ .php$ {

root /data/webroot/hahabao/;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

还要注意系统 时间 timezone 的配置是否正确

启动 /php-fpm

/data/app/php-5.5.26/sbin/php-fpm

旧版手动打补丁php-fpm安装(旧版程序已经没有了,大家新版的吧,这里做个展示)

wget http://cn2.php.net/get/php-5.2.17.tar.gz

wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz

tar zvxf php-5.2.17.tar.gz

gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1

cd php-5.2.17

./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-openssl -enable-fpm -enable-mbstring\

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

-with-mhash -with-mcrypt -enable-pcntl -enable-sockets -with-bz2 -with-curl -with-curlwrappers\

-enable-mbregex -with-gd -enable-gd-native-ttf -enable-zip -enable-soap -with-iconv -enable-bcmath\

-enable-shmop -enable-sysvsem -enable-inline-optimization -with-ldap -with-ldap-sasl -enable-pdo\

-with-pdo-mysql

make all install

启动 php-fpm : /usr/local/php/sbin/php-fpm (手动打补丁的启动方式/usr/local/php/sbin/php-fpm start)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值