Linux——PHP8.0编译安装和yum安装

文章目录

Linux------PHP8.0编译安装和yum安装

PHP8.0编译安装

此内容参考于:https://www.cnblogs.com/jhno1/p/14237034.html

安装依赖

shell 复制代码
# 安装编译依赖
[root@csq ~]# yum -y install ncurses ncurses-devel openssl-devel bison gcc gcc-c++ make cmake wget
# 安装php依赖
[root@csq ~]# yum -y install libxml2-devel sqlite-devel bzip2-devel libcurl-devel libpng-devel libjpeg-devel freetype-devel libicu-devel oniguruma-devel libxslt-devel

# 编译安装libzip-devel依赖包,因为yum版本的libzip-devel依赖包版本过低
wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -xvf libzip-1.2.0.tar.gz 
cd libzip-1.2.0/
./configure && make && make install
vim /etc/profile
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH\
source /etc/profile

下载地址:https://www.php.net/releases/index.php

shell 复制代码
[root@csq ~]# wget https://www.php.net/distributions/php-8.0.0.tar.gz

解压

shell 复制代码
[root@csq ~]# tar -xvf php-8.0.0.tar.gz 
[root@csq ~]# cd php-8.0.0/

编译

shell 复制代码
./configure --prefix=/usr/local/php-8.0.0 --with-config-file-path=/usr/local/php-8.0.0/etc --with-curl --with-freetype --enable-gd --with-jpeg  --with-gettext --with-kerberos --with-libdir=lib64 --with-libxml --with-mysqli --with-openssl --with-pdo-mysql  --with-pdo-sqlite --with-pear --enable-sockets --with-mhash --with-ldap-sasl --with-xsl --with-zlib --with-zip -with-bz2 --with-iconv  --enable-fpm --enable-pdo  --enable-bcmath  --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl  --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-xml --enable-sysvsem --enable-cli --enable-opcache --enable-intl --enable-calendar --enable-static --enable-mysqlnd --disable-fileinfo


make && make install

查看安装版本

shell 复制代码
# 配置环境变量
[root@csq php-8.0.0]#  echo "export PATH=${PATH}:/usr/local/php-8.0.0/bin/" >> /etc/profile
[root@csq php-8.0.0]# source /etc/profile
# 查看安装版本
[root@csq php-8.0.0]#  php --version
PHP 8.0.0 (cli) (built: May  7 2024 18:30:36) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies

配置软连接

shell 复制代码
[root@csq php-8.0.0]# ln -s /usr/local/php-8.0.0/ /usr/local/php

生成各个配置文件

shell 复制代码
# 生成php.ini配置文件
[root@csq php-8.0.0]# cp php.ini-production /usr/local/php/etc/php.ini
# 生成www.conf配置文件
[root@csq php-8.0.0]# cd /usr/local/php/etc/php-fpm.d/
[root@csq php-fpm.d]# cp www.conf.default www.conf
# 生成php-fpm的配置文件
[root@csq php-fpm.d]# cd ..
[root@csq etc]# cp php-fpm.conf.default php-fpm.conf

配置php文件

shell 复制代码
[root@csq etc]# cd php-fpm.d/
[root@csq php-fpm.d]# vim www.conf
# 指定 PHP-FPM 进程的运行用户
user = nginx
# 指定 PHP-FPM 进程的运行用户组
group = nginx
[root@csq php-fpm.d]# vim ../php.ini 
# 通过 POST 方法提交的整个请求的最大大小
post_max_size = 100M
# 指定了允许上传的单个文件的最大大小
upload_max_filesize = 100M

启动php-fpm

shell 复制代码
# 创建启动目录
[root@csq ~]# mkdir /usr/local/php/daemon  
# 生成php-fpm启动文件
[root@csq ~]# cp -rf php-8.0.0/sapi/fpm/init.d.php-fpm /usr/local/php/daemon
# 修改启动文件权限
[root@csq ~]# chmod 740 /usr/local/php/daemon/init.d.php-fpm 
# 配置systemd启动
[root@csq ~]# vim /etc/systemd/system/php-fpm.service
[Unit]
Description=The PHP FastCGI Process Manager
After=syslog.target network.target

[Service]
Type=simple
PIDFile=/run/php-fpm.pid
ExecStart=/usr/local/php/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
ExecStop=/bin/kill -SIGINT $MAINPID

[Install]
WantedBy=multi-user.target
[root@csq ~]# systemctl enable php-fpm.service --now   
[root@csq ~]# netstat -tlnp |grep php
tcp        0    0 127.0.0.1:9000     0.0.0.0:*       LISTEN      28324/php-fpm: mast 

PHP8.0yum安装

shell 复制代码
yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 
yum install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
# 禁用以 "remi-php" 开头的 Yum 软件仓库
[root@csq ~]# yum-config-manager --disable 'remi-php*'
# 启用名为 "remi-php80" 的 Yum 软件仓库
[root@csq ~]# yum-config-manager --enable remi-php80
# 安装php8
[root@csq ~]# yum install -y php
[root@csq ~]# yum install -y php80-php-cli php80-php-common php80-php-devel php80-php-embedded php80-php-fpm php80-php-gd php80-php-mbstring php80-php-mysqlnd php80-php-pdo php80-php-opcache php80-php-xml php80-php-soap
[root@csq ~]# php -v
PHP 8.0.30 (cli) (built: Apr 10 2024 07:34:10) ( NTS gcc x86_64 )
Copyright (c) The PHP Group
Zend Engine v4.0.30, Copyright (c) Zend Technologies
[root@csq ~]# systemctl enable php80-php-fpm.service --now
[root@csq ~]# systemctl status php80-php-fpm.service
● php80-php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php80-php-fpm.service; disabled; vendor preset: disabled)
   Active: active (running) since Tue 2024-05-07 19:14:54 CST; 21s ago
 Main PID: 30420 (php-fpm)
[root@csq ~]# netstat -tlnp |grep php
tcp    0     0 127.0.0.1:9000      0.0.0.0:*       LISTEN      31405/php-fpm: mast 
相关推荐
勤奋的凯尔森同学33 分钟前
webmin配置终端显示样式,模仿UbuntuDesktop终端
linux·运维·服务器·ubuntu·webmin
技术小齐5 小时前
网络运维学习笔记 016网工初级(HCIA-Datacom与CCNA-EI)PPP点对点协议和PPPoE以太网上的点对点协议(此处只讲华为)
运维·网络·学习
ITPUB-微风5 小时前
Service Mesh在爱奇艺的落地实践:架构、运维与扩展
运维·架构·service_mesh
打不了嗝 ᥬ᭄5 小时前
Linux的权限
linux
落幕5 小时前
C语言-进程
linux·运维·服务器
深度Linux5 小时前
C++程序员内功修炼——Linux C/C++编程技术汇总
linux·项目实战·c/c++
chenbin5206 小时前
Jenkins 自动构建Job
运维·jenkins
java 凯6 小时前
Jenkins插件管理切换国内源地址
运维·jenkins
AI服务老曹6 小时前
运用先进的智能算法和优化模型,进行科学合理调度的智慧园区开源了
运维·人工智能·安全·开源·音视频
风静如云7 小时前
OpenBMC:BmcWeb定义service
linux