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

相关推荐

  • CDN 加速 – 隐藏真实 IP – 复活 IP

    CDN 一词相信很多朋友都不会陌生,网上也经常会看到相关报道。或许大部分人都知道 CDN 加速可以提升网站的打开速度及用户下载资源的速度,而同时也有不少朋友还不清楚 CDN 是什么?有什么用途?它是如何实现加速的呢?下面为大家整理了一些通俗易懂的知识点。 CDN 是什么 CDN 的全称:CONTENT DELIVERY NETWORK,即 内容分发…

    2023年11月9日
    1.1K00
  • 如何在 Ubuntu 22.04 上启用 BBR?

    由于购买的VPS或者主机数据中心都在国外,经常会发生网络拥堵的情况,我们可以通过启用BBR来优化。 在Ubuntu系统上启用BBR可以提升网络连接速度,优化网络拥堵情况。 BBR代表瓶颈带宽,RTT是拥塞控制系统。 您可以在 Linux 桌面上启用 TCP BBR 以改善整体网上冲浪体验。 默认情况下,Linux 使用 Reno 和 CUBIC 拥塞控制算法…

    2024年3月12日
    2.3K00
  • 系统之眼!Linux系统性能监控工具Glances

    一、Glances介绍 glances是一个基于python语言开发,可以为linux或者UNIX性能提供监视和分析性能数据的功能。glances在用户的终端上显示重要的系统信息,并动态的进行更新,让管理员实时掌握系统资源的使用情况,而动态监控并不会消耗大量的系统资源,比如CPU资源,通常消耗小于2%,glances默认每两秒更新一次数据。同时glances…

    2023年8月15日
    1.6K00
  • Linux 实用工具 Screen —— 再也不怕因为网络连接中断杀死任务了!

    不知道小伙伴们是否遇到过这样的场景: 有时候,我们本地通过 SSH 连接到远程服务器并不是很稳定,经常会断开连接。如果此时我们正在做类似更新系统、DD 系统、远程传输 / 下载文件等需要一定时间的操作,就会非常难受,好不容易传了半天的文件,中断了,又得重新来传一次,还得祈祷这次别传一半断开了。 今天我们介绍的这个工具 ——screen,就是为了来解决上面这些…

    2023年11月9日
    1.4K00
  • 如何处理CentOS Failed to load SELinux policy

    CentOS 7在启动时,卡在进度条界面一直进不去系统,如下图所示: 我们可以通过按键盘的左右方向键,可以看到提示“Failed to load SELinux policy.”,这就是造成系统一直卡住无法正常启动的原因。 原因 是因为没有正确修改系统的selinux的配置,导致系统在启动时报selinux的错误 解决方案 第一步:先重启CentOS7操作系…

    2022年6月15日
    2.1K00

发表回复

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

在线咨询: QQ交谈

邮件:712342017@qq.com

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

关注微信