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

相关推荐

  • 800 多个 Kubectl 常用命令,再也不怕不会用 Kubernetes!

    这个存储库包含脚本 gener_ aliases.py 可以生成数百个方便的 kubectl shell 别名,您不再需要拼写出每个命令和–flag 参数。 通过命令/标志排列创建的 shell 别名示例如下: 示例 800 个别名,下面列出一部分: 访问下面地址,查看所有别名: 安装 您可以直接下载 bash/zsh 的文件…

    2023年7月26日
    1.3K00
  • linux查看某个文件夹的大小(ls命令、du命令详解)

    ls 命令:列出当前工作目录下的所有文件/文件夹的名称 使用ls -l,会显示成字节大小,ls- lh会以KB、MB等为单位进行显示更加直观。 du 命令:查看当前目录和子目录文件夹/文件大小情况 du = disk usage 磁盘使用率,输出每个文件或者目录总大小,其用法如下: du -sh:查看当前目录总大小。 du -sh *:查看当前目录所有子目录…

    2024年5月13日
    1.8K00
  • Linux——手把手教你解决sudo指令无法使用的问题

    解决sudo指令无法使用的问题 1. 为什么不能使用 sudo指令能够使某一条指令拥有root权限,即以root权限去执行 例如 sudo ls -l 但是,如果是新创建的普通账户,一般来说一开始是不能执行sudo命令的: 根据提示,LQF这一用户并不在sudoers这个文件中,因此没有使用sudo的权利suduers文件位于路径/etc/sudoerssu…

    2024年5月31日
    1.6K00
  • rsync+sersync实现实时监控备份同步

    rsync+sersync简介 sersync是基于inotify开发的,类似于inotify-tools的工具。所以同样内核需先支持inotify,才能搭建。 sersync可以记录下被监听目录中发生变化的(包括增加、删除、修改)具体某一个文件或者某一个目录的名字,然后使用rsync同步的时候,只同步发生变化的文件或者目录。 搭建环境:2台Linux(ce…

    2023年3月29日
    1.5K00
  • Centos如何通过Nexus代理yum源

    一 背景 公司的某些服务器不允许连接外网,造成这些服务器需要安装软件时非常不方便,此文章则是介绍如何通过Nexus3.x代理yum源,做到通过yum install来安装软件。 二 创建yum代理仓库 三 服务器上增加yum源 四 Yum安装软件

    2023年5月15日
    2.0K00

发表回复

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

在线咨询: QQ交谈

邮件:712342017@qq.com

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

关注微信