第一步:下载
第二步:安装
#创建运行用户
shell > mkdir /service/php73
shell > groupadd -r php && useradd -r -g php -s /bin/false -d /service/php73 -M php
shell > groupadd -r nginx && useradd -r -g nginx -s /bin/false -M nginx
#安装所需应用
shell > yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel
#CentOS7 Yum libzip 版本无法达到PHP73所需所以编译安装
shell > wget https://nih.at/libzip/libzip-1.2.0.tar.gz
shell > tar -zxvf libzip-1.2.0.tar.gz
shell > cd libzip-1.2.0
shell > ./configure
shell > make && make install
shell > cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h
#下载PHP安装包
shell > wget https://www.php.net/distributions/php-7.3.5.tar.bz2
shell > tar -jxvf php-7.3.5.tar.bz2
shell > cd php-7.3.5/
#安装和配置
shell > ./buildconf --force
shell > ./configure --prefix=/service/php73 --exec-prefix=/service/php73 --bindir=/service/php73/bin --sbindir=/service/php73/sbin --includedir=/service/php73/include --libdir=/service/php73/lib/php --mandir=/service/php73/php/man --with-config-file-path=/service/php73/etc --with-mysql-sock=/service/SqlData/mysql.sock --with-mhash --with-openssl --with-mysqli=shared,mysqlnd --with-pdo-mysql=shared,mysqlnd --with-gd --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-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --without-gdbm --disable-fileinfo
shell > make && make install
#创建服务,复制php,php-fpm配置等
shell > cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
shell > cp php.ini-production /service/php73/etc/php.ini
shell > cp /service/php73/etc/php-fpm.conf.default /service/php73/etc/php-fpm.conf
shell > cp /service/php73/etc/php-fpm.d/www.conf.default /service/php73/etc/php-fpm.d/www.conf
shell > echo -e '\nexport PATH=/service/php73/bin:/service/php73/sbin:$PATH\n' >> /etc/profile && source /etc/profile
#修改php-fpm为端口通讯,设置php-fpm日志目录,session目录
shell > vim /service/php73/etc/php-fpm.conf
error_log = log/php-fpm.log
shell > vim /service/php73/etc/php-fpm.d/www.conf
# 更改监听模式为端口
listen = 127.0.0.1:9000
# 开启慢日志
slowlog = /var/log/php-fpm/$pool-slow.log
request_slowlog_timeout = 10s
# 设置php的session目录(所属用户和用户组都是nginx)
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
错误介绍
configure: error: off_t undefined; check your library configuration
#在进行编译的时候 是默认查找64位的动态链接库,
#但是默认情况下 centos 的动态链接库配置文件/etc/ld.so.conf里并没有加入搜索路径,
#这个时候需要将 /usr/local/lib64 /usr/lib64 这些针对64位的库文件路径加进去。
shell > echo '/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64'>>/etc/ld.so.conf
shell > ldconfig -v