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

相关推荐

  • mysql之两个db实例中有两个表对比

    两个db实例中有两个表对比要确定两个数据库实例中的两个表是否存在差异,你需要比较这两个表的所有数据。这个过程可以通过多种方法实现,以下是几个常见的方法: SQL查询比较如果两个数据库相互可访问(例如,通过数据库链接),你可以编写SQL查询来比较它们的数据。以下是一个简单的例子,演示如何比较两个表的数据: 如果这些查询返回任何行,那么这些行就是两个表之间的差异…

    2024年7月4日
    2.3K00
  • 用户管理命令

    useradd 命令 创建普通用户 指定uid和组 创建用户,禁止登录且不创建家目录 使用 -M -s 参数 userdel命令 删除用户与相关文件 案例 passwd命令 passwd命令修改用户密码和过期时间等,root可以改普通用户,反之不可以 一条命令设置密码,企业常用 echo “密码” | passwd — stdin 用户名 –s…

    2022年6月11日
    1.4K00
  • Centos7安装telnet-server

    如果什么都不显示。说明你没有安装telnet xinetd是新一代的网络守护进程服务程序 注意:因为是由xinetd管理,这里启动的是telnet.socket而不是telnet.service 注意: 默认情况下,PAM模块限制root不能telnet到telnet-server,可使用普通用户登录后su切换 一般不建议直接用root用户远程通过…

    2023年5月29日
    96500
  • Centos在dracut模式下如何修改系统配置文件

    1、进入dracut原因 Centos系统进入dracut的原因有很多比如:系统重要文件丢失系统配置文件配置错误等 2、恢复系统文件 2.1、dracut环境 在dracut上下文中是无法看到Centos系统文件的dracut# 2.2、找到系统盘 Centos默认安装时,系统盘是一个lv设备 如果安装时,手动修改了分区,那么可以根据实际情况找到系统设备比如…

    2023年6月12日
    1.4K00
  • mysql程序结构 【思维导图】

     一条SQL语句的执行过程 连接层 (1)提供连接协议:TCP/IP 、SOCKET (2)提供验证:用户、密码,IP,SOCKET (3)提供专用连接线程:接收用户SQL,返回结果 通过以下语句可以查看到连接线程基本情况 mysql> show processlist;  SQL层 (重点) (1)接收上层传送的SQL语句 (2)…

    2023年2月7日
    1.3K00

发表回复

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

在线咨询: QQ交谈

邮件:712342017@qq.com

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

关注微信