视频地址

原文地址

一.下载/更新php源

  1. 打开下载网址

    https://launchpad.net/~ondrej/+archive/ubuntu/php

  2. 先安装一下这个命令 add-apt-repository

    apt-get install software-properties-common

  3. 添加第三方源:

    add-apt-repository ppa:ondrej/php

  4. 更新本地源

    apt-get update

二.安装php7.4

  1. 安装

    apt-get install php7.4 php7.4-fpm php7.4-mysql php7.4-gd php7.4-mbstring

    选择6. Asia

    选择70. Shanghai

  2. 启动php

    service php7.4-fpm start #启动fpm

  3. 查看进程

    root@7c609eaf61d3:/etc/init.d# ps aux|grep php 
    
    root     11864  0.0  0.0 342724 10104 ?        Ss   07:05   0:00 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
    
    www-data 11865  0.0  0.0 345020  9672 ?        S    07:05   0:00 php-fpm: pool www
    
    www-data 11866  0.0  0.0 345020  9672 ?        S    07:05   0:00 php-fpm: pool www
    
    root     11868  0.0  0.0  11464  1004 pts/1    S+   07:06   0:00 grep --color=auto php
  4. 查看版本

    root@7c609eaf61d3:/etc/init.d# php -v #查看进程
    PHP 7.4.8 (cli) (built: Jul 13 2020 16:45:47) ( NTS )
    Copyright (c) The PHP Group
    Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with Zend OPcache v7.4.8, Copyright (c), by Zend Technologies

安装php主要的就三个

phpcli #命令行

php7.4-fpm #和nginx配合的多进程管理 多数使用这个

module #和apache配合的

  1. 查看监听的端口

    安装net-tools

    可以用altupn命令查看监听的端口

    apt-get install net-tools
    root@7c609eaf61d3:/etc/init.d# netstat -altupn|grep 9000
    root@7c609eaf61d3:/etc/init.d# netstat -altupn|grep 80
    tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 23/nginx: master pr
    tcp 0 0 172.17.0.3:47020 124.200.113.110:80 TIME_WAIT -
    tcp6 0 0 :::80 :::* LISTEN 23/nginx: master pr
     以上可以看到9000端口没有被监听,只监听了80端口

    fpm监听有两种方式

  • a.监听端口,一般为9000端口
  • b.监听socket

三.修改配置

3.1 修改www.conf 文件

vim /etc/php/7.4/fpm/pool.d/www.conf

/listen = #可以找到监听方式 listen = /run/php/php7.4-fpm.sock

说明默认使用sock方式配合nginx方式工作

修改以下几处配置

1.打开在控制台显示php的错误

;php_flag[display_errors] = off 改为 php_flag[display_errors] = on

;php_admin_flag[log_errors] = on 改为 php_admin_flag[log_errors] = on

2.打开日志

;access.log = log/$pool.access.log 改为 access.log = log/$pool.access.log

打开日志后,需要新建日志文件/usr/log/www.access.log,

/var/log/php7.4-fpm.log文件里

mkdir -p /usr/log

vim /usr/log/www.access.log

保存并退出

如果没有这个文件,php会启动不了,不报错,错误日志会写入日志文件,

cat /etc/php/7.4/fpm/php-fpm.conf里可以查到php错误日志会写会

error_log = /var/log/php7.4-fpm.log

四.配置域名

vim /etc/hosts

127.0.0.1 phptest.haimait.hm

五.nginx的配置文件

