CentOS 编译安装PHP 7.31详细教程

安装依赖包

yum install -y gcc gcc-c++  make zlib zlib-devel pcre pcre-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp gmp-devel expat-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel libcurl libcurl-devel curl curl-devel libmcrypt libmcrypt-devel libxslt libxslt-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmemcached-devel libzip readline readline-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers

下载

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

解压

tar -xzvf php-7.3.1.tar.gz
cd php-7.3.1

配置

./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --enable-inline-optimization --disable-debug --enable-fpm --with-fpm-user=www --with-fpm-group=www --disable-rpath --enable-soap --with-libxml-dir --with-xmlrpc --with-openssl  --with-mhash --with-pcre-regex --with-zlib --enable-bcmath --with-bz2 --enable-calendar --with-curl --enable-exif --with-pcre-dir --enable-ftp --with-gd --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir --with-freetype-dir --enable-gd-jis-conv --with-gettext --with-gmp --with-mhash --enable-mbstring --with-onig --enable-shared --enable-opcache --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-readline --with-iconv --enable-pcntl --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets  --enable-zip --enable-wddx --with-pear

make && make install

WARNING: unrecognized options: --with-mysql, --with-mcrypt
表示不支持模块:–with-mysql, --with-mcrypt,可以删除选项

configure: error: Please reinstall readline - I cannot find readline.h
解决:

yum -y install readline-devel

configure: error: Please reinstall the libzip distribution
解决:

wget https://libzip.org/download/libzip-1.3.2.tar.gz
tar zxvf libzip-1.3.2.tar.gz
cd libzip-1.3.2
./configure
make
make install

configure: error: off_t undefined; check your library configuration
解决:

vim /etc/ld.so.conf.d/local.conf
把这面内容输入到local.conf 文件

/usr/local/lib64             
/usr/local/lib               
/usr/lib                      
/usr/lib64

更新

ldconfig -v

PHP配置

php.ini是php运行核心配置文件
php-fpm.conf是php-fpm进程服务的配置文件

# cp php.ini-production /usr/local/php7/etc/php.ini
# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# chmod +x /etc/init.d/php-fpm

设置开机启动

# chkconfig --add php-fpm
# chkconfig php-fpm on
# service php-fpm start
    Starting php-fpm done
# ps -ef|grep php
发布了65 篇原创文章 · 获赞 88 · 访问量 28万+

猜你喜欢

转载自blog.csdn.net/uisoul/article/details/86631469