基于centOS 7.6 php7.3.13安装与编译

第一步: 下载源码和解压

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

tar -xzvf php-7.3.13.tar.gz

cd php-7.3.13/

第二步:配置安装所需环境/依赖(PS:PHP最烦的就是依赖问题)

yum install -y gcc gcc-c++ make zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libjpeg-devellibxml2 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

第三步:安装位置配置以及启用拓展

./configure --prefix=/usr/local/php --exec-prefix=/usr/local/php --with-mysqli --with-pdo-mysql bindir=/usr/local/php/bin --sbindir=/usr/local/php/sbin --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 --with-openssl --enable-mbstring --enable-fpm --enable-bcmath --with-curl --with-freetype-dir  --with-gettext --with-iconv-dir --with-kerberos --with-libdir=lib64 --with-libxml-dir --with-mysqli --with-openssl --with-pcre-regex --with-pdo-mysql --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl  --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml 

第四步:安装

make && make install

第五步:配置PHP使用

# 拷贝php配置文件

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

#拷贝php-fpm服务并赋予执行权限

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

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

# 拷贝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

# 配置安装目录(可选)

vi /usr/local/php/etc/php-fpm.conf

# 设置php环境变量

vi /etc/profile.d/php.sh

export PATH=$PATH:/usr/local/php/bin/:/usr/local/php/sbin/

source /etc/profile.d/php.sh

# 设置PHP环境命令快捷方式 php -v

ln -s /usr/local/php/bin/php /usr/bin/php

最后一步

service php-fpm start

# 设置php-fpm开机启动

chkconfig php-fpm on

 

  

 

你可能感兴趣的:(服务器)