一、准备工作
二、安装apache2
三、安装mysql
四、安装php
五、安装depress
准备工作
配置虚拟机安装ubuntu20.04
配置环境及相关设置(配置中文及防火墙等)

安装apache2
Apache HTTP服务器是世界上使用最广泛的Web服务器。它提供了许多强大的功能,包括可动态加载的模块,强大的媒体支持以及与其他流行软件的广泛集成。

开始安装

打开终端,进入根目录

`renxiaoxu@ubuntu:~$` sudo su

更新环境

renxiaoxu@ubuntu:~$ apt-get upgrade

安装apache环境

renxiaoxu@ubuntu:~$ sudo apt-get install apache

确认安装后, apt将安装Apache和所有必需的依赖项
安装完成之后我们可以在浏览器中输入localhost进行访问
也可以查看apache

renxiaoxu@ubuntu:~$ service apache2 status

看到runing说明成功

**

安装mysql 数据库
安装mysql

renxiaoxu@ubuntu:~$sudo apt-get install my-server

验证 MySQL

renxiaoxu@ubuntu:~$sudo apt-get install my-server
mysql.service - MySQL Community Server
mysql.service - MySQL Community ServerLoaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset:>Active: active (running) since Thu 2022-03-10 20:07:08 CST; 1 day 1h agoMain PID: 1024 (mysqld)Status: "Server is operational"Tasks: 43 (limit: 9419)Memory: 474.9MCGroup: /system.slice/mysql.service└─1024 /usr/sbin/mysqld

保护加固 MySQL

renxiaoxu@ubuntu:~$ mysql_secure_installation
●Error: Access denied for user 'root'@'localhost'

mysql需要测试 MySQL 用户密码的强度,并且提高安全性

Securing the MySQL server deployment.Connecting to MySQL using a blank password.VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?Press y|Y for Yes, any other key for No:

三个级别的密码验证策略,低级,中级,高级

There are three levels of password validation policy:LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  filePlease enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 2

下一次被提示时,将被要求为 MySQL root 用户设置一个密码:

Please set the password for root here.New password: Re-enter new password

如果你设置了验证密码插件,这个脚本将会显示你的新密码强度。输入y确认密码:


Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y

下一步,你将被要求移除任何匿名用户,限制 root 用户访问本地机器,移除测试数据库并且重新加载权限表。你应该对所有的问题回答y。
以 root 用户身份登录


renxiaoxu@ubuntu:~$ sudo mysql -u root -p

-u 指定用户名 -p需要输入密码


Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?Press y|Y for Yes, any other key for No:

安装 PHP 7.4,配合apache
更新环境


renxiaoxu@ubuntu:~# sudo apt update

安装PHP

renxiaoxu@ubuntu:~# sudo apt install php libapache2-mod-php

php安装好了,重启 Apache,重新加载 PHP 模块


renxiaoxu@ubuntu:# sudo systemctl restart apache2

安装 PHP 扩展
PHP 扩展被编译成库文件,用来扩展 PHP 核心功能
安装 MySQL 和 GD 扩展


renxiaoxu@ubuntu:# sudo apt install php-mysql php-gd

在安装一个新的 PHP 扩展之后,依赖于你的设置,不要忘记去重启 Apache 或者 PHP FPM 服务
测试 PHP 处理
进入/var/www

renxiaoxu@ubuntu:~$ cd /var/www

修改权限


renxiaoxu@ubuntu:~$#sudo chmod 777 /etc/apache2/mods-enabled/dir.conf
bash
renxiaoxu@ubuntu:~$/var/www# cd html/

建立php文件


renxiaoxu@ubuntu:~$/var/www/html# sudo gedit index.php

编辑内容如下


?phpecho phpinfo();
?>

浏览器输入http://localhost/info.php打开测试页面
至此lamp基本搭建完成

安装depress
修改ssh

进入根目录


sudo su -

修改配置文件


sudo vim /etc/ssh/ssh_config.d/

安装ssh


sudo apt-get install openssh-server

添加ssh.service


sudo systemctl enable ssh.service

启动ssh


service ssh start
sudo apt-get update && apt-get upgrade   //升级更新一下

配置防火墙


sudo ufw app list
sudo ufw allow 'Apache'
进入/var/www/html下创建自己的文件夹

cd /var/www/html/

创建你的项目文件夹


mkdir -p food

用户权限设置


renxiaoxu@ubuntu:~$/var/www/html# sudo chown -R 755 /var/www
修改000-default.conf

1.进入文件夹


renxiaoxu@ubuntu:~$/# cd /etc/apache2/sites-available/

2.备份


renxiaoxu@ubuntu:~$/etc/apache2# sudo cp 000-default.conf 000-food.conf

3.修改


