一、PHP简介
PHP是一种创建动态交互性站点的强有力的服务器端脚本语言。PHP是目前动态网页开发中使用最为广泛的语言之一。PHP能运行在包括Windows、Linux等在内的绝大多数操作系统环境中
PHP是免费的,并且使用非常广泛。同时,对于像微软ASP这样的竞争者来说,PHP无疑是另一种高效率的选项。
给大家介绍下CentOS 7.9下如何通过编译去安装php-7.4.29,教程为本人亲测。
操作系统:CentOS Linux release 7.9.2009
Libzip:1.2.0
Oniguruma:6.9.7.1
PHP版本:7.4.29
二、安装Libzip
下载地址:https://libzip.org/download/libzip-1.2.0.tar.gz
1)安装依赖包
[root@localhost ~]# yum -y install wget gcc gcc-c++ zlib-devel
2)下载安装包
[root@localhost ~]# wget https://libzip.org/download/libzip-1.2.0.tar.gz
3)解压安装包
[root@localhost ~]# tar xf libzip-1.2.0.tar.gz
4)预编译
[root@localhost ~]# cd libzip-1.2.0/
[root@localhost libzip-1.2.0]# ./configure
5)编译和安装
[root@localhost libzip-1.2.0]# make && make install
6)配置动态库路径
[root@localhost libzip-1.2.0]# vim /etc/ld.so.conf
# 添加以下几行内容
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64
[root@localhost libzip-1.2.0]# ldconfig -v
三、安装oniguruma
下载地址:https://github.com/kkos/oniguruma/releases/download/v6.9.7.1/onig-6.9.7.1.tar.gz
1、安装依赖包
[root@localhost ~]# cd ~ && yum -y install wget gcc gcc-c++
2、下载安装包
[root@localhost ~]# wget --no-check-certificate https://github.com/kkos/oniguruma/releases/download/v6.9.7.1/onig-6.9.7.1.tar.gz -O oniguruma-6.9.7.1.tar.gz
3、解压安装包
[root@localhost ~]# tar xf oniguruma-6.9.7.1.tar.gz
4、预编译
[root@localhost ~]# cd onig-6.9.7
[root@localhost onig-6.9.7]# ./configure --prefix=/usr --libdir=/lib64
5、编译和安装
[root@localhost onig-6.9.7]# make && make install
四、安装PHP
1、下载php-7.4.29软件包
下载地址:https://www.php.net/distributions/php-7.4.29.tar.gz
[root@localhost ~]# wget -c https://www.php.net/distributions/php-7.4.29.tar.gz
2、解压php-7.4.29软件包
[root@localhost ~]# tar xf php-7.4.29.tar.gz
3、进入php目录
[root@localhost ~]# cd php-7.4.29
4、安装epel-release源
[root@localhost php-7.4.29]# yum -y install epel-release
5、安装依赖包
[root@localhost php]# yum -y install sqlite-devel wget gcc gcc-c++ pcre pcre-devel openssl openssl-devel libxml2 libxml2-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel cmake
http://php.net/manual/zh/install.unix.nginx.php(极简安装)
[root@localhost php-7.4.29]#
./configure --prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-mysqlnd-compression-support \
--enable-inline-optimization \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-pdo \
--enable-fpm \
--enable-opcache \
--enable-bcmath \
--enable-calendar \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--enable-ftp \
--enable-gd \
--with-fpm-user=www \
--with-fpm-group=www \
--with-xmlrpc \
--with-openssl \
--with-mhash \
--with-sqlite3 \
--with-iconv \
--with-bz2 \
--with-curl \
--with-cdb \
--with-zlib \
--with-gettext \
--with-gmp \
--with-mhash \
--with-jpeg \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pdo-sqlite \
--with-readline \
--with-xsl
7、编译和安装
[root@localhost php-7.4.29]# make && make install
8、配置php-fpm
[root@localhost php-7.4.29]# cp php.ini-production /etc/php.ini
[root@localhost php-7.4.29]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@localhost php-7.4.29]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
[root@localhost php-7.4.29]# \cp sapi/fpm/php-fpm.service /usr/lib/systemd/system
9、创建配置文件
[root@localhost php-7.4.29]# vim /usr/local/php/etc/php-fpm.d/www.conf
[www]
listen = 0.0.0.0:9000
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 128
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 10000
rlimit_files = 1024
slowlog = log/$pool.log.slow
10、创建www用户,启动php-fpm
[root@localhost php-7.4.29]# useradd -s /sbin/nologin www >/dev/null 2>&1
11、配置开机自启动
[root@localhost php-7.4.29]# sed -i '/ProtectSystem/s/full/false/' /usr/lib/systemd/system/php-fpm.service
[root@localhost php-7.4.29]# systemctl daemon-reload
[root@localhost php-7.4.29]# systemctl enable php-fpm
12、启动php-fpm
[root@localhost php-7.4.29]# systemctl start php-fpm
13、查看php版本信息
[root@localhost php-7.4.29]# ln -sf /usr/local/php/bin/php /usr/bin/
[root@localhost php-7.4.29]# php -v
PHP 7.4.29 (cli) (built: Jul 6 2022 10:26:44) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
# 至此就已经安装好php7.4.29了,希望可以帮助到大家。如需转载请注明出处。
若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!
广东省广州市 电信 1F
写的不错,请测有效