Ubuntu部署PHP7.4

系统版本:Ubuntu22.04

PHP版本: 7.4

Mysql版本:8.0

Nginx版本: 最新

1. 更新系统

首先,确保系统包是最新的:

复制代码
sudo apt update && sudo apt upgrade -y

2. 安装 Nginx

Nginx 在默认的 Ubuntu 仓库中,因此安装它很简单:

复制代码
sudo apt install nginx -y

启动并使 Nginx 在启动时自动启动:

复制代码
sudo systemctl start nginx
sudo systemctl enable nginx

3. 安装 MySQL 8.0

列出MySQL的可用版本

复制代码
   apt list -a mysql-server

使用以下命令安装您选择的版本,替换[version]为您从第2步中看到的版本号

复制代码
sudo apt install mysql-server=[version]

使用以下命令安装选择的版本,替换[version]上面看到的版本号:

复制代码
sudo apt install mysql-server=[version]

例如,如果要安装 8.0.28版本,可以使用:

复制代码
sudo apt install mysql-server=8.0.28-0ubuntu4

4. 安装 PHP 7.4

为了安装 PHP 7.4,我们可以使用 ondrej/php PPA:

复制代码
sudo apt install software-properties-common -y
sudo add-apt-repository ppa:ondrej/php
sudo apt update

安装 PHP 7.4 以及与 Nginx 和 MySQL 相关的一些常用扩展:

复制代码
sudo apt install php7.4 php7.4-fpm php7.4-mysql php7.4-cli php7.4-fpm php7.4-json php7.4-common php7.4-mbstring php7.4-zip php7.4-gd php7.4-mysqli -y

启动并使 PHP 7.4 FPM 在启动时自动启动:

复制代码
sudo systemctl start php7.4-fpm
sudo systemctl enable php7.4-fpm

可能遇到的问题

  • 安装mysql时出现

Warning: apt-key should not be used in scripts (called from postinst maintainerscript of the package mysql-apt-config)

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8))

相关推荐
漏刻有时4 小时前
PHP GeoJSON转PNG地图渲染程序开发笔记、源码解读、问题复盘与整改方案
android·笔记·php
always_TT6 小时前
【Python 日志记录:logging 模块入门】
开发语言·python·php
Immortal__y9 小时前
Upload-Labs 关卡防御方式
php
☆凡尘清心☆10 小时前
CentOS Stream 9 专用 LNMP 全自动一键脚本
linux·运维·mysql·nginx·lnmp·centos stream 9
JonLee202011 小时前
适配 Yii 3.0,php-casbin/yii-permission 3.0 正式发布
安全·php·rbac·yii·权限·casbin
QH1392923188013 小时前
# R&S ZNB43 ZNA43 ZNA67矢量网络分析仪
开发语言·网络·php
AnsonNie13 小时前
Ubuntu系统安装裕太微YT6801网卡驱动【笔记】
笔记·ubuntu
xqqxqxxq14 小时前
DML 表数据:插入、删除、修改
笔记·mysql
名字还没想好☜15 小时前
Python concurrent.futures 实战:用 ThreadPoolExecutor 并发处理 + as_completed 收结果
数据库·python·php·并发
xxwl58515 小时前
数据库后端接口测试报告
spring boot·mysql·tomcat