Linux下安装PHP

安装准备

  1. 安装PHP所需的系统库,可以扩展php更多功能
[root@localhost ~]# yum install  gcc gcc-c++ make zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel  freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y
  1. 手动安装libiconv-devel(编译三部曲)

默认yum源中缺少libiconv-devel软件包,需要编译安装,用于php的编码转换

[root@localhost tools]# wget -P /tools/  http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
[root@localhost tools]# ls
libiconv-1.15.tar.gz  mysql-5.7.33-linux-glibc2.12-x86_64.tar.gz
[root@localhost tools]# tar zxf libiconv-1.15.tar.gz
[root@localhost tools]# cd libiconv-1.15/
[root@localhost libiconv-1.15]# ./configure --prefix=/opt/libiconv
[root@localhost libiconv-1.15]# make && make install

下载安装

国内镜像地址:http://mirrors.sohu.com/php/

  1. 下载编译文件
[root@localhost ~]# cd /tools
[root@localhost tools]# wget http://mirrors.sohu.com/php/php-7.3.5.tar.gz
  1. 编译安装
  • 配置编译脚本
[root@localhost tools]# wget http://mirrors.sohu.com/php/php-7.3.5.tar.gz
[root@localhost tools]# tar -zxf php-7.3.5.tar.gz
[root@localhost tools]# cd php-7.3.5
[root@localhost php-7.3.5]# ./configure --prefix=/opt/php7.3.5 --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir=/opt/libiconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-fpm --enable-mbstring --with-gd --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --enable-short-tags --enable-static --with-xsl --with-fpm-user=nginx --with-fpm-group=nginx --enable-ftp --enable-opcache=no
  • 看到如下提示,说明编译成功了
creating libtool
appending configuration tag "CXX" to libtool

Generating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using PHP.

config.status: creating php7.spec
  • 进行编译安装
[root@localhost php-7.3.5]# make && make install
  • 配置软连接
[root@localhost php-7.3.5]# ln -s /opt/php7.3.5/ /opt/php

配置PHP

  1. 拷贝php配置文件到php默认目录,且改名
[root@localhost php-7.3.5]# cp php.ini-development /opt/php/lib/php.ini
  1. 配置FastCGI
[root@localhost php-7.3.5]# cd /opt/php/etc/
[root@localhost etc]# pwd
/opt/php/etc
[root@localhost etc]# ls
pear.conf  php-fpm.conf.default  php-fpm.d
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# cp php-fpm.d/www.conf.default php-fpm.d/www.conf
  1. 启动php服务
[root@localhost etc]# /opt/php/sbin/php-fpm
[root@localhost ~]# netstat -tunlp|grep php
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      16818/php-fpm: mast 

文章来源:https://www.cnaaa.net,转载请注明出处:https://www.cnaaa.net/archives/5140

(1)
郭靖的头像郭靖
上一篇 2022年6月25日 下午4:54
下一篇 2022年6月28日 下午6:56

相关推荐

  • 开源网站监控利器:Utime Kuma部署指南

    🔍 Uptime Kuma 简介 GitHub 项目地址:https://github.com/louislam/uptime-kuma 一款开源自托管监控工具,支持多种协议检测(HTTP/TCP/Ping/DNS 等)和实时告警(飞书/钉钉/邮件等) 核心优势: 🚀 部署教程 Docker 部署 验证:访问 http://服务器IP:3001​ 完成初始化…

    2025年6月14日
    1.6K00
  • Ping命令详解

    命令简介 ping 命令是 Linux 系统中一个非常常用的网络命令。ping 命令主要用于测试网络的连通性,也可用于测试网络的性能和主机的响应能力。 日常工作中,我们经常会遇到网页无法打开、网址无法请求的情况。这个时候我们的一般操作是 ping 一下网址,比如 ping baidu.com 使用 …

    2023年1月4日
    1.2K00
  • Linux 实用工具 Screen —— 再也不怕因为网络连接中断杀死任务了!

    不知道小伙伴们是否遇到过这样的场景: 有时候,我们本地通过 SSH 连接到远程服务器并不是很稳定,经常会断开连接。如果此时我们正在做类似更新系统、DD 系统、远程传输 / 下载文件等需要一定时间的操作,就会非常难受,好不容易传了半天的文件,中断了,又得重新来传一次,还得祈祷这次别传一半断开了。 今天我们介绍的这个工具 ——screen,就是为了来解决上面这些…

    2023年11月9日
    1.2K00
  • OpenSuSe系统登录密码忘了如何进行重置

    如果你的OpenSusE系统密码忘记了,又不想重装系统,那么,你可以通过如下几个步骤来强制重置root密码 1、重新启动机器,在出现grub引导界面后,按“e”,出现启动Linux的选项,移动光标至第一个选项上再次按“e”出现一个编辑字符的界面在字符后面加入“init=/bin/bash”字段,然后回车。按Ctrl+X,通过给内核传递init=/bin/ba…

    2022年11月24日
    1.8K00
  • Hollywood – 给你的命令行加点魔法般的动画效果

    作为命令行的重度用户,你是否想让枯燥的终端界面来点生动有趣的元素?Hollywood来了!这是一个无比诙谐、小巧玲珑而又功能强大的动画效果命令行工具。 Hollywood可以为文本添加各种动画效果,让你的输出显示得像电影般生动活泼。它支持多种炫酷动画,并可深度自定义。本文将详细介绍Hollywood的安装使用、酷炫示例和高级技巧,让你快速上手,给终端加点魔力…

    2023年10月13日
    2.1K00

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

在线咨询: QQ交谈

邮件:712342017@qq.com

工作时间:周一至周五,8:30-17:30,节假日休息

关注微信