Linux下安装php

Linux下安装配置php

工具

php版本:php-5.5.35.tar.gz
在这里插入图片描述

解压移动当前文件至创建好的/usr/local/php文件夹下
tar -xf php-5.5.35.tar.gz
mv php-5.5.35 /usr/local/php/

在这里插入图片描述

配置
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
如果出现报错configure: error: xml2-config not found. Please check your libxml2 installation.;需要安装libxml2依赖包
yum search libxml2

在这里插入图片描述

安装
yum install libxml2.x86_64
yum install libxml2-devel.x86_64
再次执行
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
报错:configure: error: Please reinstall the BZip2 distribution,需要安装BZip2依赖包

yum search BZip2

在这里插入图片描述

安装
yum install bzip2-devel.x86_64
yum install bzip2.x86_64

再次执行
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath

报错: configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/,需要安装curl依赖包

安装
yum search curl
yum install libcurl-devel.x86_64

再次执行
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath

报错:configure: error: jpeglib.h not found,需要安装jpeglib依赖

安装:
yum search libjpeg
yum install libjpeg-turbo-devel.x86_64

再次执行
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath

报错:configure: error: png.h not found.需要安装png.依赖

安装:
yum search png
yum install libpng-devel.x86_64

再次执行
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath

报错:configure: error: freetype-config not found.需要安装freetype依赖

安装:
yum search freetype
yum install freetype-devel.x86_64

配置完成

在这里插入图片描述

编译
make && make install

复制:
cp php.ini-production /usr/local/php/etc/php.ini
cd /usr/local/php/etc/
cp php-fpm.conf.default php-fpm.conf

可选修改php.ini参数:(zabbix环境需要修改的参数)
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
date.timezone = PRC

启动
/usr/local/phh/sbin/php-fpm
在这里可以修改vim .bash_profile,把php启动路径放进去为后期启动更加方便。

后续 安装zabbix时报错:PHP ldap Warning
需要安装ldap
/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212路径下面未发现ldap.so,需要重新安装编译

在这里插入图片描述

进入模块所在的源码位置/usr/local/php/php-5.5.35/ext/ldap
编译PHP扩展的工具,主要是根据系统信息生成对应的configure文件

在这里插入图片描述

此时出现Cannot find autoconf报错,需要安装autoconf依赖包
yum search autoconf
yum install yum install autoconf-archive.noarch

在这里插入图片描述

再次执行/usr/local/php/bin/phpize
在这里插入图片描述

配置./configure --with-php-config=/usr/local/php/bin/php-config --with-ldap
需要安装openldap依赖
yum install openldap*

在这里插入图片描述

编译安装make && make install

在这里插入图片描述
在这里插入图片描述

修改配置文件:vim /usr/local/php/etc/php.ini
找到 ;extension=ldap 的行 把注销去掉 , 5版本的php添加extension=ldap.so
保存退出重新启动项目即可

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值