CentOS PHP5.6源码安装

php 专栏收录该内容
0 篇文章 0 订阅

安装编译环境

yum install gcc-c++

新建安装目录

mkdir -p /usr/local/php5.6 && cd /usr/local/php5.6

下载源码

wget http://cn2.php.net/get/php-5.6.40.tar.bz2/from/this/mirror

解压

tar zxvf php-5.6.40.tar.gz 

移动

cd /usr/local/php5.6/php-5.6.40/ && mv * .. && cd .. && rm -rf /usr/local/php5.6/php-5.6.40/

配置

./configure  --prefix=/usr/local/php --enable-fpm --with-fpm-user=daemon --with-fpm-group=daemon --with-config-file-path=/usr/local/php/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-gd --with-zlib --with-libxml-dir --with-curl --with-curlwrappers --with-mhash --with-xmlrpc --with-openssl --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-gd-native-ttf --enable-ftp --enable-pcntl --enable-sockets --enable-zip --enable-soap --disable-debug --disable-ipv6

安装

make -j 4
make install

php虚拟机运行配置文件

find . -name php.ini\*
# 移动php文件运行配置到之前配置好的配置目录
cp -rf php.ini-production /usr/local/php/etc/

find . -name php-fpm\*
# 移动php虚拟机运行配置到之前配置好的配置目录
cp -rf ./sapi/fpm/php-fpm.conf /usr/local/php/etc/

配置systemV控制脚本

find . -name init\*
cp -rf ./sapi/fpm/init.d.php-fpm /etc/init.d/
cd /etc/init.d/
mv init.d.php-fpm php-fpm
chmod a+x /etc/init.d/php-fpm 

配置php.ini

cd /usr/local/php/
cd etc/
mv php.ini-production php.ini

配置 php-fpm.conf

vim php-fpm.conf
#用户组
listen.owner = daemon
listen.group = daemon
listen.mode = 0660

#修改监听soket
listen = /dev/shm/php.socket

启动

/etc/init.d/php-fpm start

安装可能出现的错误依赖记录

错误一

checking for xml2-config path... 
configure: error: xml2-config not found. Please check your libxml2 installation.
# yum list libxml2*

yum install libxml2-devel.x86_64 libxml2-static.x86_64

错误二

checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
    easy.h should be in <curl-dir>/include/curl/
yum install curl curl-devel

错误三

checking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-vpx-dir=<DIR>
configure: error: jpeglib.h not found.
yum install libjpeg-turbo.x86_64 libjpeg-turbo-devel.x86_64 libjpeg-turbo-static.x86_64

错误四

If configure fails try --with-vpx-dir=<DIR>
checking for jpeg_read_header in -ljpeg... yes
configure: error: png.h not found.
yum install libpng-devel.x86_64 libpng-static.x86_64

错误五

checking for jpeg_read_header in -ljpeg... yes
checking for png_write_image in -lpng... yes
If configure fails try --with-xpm-dir=<DIR>
configure: error: freetype-config not found.
yum install freetype-devel.x86_64
  • 0
    点赞
  • 0
    评论
  • 2
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

tar zxvf php-5.6.37.tar.gz cd php-5.6.37 #添加组 groupadd www #添加php-fpm用户 useradd -c php-fpm-user -g www -M www # c和c++编译器 yum -y install -y gcc gcc-c++ # PHP扩展依赖 yum install -y libxml2-devel openssl-devel libcurl-devel libjpeg-devel libpng-devel libicu-devel openldap-devel ./configure --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --enable-fpm\ --with-fpm-user=www\ --with-fpm-group=www\ --enable-mysqlnd\ --with-mysql=mysqlnd\ --with-mysqli=mysqlnd\ --with-pdo-mysql=mysqlnd\ --enable-opcache\ --enable-pcntl\ --enable-mbstring\ --enable-soap\ --enable-zip\ --enable-calendar\ --enable-bcmath\ --enable-exif\ --enable-ftp\ --enable-intl\ --with-openssl\ --with-zlib\ --with-curl\ --with-gd\ --with-zlib-dir=/usr/lib\ --with-png-dir=/usr/lib\ --with-jpeg-dir=/usr/lib\ --with-gettext\ --with-mhash\ --with-ldap make && make install cp php.ini-production /usr/local/php/etc/php.ini cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm # 设置php-fpm开机自动启动 chmod +x /etc/init.d/php-fpm chkconfig php-fpm on cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf service php-fpm start 设置php为全局命令: 修改/etc/profile文件使其永久性生效,并对所有系统用户生效, 在文件末尾加上如下两行代码: PATH=$PATH:/usr/local/php/bin //php命令路径 如果还要同时加入mysql 则第一句: PATH=$PATH:/usr/local/php/bin:/usr/local/mysql/bin //路径一定要正确 执行 命令source /etc/profile 使用php -V确认 【查看php-fpm端口】 vim /usr/local/php/etc/php-fpm.conf listen = 127.0.0.1:9000
相关推荐
©️2020 CSDN 皮肤主题: Age of Ai 设计师:meimeiellie 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值