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

相关推荐

  • Linux/windows禁止ping和取消禁止ping的方法

    LINUX: Linux默认是允许Ping响应的,系统是否允许Ping由内核参数决定。 具体的配置方法如下: 内核参数设置 1、允许PING设置 1)临时允许PING操作的命令为: #echo 0 >/proc/sys/net/ipv4/icmp_echo_ignore_all 2)永久允许PING配置方法 /etc/sysctl.conf中增加一行 …

    2022年6月13日
    2.9K00
  • 二进制部署Mysql8.0.31

    二进制部署Mysql8.0.31 一、软件包下载 企业版:Enterprise , 互联网行业一般不选择. 社区版本:选择 源码包 编译安装: source code .tar.gz 通用二进制 公司用什么版本数据库? 具体什么小版本号? 5.6.20 5.6.34 5.6.36 5.6.38 5.6.40 5.7.18 5.7.20 5.7.22 5.7.…

    2023年1月20日
    1.1K00
  • Centos7.9下宝塔部署点可云进销存系统

    1、宝塔安装 见Centos7.6下宝塔安装及资产管理系统部署 2、安装环境 3、源码获取 4、系统部署 1、上传文件并解压 2、创建站点指向子目录 3、配置伪静态 4、配置数据库信息 直接输入 http://www.你的网址.com/install/ 然后输入你的数据库信息 至此 安装完成,默认账户密码:admin / admin888

    2023年2月14日
    1.6K00
  • Nginx优化与防盗链技术

      在当今互联网时代,网站的性能和安全性变得尤为重要。Nginx作为一种高性能的HTTP和反向代理服务器,因其轻量级、高效能和灵活性而被广泛应用于各类网站和应用中。然而,随着互联网流量的不断增长和网络袭击的日益猖獗,如何优化Nginx服务并有效防止盗链成为了每个网站管理员必须面对的重要课题。   Nginx的优化不仅仅是为了提升网站的响应…

    2024年6月27日
    1.8K00
  • CentOS 添加(永久)静态路由的方法总结

    一、使用 route 命令加入临时路由,重启后将失效 route 命令参数: 二、在 Linux 中添加永久路由的方法 1. 默认网关 (1)写入 ifcfg 文件(推荐) vi /etc/sysconfig/network-scripts/ifcfg-eth0 在配置 ip 地址的时候直接将 GATEWAY 的配置写入 ifcfg 文件。形式:GATEWA…

    2023年9月5日
    1.1K00

发表回复

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

在线咨询: QQ交谈

邮件:712342017@qq.com

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

关注微信