ubuntu20.04 搭建 LAMP环境

ubuntu20.04 搭建 LAMP环境

Linux+Apache+Mysql+php+php解释器 简称“LAMP ”

1. 准备工作

利用xshell连接ubuntu 20.04的虚拟机,进入root权限

更新源 (这里报错很可能是源的问题,进入/etc/apt/sources.list切换源)

apt-get update

更新软件

apt-get upgrade

2.安装Apache2

apt install apache2 -y

在浏览器输入虚拟机ip看到以下界面表示安装成功

在这里插入图片描述

3.安装Mysql

apt install mysql-server mysql-client

创建数据库

mysql -u root -p

create database blog

修改权限

ls -al   #查看当前权限
cd ../    
chmod -R 777 html/
cd html
ls -al

4. 安装php

apt install php

apt install install libapache2-mod-php

apt install php-mysql

5.安装wordpress

在安装之前,为使安装方便,我们安装一个小工具,可以将文件直接拖进xshell

apt install lrzsz

把wordpress压缩包放到/var/www/html下面

cd /var/www/html
tar xzvf wordpress....<tab键补全>

重启apache服务

/etc/init.d/apache2 restart

在登录之前,我们先修改一波账号密码,由于ubuntu20.04版本有些特殊,我们需要进入特定文件找到debain-sys-maint用户的密码

cat /etc/mysql/debain.cnf

用此账号和密码进行登录

mysql -u debain-sys-maint -p

修改密码

use mysql
flush privileges
alter user 'root'@'localhost' identified with mysql_native_password by '你的密码';
flush privileges

修改完成以后进入网址进行登录,我们会看到以下界面

在这里插入图片描述

ubuntu20.04 mysql修改root密码参考网址

https://blog.csdn.net/u013277209/article/details/108237466

Guess you like

Origin blog.csdn.net/weixin_47559704/article/details/115016131