renxiaoxu@ubuntu:~$/etc/apache2/sites-available# sudo nano 000-default.confThe ServerName directive sets the request scheme, hostname and port that# the server uses to identify itself. This is used when creating        # redirection URLs. In the context of virtual hosts, the ServerName        # specifies what hostname must appear in the request's Host: header to        # match this virtual host. For the default virtual host (this file) this        # value is not decisive as it is used as a last resort host regardless.        # However, you must set it for any further virtual host explicitly.        #ServerName www.example.com        ServerAdmin 1052469821@qq.com        ServerName lifeonchina        ServerAlias www.lifeonchina.com        DocumentRoot /var/www/html        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,        # error, crit, alert, emerg.        # It is also possible to configure the loglevel for particular        # modules, e.g.        #LogLevel info ssl:warn

4.修改完后ctrl+x保存退出

5.确认


renxiaoxu@ubuntu:~$/etc/apache2/sites-available# sudo a2ensite 000-default.conf
bash
Site 000-default already enabled       //成功

6.重启apache2,并检查


renxiaoxu@ubuntu:~$/etc/apache2/sites-available# sudo systemctl restart apache2
renxiaoxu@ubuntu:~$/etc/apache2/sites-available# sudo apache2ctl configtest
报错

Set the 'ServerName' directive globally to suppress this message

解决方式


renxiaoxu@ubuntu:~$/etc/apache2/sites-available# sudo nano  /etc/apache2/apache2.conf

编辑配置文件apache.conf

#在文件最后添加一行 ServerName localhost:80 #然后保存并重启Apache2

再测试


service apache2 restart
root@suliu-virtual-machine:/etc/apache2/sites-available# sudo apache2ctl configtest
Syntax OK.  //成功!

修改完成

1.登陆lmysql


renxiaoxu@ubuntu:/etc/apache2/sites-available# sudo mysql -u root -p

-//输入密码


Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)Copyright (c) 2000, 2022, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>           //成功进入

2.创建数据库//database:life; user:life_user; password:##############;


mysql> CREATE DATABASE life;(接着上面的mysql>,只需要写入CREATE DATABASE life;)Query OK, 1 row affected (0.06 sec)

3.创建USER

mysql> CREATE USER life_user@localhost IDENTIFIED BY '##############';

4.创建GRANT

mysql> GRANT ALL PRIVILEGES ON life.* TO life_user@localhost;
mysql> FLUSH PRIVILEGES;

退出

mysql> EXIT;

数据库创建完成、

安装wordpress
1.进入/var/www/html/

renxiaoxu@ubuntu:/etc/apache2/sites-available# cd /var/www/html/

2.下载woedpress文件

renxiaoxu@ubuntu:-virtual-machine:~# wget http://wordpress.org/latest.tar.gz

3.查看下载的文件

renxiaoxu@ubuntu-virtual-machine:~# ls

-看到latest.tar.gz,这是一个压缩包,将其解压 #@4.解压

renxiaoxu@ubuntu:-virtual-machine:~# tar xzvf latest.tar.gz

-解压完成后多了一个wordpress文件

5.update

sudo apt-get update

6.删除压缩文件

renxiaoxu@ubuntu:~$ rm latest.tar.gz

7.将wordpress里面的文件全部移到根目录即上一层目录

renxiaoxu@ubuntu:~$/var/www/html/wordpress# mv * /var/www/html/

编辑wenjian
1.备份wp-config-sample.php

renxiaoxu@ubuntu:~$/var/www/html# cp wp-config-sample.php wp-config.php

2.修改wp-config.php

rrenxiaoxu@ubuntu:~$/var/www/html# sudo nano wp-config.php

3.修改如下,数据库名,用户名,密码