5.1 sock方式和nginx配合工作

  1. 修改php监听方式

    vim /etc/php/7.4/fpm/pool.d/www.conf

    这里我们使用监听sock的方式配合nginx工作

    listen = /run/php/php7.4-fpm.sock

  2. 重启php

    service php7.4-fpm reload

  3. 修改nginx配置文件

    vim /etc/nginx/conf.d/phptest.haimait.hm.conf

    server {
    listen 80;
    server_name phptest.haimait.hm;
    access_log /var/log/nginx/phptest.haimait.hm.access.log;
    error_log /var/log/nginx/phptest.haimait.hm.error.log;
    root /wwwroot/html/phptest;
    location / {
    index index.php index.html index.htm;
    }
    location ~ \.php$ {
    root /wwwroot/html/phptest;
    #fastcgi_pass这里的路径要的/etc/php/7.4/fpm/pool.d/www.conf 里listen = 里的配置的一致
    fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    #fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #�user root
    #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
    include fastcgi_params;
    }
    }

    保存退出后

  4. 重启nginx

    root@7c609eaf61d3:/etc/nginx/conf.d# service nginx restart
    * Restarting nginx nginx
  5. curl测试

curl http://127.0.0.1/index.php 测试成功

5.2监听9000端口和nginx配合工作(推荐)

  1. 修改php监听方式

    vim /etc/php/7.4/fpm/pool.d/www.conf

    这里我们改为使用监听9000端口的方式配合nginx

    listen = /run/php/php7.4-fpm.sock 改为listen = 127.0.0.1

    重启php

  2. service php7.4-fpm reload

  3. 修改nginx配置文件

    vim /etc/nginx/conf.d/phptest.haimait.hm.conf

