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

相关推荐

  • Nginx升级版本

    一:宝塔Nginx升级 在宝塔界面点击软件管理->运行环境->Nginx的设置 选择切换版本->选择想要升级的版本,点击切换等待安装成功 二:Linux下升级nginx版本(源码包方式) 方式:使用源码包的方式 老版本:nginx/1.13.0 新版本:nginx/1.22.0 一:下载源码包 wget http://nginx.org/d…

    2022年8月2日
    45300
  • Linux显示磁盘空间不足,/tmp文件夹占用100%问题分析和解决方案

    系统运行过程中发现无法上传文件,第一反应是磁盘空间不足导致,登录服务器后查看文件存放的空间充足,但是无法上传文件且命令行的tab键自动补充也提示空间不足。最后经过搜索和分析发现是/tmp 文件夹占用100%导致。以下记录分析和解决流程。 问题分析         服务器环境        …

    2023年12月22日
    15500
  • 部署linux服务器管理面板–Ajenti

    一、部署Ajenti服务器管理面板 1.Ajenti官网 官网地址:https://ajenti.org/ 2.其他操作系统部署方式 3.部署Ajenti 在本地直接部署署Ajenti,安装成功会有如下提示。 curl https://raw.githubusercontent.com/Eugeny/ajenti/master/scripts/install…

    2023年9月19日
    20000
  • 在 VMware 中安装 Kali Linux 系统的详细过程

    Kali Linux 是用于学习和练习黑客攻击和渗透测试的Linux发行版的不二之选。 而且,如果你经常捣鼓 Linux 发行版,出于好奇心,你可能已经尝试过它。 警告!本文介绍的内容仅供学习 Kali Linux 的安装,请勿使用 Kali Linux 进行任何非授权的行为。Kali Linux 应该用于在授权的情况下,对授权的目标进行合理的渗透测试,以了…

    2022年6月8日
    86800
  • Linux缓冲区的理解

    一、FIFE 可以看到对过程重定向后结果发生了改变,C接口的函数printf,fprintf,fputs都被打印了两次;而系统接口write前后只被打印了一次,为什么呢?肯定和fork有关! fork会创建子进程。在创建子进程的时候,数据会被处理成两份,父子进程发生写时拷贝,我们进行printf调用数据的时候,数据写到显示器外设上,就不属于父进程了,数据没被…

    2023年4月10日
    20900

发表回复

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

在线咨询: QQ交谈

邮件:712342017@qq.com

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

关注微信