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

相关推荐

  • pve 虚拟机关机未成功被锁定,如何解决

    有时我们在回滚快照时,因为某一些错误并不能正确回滚,导致LXC容器被锁定,导致我们无法进入系统,只需要在Proxmox VE下输入解锁命令即可解锁。 例如我有一个LXC容器Ubuntu系统,因为快照回滚失败被锁定,容器加了一个锁并变为rollback状态,此时此容器无法打开。 只需要在Proxmox VE命令行窗口输入解锁命令即可解锁。 如果是虚拟机被锁定则…

    2024年6月17日
    2.6K00
  • OpenSSH_9.3p1 升级到 OpenSSH_9.5p1

    文章声明:此文基于实操撰写 生产环境:此文升级是基于9.3p1升级9.5p1ssh -V查看版本是:OpenSSH_9.3p1, OpenSSL 1.1.1t 7 Feb 2023问题关键字:OpenSSH 升级, OpenSSH 更新, OpenSSH 漏洞修复漏洞信息:OpenSSH 命令注入漏洞(CVE-2020-15778)、OpenSSH 安全漏洞…

    2023年12月13日
    1.9K00
  • cobbler搭建

    什么是cobbler Cobbler是一个Linux系统安装的服务,可以通过网络启动(PXE)的方式来快速安装、重装物理服务器和虚拟机,同时还可以管理DHCP,DNS等。 Cobbler可以使用命令行方式管理,也提供了基于Web的界面管理工具(cobbler-web),还提供了API接口,可以方便二次开发使用。 Cobbler是较早前的kickstart的升…

    2022年11月26日
    1.6K00
  • VMware 虚拟机里连不上网的五种解决方案

    大家好,又见面了,我是你们的朋友全栈君。 在VMware虚拟机里的虚拟机系统连接不上网络 首先,注意查看适配器选项里的网络连接这两个网络连接是否存在,如果不存在可以重新装一下VM 如果存在,连不上网 解决办法一: 虚拟机设置里,找到“网络适配器”,右边的网络连接选择“NAT 模式”,如果不行的话再 linux系统。还是不行的话接着看第二种解决方案。 解决方法…

    2024年6月28日
    4.4K00
  • /etc/security/limits.conf配置文件详解

    /etc/security/limits.conf 是一个用于配置用户或用户组资源限制的配置文件。这个文件通常用于设置系统资源的软限制和硬限制,以及一些特殊权限。 一. limits.conf常见配置项详解 下面是一些 /etc/security/limits.conf 文件中可能包含的常见配置项: 描述 第一列表示用户和组(@开头),这里的 * 代表所有用…

    2024年5月14日
    1.5K00

发表回复

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

在线咨询: QQ交谈

邮件:712342017@qq.com

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

关注微信