server {
listen 80;
server_name phptest.haimait.hm;
access_log /var/log/nginx/phptest.haimait.hm.access.log;
error_log /var/log/nginx/phptest.haimait.hm.error.log;
root /wwwroot/html/phptest;
location / {
index index.php index.html index.htm;
}
location ~ \.php$ {
root /wwwroot/html/phptest;
#fastcgi_pass这里的路径要的/etc/php/7.4/fpm/pool.d/www.conf 里listen = 里的配置的一致
#fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; #�user root
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
}

保存退出后

  1. 重启nginx
root@7c609eaf61d3:/etc/nginx/conf.d# service nginx restart
* Restarting nginx nginx
  1. curl测试

    curl http://127.0.0.1/index.php 测试成功

ubuntu系统下安装php7.4的更多相关文章

  1. ubuntu系统下安装pyspider:搭建pyspider服务器新手教程

    首先感谢“巧克力味腺嘌呤”的博客和Debian 8.1 安装配置 pyspider 爬虫,本人根据他们的教程在ubuntu系统中进行了实际操作,发现有一些不同,也出现了很多错误,因此做此教程,为新手服 ...

  2. CentOS和Ubuntu系统下安装 HttpFS (助推Hue部署搭建)

    不多说,直接上干货! 我的集群机器情况是 bigdatamaster(192.168.80.10).bigdataslave1(192.168.80.11)和bigdataslave2(192.168 ...

  3. Ubuntu系统下安装并配置hive-2.1.0

    说在前面的话 默认情况下,Hive元数据保存在内嵌的Derby数据库中,只能允许一个会话连接,只适合简单的测试.实际生产环境中不使用,为了支持多用户会话, 则需要一个独立的元数据库,使用MySQL作为 ...

  4. ubuntu系统下安装pip3及第三方库的安装

    ubuntu系统下会自带python2.x和python3.x坏境,不需要我们去安装.并且ubuntu系统下还会自动帮助我们安装python2.x坏境下的pip安装工具, 但是没有python3.x坏 ...

  5. ubuntu系统下安装pyspider:安装命令集合。

    本篇内容的前提是你已安装好python 3.5.在ubuntu系统中安装pyspider最大的困难是要依赖组件经常出错,特别是pycurl,但把对应的依赖组件安装好,简单了.下面直接上代码,所有的依赖 ...

  6. CentOS和Ubuntu系统下安装vsftp(助推大数据部署搭建)

    不多说,直接上干货! 同时,声明,我这里安装的vsftp,仅仅只为我的大数据着想,关于网上的复杂安装,那是服务和运维那块.我不多牵扯,也不多赘述. 一.CentOS系统里安装vsftp 第一步:使用y ...

  7. 在 Ubuntu/Debian 下安装 PHP7.3 教程

    介绍 最近的 PHP 7.3.0 已经在 2018 年12月6日 发布 GA,大家已经可以开始第一时间体验新版本了,这里先放出 PHP7.3 安装的教程以便大家升级. 适用系统: Ubuntu 18. ...

  8. Python 基础之在ubuntu系统下安装双版本python

    前言:随着python升级更新,新版本较于老版本功能点也有不同地方,作为一个初学者应该了解旧版本的规则,也要继续学习新版本的知识.为了能更好去学习python,我在ubuntu安装python2和py ...

  9. ubuntu系统下安装gstreamer的ffmpeg支持

    当您在安装gstreamer到您的ubuntu系统中时,为了更好地进行流媒体开发,需要安装ffmpeg支持,但一般情况下,直接使用 sudo apt-get install gstreamer0.10 ...

  10. Ubuntu系统下安装Eclipse

    第一步:查看操作系统位数. 打开终端,输入file /sbin/init 可以看到笔者Ubuntu系统为32位,读者可以使用该命令获取自己机器上的操作系统位数. 这一步是最至关重要的一步,笔者机器处理 ...

随机推荐

  1. UE427-C++实现摄像机视角的移动,类似开镜效果

    教程 方法 调整相机视野和弹簧臂的长度 //自带的tick函数内 需要使用DeltaTime if (bZoomIn) { ZoomFactor += DeltaTime / 0.5f; } else ...

  2. reinterpret_cast 和 static_cast 的区别

    安全性: static_cast 是一个安全的类型转换,它只能转换具有继承关系或密切相关的类型,并且在编译时进行类型检查. reinterpret_cast 是一个不安全的类型转换,它可以将任何类型的 ...

  3. Java开发岗面试题小结

    8种基本数据类型 类型名称 关键字 占用内存 取值范围 字节型 byte 1 字节 -128~127 短整型 short 2 字节 -32768~32767 整型 int 4 字节 -21474836 ...

  4. #线段树,模拟费用流#CF280D k-Maximum Subsequence Sum

    题目 给定一个大小为 \(n\) 的序列,要求支持单点修改和查询区间内至多 \(k\) 个不交子区间之和的最大值(可以不取) 分析 考虑源点向每个点.每个点向汇点流流量1费用0的边,每个点向右边的点流 ...

  5. #dp,矩阵乘法#洛谷 5371 [SNOI2019]纸牌

    题目 一副纸牌有 \(n\) 种,每种有 \(m\) 张, 现在有 \(k\) 个限制条件形如第 \(k_i\) 种牌至少选 \(a_i\) 张, 一个三元组合法当且仅当其为 \((i,i+1,i+2 ...

  6. #扩展域并查集,线段树分治#CF576E Painting Edges

    题目链接 题目翻译 给定一张 \(n\) 个点 \(m\) 条边的无向图. 一共有 \(k\) 种颜色,一开始,每条边都没有颜色. 定义合法状态为仅保留染成 \(k\) 种颜色中的任何一种颜色的边,图 ...

  7. #虚树,树形dp#CF613D Kingdom and its Cities

    洛谷题面 Codeforces 分析 若两个重要城市为一条边的两个顶点显然无解 否则考虑建一棵虚树,设\(dp[x]\)表示以\(x\)为根的子树最少需要摧毁的城市数, 令\(Siz[x]\)表示\( ...

  8. OpenHarmony—应用间HSP开发指导

     应用间HSP用于不同应用间的代码.资源共享. 应用间HSP的宿主应用是一种特殊状态的应用,只能由一个HSP组成,不会独立运行在设备上,而是被普通应用模块的依赖项引用.当普通应用运行时,通过动态调用的 ...

  9. Harbor仓库高可用

    一.搭建两台Harbor 搭建方法参考:https://www.cnblogs.com/hanfuming/p/15750031.html 二.两台新建相同项目 三.第二台harbor上仓库管理中新建 ...

  10. 【转】CentOS安装VMware Tools

    [转]CentOS安装VMware Tools VMware 是非常好的虚拟机软件.如果系统安装了VMware Tools以后对虚拟机的性能会提升很多的.下面是如果在CentOS系统内安装VMware ...