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

相关推荐

  • 微信扫码登录的技术实现思考

    简介: 微信扫码登录是很常见的技术,曾经在一次面试当中,面试官就曾问过微信扫码登录的实现思路,这次,以微信读书网页版扫码登录为例子,聊聊我对它技术实现思路一些思考。 微信扫码登录是很常见的技术,曾经在一次面试当中,面试官就曾问过微信扫码登录的实现思路,这次,以微信读书网页版扫码登录为例子,聊聊我对它技术实现思路一些思考。 以谷歌浏览器来做分析,打开F12,准…

    2023年11月10日
    1.2K00
  • 虚拟机中进行raid5测试部署

    raid5需要几块硬盘?答案:至少3块。raid5是独立磁盘冗余阵列(raid)种一种,它是用户数据和数据奇偶校验码轮流存储在所有磁盘阵列种的一种体系架构,根据raid5的工作原理,要实现raid5至少需要3块物理磁盘。 原理:每次存储数据时,数据被平均分配到n-1个磁盘中,随机选中一个磁盘生成校验码。当有一个磁盘坏掉时,还可使用其他磁盘进行热备份故障修复;…

    2022年8月16日
    1.3K00
  • Jenkins常见报错(持续更新)

    1、Jenkins连接Git仓库时候报错Permission denied, please try again. 解决方法(1): jenkins 使用root 用户运行jenkins (因为是使用的是Yum的安装方式,默认启动是以jenkins 用户运行的,但是我们签发的证书是在root 下签发的,所以提示权限拒绝) [root@jenkins .ssh]…

    2023年5月16日
    1.5K00
  • Linux下查找并删除挖矿程序实例

    症状表现 从外网连接服务器时,间接性断开特别频繁。在断开的时候,从内网也连接不上 排查方法 从链路等硬件方面去排查 通过zabbix监控的服务器的端口,发现这个服务器一直在间断性占用1000M带宽,实际客户购买的带宽15M,这就是客户间断性频繁断网的原因。 在排除了线路等相关问题后,将问题锁定在客户系统内。 在软件中排查 在Linux系统中,我们可以使用to…

    2022年6月14日
    1.4K00
  • OpenSuSe15.4以Server模式安装配置网络

    配置静态ip地址 编辑/etc/sysconfig/network/ifcfg-xxx (xxx是网卡设备名),此处是ifcfg-eth0 主要是为了实现静态ip的需求 配置网关 在ifcfg-xxx中配置GATEWAY是无效的,需要编辑/etc/sysconfig/network/routes 主要解决无法访问外网的问题,常见问题: ping 一个公网ip…

    2022年11月23日
    1.4K00

发表回复

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

在线咨询: QQ交谈

邮件:712342017@qq.com

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

关注微信