centos7下编译安装php7.3

1、下载php7.3的源码php

https://www.php.net/downloads.php

下载php-7.3.4.tar.gzmysql

 

2、安装gcc,gcc-c++,kernel-develc++

yum -y install gcc gcc-c++ kernel-devel

  

3、安装php须要的依赖库sql

yum -y install wget pcre pcre-devel openssl openssl-devel libicu-devel autoconf libjpeg libjpeg-devel \ 
libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel \ 
glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap \ 
openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel \ 
gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline \ 
readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel

 

4、建立用户和组,并解压bootstrap

groupadd www
useradd -g www www
tar xf php-7.3.4.tar.gz
cd php-7.3.4

  

5、进行编译安装api

php的路径 --prefix 和配置文件 --with-config-file-path 路径你们能够自行设置php7

./configure --prefix=/data/nmp/php \
--with-config-file-path=/data/nmp/php/etc \
--with-fpm-user=www \
--with-fpm-group=www \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir \
--with-ldap=shared \
--with-gdbm \
--with-pear \
--with-gettext \
--with-curl \
--with-xmlrpc \
--with-openssl \
--with-mhash \
--with-gd \
--enable-fpm \
--enable-mysqlnd \
--enable-mysqlnd-compression-support \
--enable-xml \
--enable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-intl \
--enable-ftp \
--enable-gd-jis-conv \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-soap \
--enable-fileinfo \
--enable-opcache \
--enable-maintainer-zts \

编译安装curl

make -j 4 && make install

  

上面的步骤有可能出现的问题:socket

一、configure: WARNING: unrecognized options: --with-mcrypt, --with-libmbfl, --enable-gd-native-ttfphp-fpm

说明上面的配置参数已经弃用了,删除便可。

二、configure: error: DBA: Could not find necessary header file(s).

安装下 yum install gdbm-devel

三、configure: error: Cannot find ldap libraries in /usr/lib

拷贝下文件 cp -frp /usr/lib64/libldap* /usr/lib/

四、configure: error: off_t undefined; check your library configuration

进行以下操做:

vi /etc/ld.so.conf
# 添加以下几行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
# 保存退出
:wq
# 使之生效
ldconfig -v

五、configure: error: Please reinstall the libzip distribution

在 https://libzip.org/download/ 下载源码,进行安装

tar xf libzip-1.5.2.tar.gz
cd libzip-1.5.2
mkdir build && cd build && cmake .. && make && make install

六、CMake 3.0.2 or higher is required. You are running version 2.8.12.2

说明你的cmake版本太低,须要从新安装

先删除原有cmake

yum remove cmake

在 https://cmake.org/download/ 下载源码

tar xf cmake-3.14.3.tar.gz
cd cmake-3.14.3
./bootstrap && make && make install

而后修改 vi /etc/profile,并加入以下内容

PATH=/usr/local/bin:$PATH
export PATH
source /etc/profile

  

6、配置php.ini文件

具体的路径,你们可自行修改。

cp php.ini-development /data/nmp/php/etc/php.ini
cp /data/nmp/php/etc/php-fpm.conf.default /data/nmp/php/etc/php-fpm.conf
cp /data/nmp/php/etc/php-fpm.d/www.conf.default /data/nmp/php/etc/php-fpm.d/www.conf

配置php.ini文件

max_execution_time = 120
max_input_time = 120
memory_limit = 1024M
post_max_size = 128M
date.timezone = PRC
extension_dir = "/data/nmp/php/lib/php/extensions/no-debug-zts-20180731"

  

7、配置Systemd服务

其实php-fpm.service文件php已经帮咱们配置好了,只须要咱们复制到指定位置,并启用就好了。

cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/

php-fpm.service文件内容以下:

[Unit]
Description=The PHP FastCGI Process Manager
After=network.target

[Service]
Type=simple
PIDFile=/data/nmp/php/var/run/php-fpm.pid
ExecStart=/data/nmp/php/sbin/php-fpm --nodaemonize --fpm-config /data/nmp/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

启用php-fpm.service

systemctl enable php-fpm.service

启动php-fpm

systemctl start php-fpm.service
相关文章
相关标签/搜索