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

相关推荐

  • 关于磁盘IO的那些事

    关于磁盘IO的那些事 一、背景 需要把生产上一份clickhouse的备份数据到测试环境上,心想也就59G 的大小,应该很快吧,殊不知压缩就搞了3个多小时,于是好奇看下磁盘IO的一些参数,分享给大家学习参考 在分析存储性能之前,需要先了解存储性能定义的三个核心指标:IOPS、Throughput、await 指标 说明 IOPS 每秒进行的IO操作次数 Th…

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

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

    2022年11月24日
    1.3K00
  • ESXI6.7物理机安装之网卡驱动封装

    原因: 下载好ESXI6.7.iso镜像,写入U盘后,提示No Network Adapters,找不到网卡驱动。 解决办法:         需要重新封装ESXI,将对应的网卡驱动嵌入进来 我这里先提供一个封装好的,瑞昱r8168网卡定制版ESXI6.7下载:https://pan.baidu.c…

    2023年1月20日
    1.4K00
  • Linux安装青龙面板 稳定版超级详细

    一.安装docker容器 1.工具安装 复制所有代码然后直接右键粘贴进去 中间过程输入y 回车 yum install docker-io –y 这里输入y 安装成功之后是这个样子 输入以下代码回车 systemctl start docker 复制粘贴下面命令回车 docker ps 如果显示下图 即为成功 二.安装青龙面板 1.安装面板 (想改青龙面板端…

    2022年6月22日
    3.1K00
  • 使用 B VPS 中转 A VPS 流量

    引言 由于某些不可抗力原因, 所处网络环境无法访问 A VPS, 因此 增加 能访问到的 B VPS 来中转流量到 A VPS me –x-> A VPS me <—-> B VPS <—-> A VPS 非内网穿透需求, A VPS 有公网ip, 可被公网直接发现 和使用某些客户端 配合 Cloudflare…

    2024年6月28日
    2.2K00

发表回复

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

在线咨询: QQ交谈

邮件:712342017@qq.com

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

关注微信