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

相关推荐

  • PVE8开启vgpu显卡虚拟化(基于Tesla P4)

    Tesla系列显卡真是垃圾佬的福音,很久以上上万的卡,现在几百块就能收到,不仅可以炼丹,还可以玩游戏,甚至可以给PVE用作vgpu,来实现云桌面,云游戏。博主先后买过P40和P4,面对250W功耗的24G显存的P40,显然它更适合炼丹,P4 TDP 75W,1060的性能表现,它的最佳用途其实不是个人桌面的游戏显卡,而是虚拟化云主机使用,而搭配上一台低功耗主…

    2024年2月26日
    3.1K00
  • 数据库迁移报错,提示默认日期不能为‘0000-00-00 00:00:00’

    将服务器的数据同步到本地或备份还原到本地mysql时,出现莫名其妙的报错,可能有以下这些报错:“Data truncated for column ‘字段名‘ at row 1”,集中在时间的默认值。数据源的mysql版本是5.5.30,有些时间字段默认值设置为0000-00-00 00:00:00。目标mysql版本为5.7.17,查资料发现,MySQL …

    2022年12月2日
    2.0K00
  • linux修改limits.conf不生效

    一、修改方法 1.临时方法 为了优化linux性能,可能需要修改这个最大值。临时修改的话ulimit -n 204800就可以了,重启后失效。 2.永久生效方法 (1)、修改/etc/security/limits.conf文件 在文件末尾添加如下内容,然后重启服务器或重新登录即可生效。重启后用查看命令进行查看,如果显示数字等于204800即证明修改成功。如…

    2024年5月14日
    1.6K00
  • 更新Jumpserver版本

    手动更新 下载最新的install包 国内最新离线升级包下载地址:https://community.fit2cloud.com/#/products/jumpserver/downloads 解压更新包 更新 启动 清理磁盘 通过update_jumpserver.sh脚本更新 上传更新脚本 给脚本赋予执行权限 执行脚本并输入版本号

    2024年10月24日
    3.4K00
  • Linux Top 命令指南

    top 命令允许用户监视 Linux 上的进程和系统资源使用情况,它是系统管理员工具箱中最有用的工具之一,并且在每个发行版中都预装了它。与 ps 等其他命令不同,它是交互式的,我们可以浏览进程列表、终止进程,等等。本文中,我们将了解如何使用 top 命令。 Getting started top 命令非常简单,只需要在终端中输入 top 即可。top 指令将…

    2022年12月13日
    1.5K00

发表回复

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

在线咨询: QQ交谈

邮件:712342017@qq.com

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

关注微信