linux 安装php7.3

zhan11400
字数 2519阅读 86

#安装依赖包
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 http://cn2.php.net/get/php-7.3.0.tar.gz/from/this/mirror -o php-7.3.0

#解压

tar -zxvf php-7.3.0.tar.gz #进入源码包目录

cd php-7.3.0

#configure配置

./configure \

--prefix=/usr/local/php \ #PHP路径

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

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

--sbindir=/usr/local/php/sbin \  #php启动路径

--includedir=/usr/local/php/include \ #扩展包

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

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

--with-config-file-path=/usr/local/php/etc \ #php-config路径

--with-openssl \

--enable-mbstring \

--enable-fpm

#编译安装 

make && make install

#把源码包的php.ini-production复制到php安装目录的etc,并且改名

cp php.ini-production /usr/local/php/etc/php.ini

#

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 

chmod +x /etc/init.d/php-fpm

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

cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf  #添加php安装目录到系统环境变量 

vim /etc/profile.d/php.sh 

export PATH=$PATH:/usr/local/php/bin/:/usr/local/php/sbin/  #使用source立即生效刚刚添加的php环境变量

source /etc/profile.d/php.sh 

#service php-fpm start就可以了
#设置开启自启动

chmod +x /etc/init.d/php-fpm

chkconfig --add php-fpm

chkconfig php-fpm on


0条评论
    暂无评论
发表评论