mod_php73安装,编译安装php7.3.12

安装libmcrypt-devel

yum -y install epel-release

yum update -y

yum -y install gcc gcc-c++ autoconf automake libtool re2c flex bison php-mcrypt libmcrypt libmcrypt-devel openssl openssl-devel libxml2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel zlib-devel mcrypt bzip2-devel libicu-devel systemd-devel mhash postgresql-devel glibc-devel glib2-devel ncurses-devel curl-devel gettext-devel libzip-devel pcre-devel

groupadd web

useradd -M -s /sbin/nologin -g web php

如果用于开发,可以设置php账户可登录,添加密码,如下

PS:      useradd -m -s /bin/bash -g web php

passwd php

Libzip 版本过低

假如编译完成之后报错:

“checking for libzip... configure: error: system libzip must be upgraded to v”

先删除libzip

yum remove libzip -y

wget https://nih.at/libzip/libzip-1.2.0.tar.gz

tar -zxvf libzip-1.2.0.tar.gz

cd libzip-1.2.0

./configure

make && make install

或者

yum install libxml2-devel

报错:

configure: error: off_t undefined; check your library configuration

解决方法:

根据报错信息分析 configure: error: off_t undefined; check your library configuration

未定义的类型 off_t。

off_t 类型是在头文件unistd.h中定义的,在32位系统编译成long int,64位系统则编译成 long long int,我的系统是64位的吧,在进行编译的时候是默认查找64位的动态链接库,但是默认情况下centos的动态链接库配置文件/etc/ld.so.conf里并没有加入搜索路径,这个时候需要将 /usr/local/lib64 /usr/lib64 这些针对64位的库文件路径加进去。

添加搜索路径到配置文件

echo '/usr/local/lib64

/usr/local/lib

/usr/lib

/usr/lib64'>>/etc/ld.so.conf

更新配置

ldconfig -v

cd /usr/local/src/

wget http://cn2.php.net/distributions/php-7.3.12.tar.gz

tar -zxvf php-7.3.12.tar.gz

cd php-7.3.12/

./buildconf --force

./configure \

--prefix=/usr/local/php73 \

--exec-prefix=/usr/local/php73 \

--bindir=/usr/local/php73/bin \

--sbindir=/usr/local/php73/sbin \

--includedir=/usr/local/php73/include \

--libdir=/usr/local/php73/lib/php \

--mandir=/usr/local/php73/php/man \

--with-config-file-path=/usr/local/php73/etc \

--with-mysql-sock=/var/lib/mysql/mysql.sock \

--with-mhash \

--with-openssl \

--with-mysqli=shared,mysqlnd \

--with-pdo-mysql=shared,mysqlnd \

--with-gd \

--with-jpeg-dir \

--with-png-dir \

--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-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-soap \

--without-pear \

--with-gettext \

--enable-session \

--with-curl \

--with-freetype-dir \

--enable-opcache \

--enable-fpm \

--with-fpm-user=php \

--with-fpm-group=web \

--without-gdbm \

--with-pgsql \

--with-libxml-dir \

--with-bz2 \

--with-pcre-dir \

--disable-fileinfo

make && make install

cp php.ini-development /usr/local/php73/etc/php.ini

cp /usr/local/php73/etc/php-fpm.conf.default /usr/local/php73/etc/php-fpm.conf

cp /usr/local/php73/etc/php-fpm.d/www.conf.default /usr/local/php73/etc/php-fpm.d/www.conf

vi /lib/systemd/system/php-fpm.service

[Unit]

Description=The PHP FastCGI Process Manager

After=network.target

[Service]

Type=forking

PIDFile=/run/php-fpm.pid

ExecStart=/usr/local/php73/sbin/php-fpm --daemonize -g /run/php-fpm.pid

ExecReload=/bin/kill -USR2 $MAINPID

ExecStop=/bin/kill -SIGINT $MAINPID

PrivateTmp=true

[Install]

WantedBy=multi-user.target

开机自启动、运行、停止、重新加载、删除开机启动

chmod +x /lib/systemd/system/php-fpmd.service

systemctl enable php-fpm.service

systemctl start php-fpm.service

systemctl stop php-fpm.service

systemctl daemon-reload

systemctl disable php-fpm.service

安装插件

yum -y install ImageMagick-devel

编译imageMagick插件

配置php.ini

vi /usr/local/php-73/etc/php.ini

修改

expose_php = Off

date.timezone=Asia/Shanghai

末尾添加

extension=imagick.so

extension=pdo_mysql.so

extension=redis.so

小tips

php 命令无法使用时在php已经安装的情况下添加php的环境变量 /etc/profile

vi /etc/profile

在文件末尾添加

PATH=$PATH:/usr/local/php73/bin/

然后重启

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值