CentOS7安装php7.3

安装依赖

yum install -y gcc gcc-c++  make zlib zlib-devel pcre pcre-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

下载PHP

wget https://www.php.net/distributions/php-7.3.4.tar.gz

解压

tar -zxvf php-7.3.4.tar.gz
cd php-7.3.4

编译安装

./configure \
--prefix=/usr/local/php73 \
--with-config-file-path=/usr/local/php73/etc \
--enable-fpm \
--enable-mysqlnd \
--enable-mbstring \
--with-gd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir=/usr \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--with-ldap=shared \
--with-gdbm \
--with-pear \
--with-gettext \
--with-curl \
--with-xmlrpc \
--with-openssl \
--with-mhash \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-intl \
--enable-ftp \
--enable-intl \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-soap \
--enable-opcache \
--enable-cli \
--with-sodium \
--disable-fileinfo \
--disable-rpath

安装

make
make install

删除临时文件

make clean
make distclean

配置环境变量:
可以在 /etc/profile文件末尾添加php环境变量

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

#保存后刷新环境变量:
source /etc/profile

#查看环境变量:
echo $PATH

#查看php版本
php -v

配置PHP

cp php.ini-production /usr/local/php73/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

#复制启动脚本
cp sapi/fpm/init.d.php-fpm /etc/init.d/php73-fpm
chmod +x /etc/init.d/php73-fpm

配置php.ini文件

max_execution_time = 300
max_input_time = 300
memory_limit = 1024M
post_max_size = 128M
upload_max_filesize = 2M
date.timezone = Asia/Shanghai
extension_dir = "/usr/local/php73/lib/php/extensions/no-debug-non-zts-20180731/"

开机启动

systemctl enable php73-fpm
systemctl start php73-fpm

php-fpm的启动、停止和重启:

#启动
service php73-fpm start

#停止
service php73-fpm stop

#重启
service php73-fpm restart

错误解决:
php7.3 Please reinstall the libzip distribution

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 -j4 && make install

fatal error: zipconf.h: No such file or directory

find /usr/local -name 'zipconf.h' 
ln -s /usr/local/lib/libzip/include/zipconf.h /usr/local/include

configure: error: off_t undefined; check your library configuration

vim /etc/ld.so.conf

## 添加如下几行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
# 使之生效
ldconfig -v
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

大恩子

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值