bash
define( 'DB_NAME', 'life' );
/** Database username */define( 'DB_USER', 'life_user' );/** Database password */define(

linux常用指令
#@sudo gedit asdf命令下无法输入中文
//直接gedit asdf

#@删除文件
//sudo rm
// -rf 强力删除,不需确认
// -i 每删除一个文件或进入一个子目录都要确认
// -r 递归删除子目录
// -d 删除空目录
// -v 显示删除结果

#@快速查找文件
//whereis asdf
//locate asdf
//find /-name asdf

#@创建文件夹
//mkdir asdf

#@创建多级文件夹
//mkdir -p asdf

#@创建文件
//touch asdf.x

#@打开当前目录的弹窗
//sudo nautilus

#@复制一个文件到另一个文件
//sudo cp -r 文件夹名 目标文件夹路径

#@修改文件名
//sudo mv 原文件名 修改后文件名

#@启动mysql
// service mysql start

#mysql查看状态
// service mysql status

#@关闭mysql
// service mysql stop

#@启动apache
service apache2 start

#@重启apache
//service apache2 restart

#@停止apache
//service apache2 stop

#@apache查看状态
//service apache2 status

#@查看mysql的用户名和密码
//sudo cat /etc/mysql/debian.cnf

#@user = debian-sys-maint
#@password = K8Jjiz7MPntks3fZ

#@ctrl + r –查找上一次命令

#@回到本行首字母
//ctrl + a

#@登陆mysql
//sudo mysql -uroot -p

ubuntu20.04搭建lamp环境 +制作网页相关推荐

  1. ubutnu16.04搭建LAMP环境(搭建wordpress博客)

    本次讲的是ubuntu的16.04版,通过搭建Lamp环境来建立wordpress博客网站.其他的linux版本也可以参考. 安装之前最好先更新一下系统软件库.命令:sudo apt-get upda ...

  2. ubuntu-kylin16.04搭建lamp环境。

    首先下载安装apache2 输入:sudo apt-get install apache2 安装完毕后,在浏览器中输入:localhost 显示如下图,说明安装正确. 紧接着安装php7.0 输入:s ...

  3. linux如何搭建lamp环境,Linux操作系统下搭建LAMP环境

    准备:先在目录home/csy/下建website代码目录,然后新建php文件,命名为test.php. 在test.php编写代码如下: php phpinfo(); ?> 保存并退出. 一. ...

  4. 阿里云ubuntu14.04下lamp环境搭建の备忘

    以下内容大部分来自于网络上的收集,百度搜lamp能搜到很多文字教程.百度lamp搭建 推荐几个视频教程: 在Ubuntu Server下搭建LAMP环境 PHP环境LAMP/LNMP安装与配置 我收藏 ...

  5. PHP学习记录第一篇:Ubuntu14.04下LAMP环境的搭建

    PHP学习记录第一篇:Ubuntu14.04下LAMP环境的搭建 最近一段时间会学习一下PHP全栈开发,将会写一系列的文章来总结学习的过程,以自勉. 第一篇记录一下LAMP环境的安装 0. 安装Apa ...

  6. 在虚拟机端搭建lamp和通过docker技术在云服务器搭建lamp环境

    一.搭建LAMP环境--->部署WEB程序 1.LAMP环境作用(重点掌握) L:Linux操作系统,提供了项目部署时所需要的操作系统环境 A:Apache服务器:WEB应用程序的服务器,提供软 ...

  7. kali_vps,debian,Ubuntu下搭建LAMP环境

    文章目录 一.Apache2 web服务器的安装: 更新服务器出现以下问题: 安装Apache: 开启 .关闭和重启Apache服务器: 二.数据库的安装,这里安装MySQL5.7: 三.PHP的安装 ...

  8. Redhat Linux通过RPM安装搭建LAMP环境

    LAMP就是Linux+Apache+MySql+PHP搭建的动态网站环境,是目前互联网上非常流行的一个网页服务组合. 网上有很多教程搭建LAMP环境,基本上都是编译安装的,其实对新手来说只需要了解L ...

  9. 利用rpm包搭建lamp环境及论坛的创建

    一.利用rpm包搭建Lamp环境 安装过程 1. 安装apche服务 yum install httpd –y 2.安装mysql数据库 yum install mysql mysql-server ...

最新文章

  1. C++中的构造函数VS析构函数
  2. 物理机与虚拟机IP互ping通,而互ping主机名不通
  3. es重建字段类型_关于elasticsearch中更新数据的几种方式
  4. 稳定菜篮子市场供需 农业大健康-林裕豪:从玉农业全力保障
  5. SourceInsight 4.0 之二 项目文件关联
  6. IntelliJ IDEA for Mac 直接将模块硬盘上的根目录删除会怎么样
  7. Oracle利用序列实现自动增长列
  8. 【Java】Junit、反射和注解的笔记
  9. Android ArryaList 笔记
  10. ISCC2018(misc)
  11. OSError: [WinError 126] 找不到指定的模块。【专治疑难杂症】
  12. 替罪羊树+3369 【模板】普通平衡树
  13. 21日请假一天陪妈妈去国博
  14. php7.2 eregi,php – 函数eregi()已弃用
  15. 向军php视频教程下载,向军hd框架视频教程,后盾网框架下载
  16. 通过 TensorFlow 实现 AI 语音降噪提升 QQ 音视频通话质量
  17. MyBatis一对多关系映射
  18. 我写的Javascript贪食蛇v1
  19. mac默认输入法其实挺好用
  20. 自然场景文字检测方案总结

热门文章

  1. FlexRay汽车通信总线介绍及测试环境
  2. 仅改变rowspan背景_重排96黄金一代选秀前4位!艾弗森仅第三,前两名竟然还是队友...
  3. 八卦:大量放送Gmail,Orkut,Wallop的邀请函
  4. 使用 TestFight 构建 Beta 测试版本
  5. STM32学习笔记(15)——SPI协议
  6. Java缓存知识汇总
  7. 如何进行期货日内趋势量化交易系统的设计?
  8. 冒烟测试(smoke test)、可用性测试(sanity test)和回归测试(regression test)
  9. 手机搜狐 html5,手机搜狐欲改版推全新域名及LOGO 着力Html5技术
  10. 程序员的机器学习入门笔记(一):基本概念介绍