windows下Ubuntu安装 Lnmp环境

安装 Nginx#

  1. 安装Nginx
    sudo apt install nginx -y
  2. 启动并使 Nginx 在启动时自动启动
    sudo systemctl start nginx
    sudo systemctl enable nginx

     

     

     

安装Mysql5.7 #

一:先卸载并清理历史的Mysql环境#

  • 首先,停止Mysql服务
    sudo systemctl stop mysql
  • 然后,通过apt-get命令移除MySQL包
    sudo apt-get remove --purge mysql-server mysql-client mysql-common
  • 清理残余的配置和数据文件
    sudo rm -rf /etc/mysql /var/lib/mysql
    sudo apt-get autoremove
    sudo apt-get autoclean
  • 如果你之前安装了其他非官方的MySQL版本或是MariaDB,也可以一并卸载
    sudo apt-get remove --purge mysql-server-core-*

二:安装 Mysql5.7版本的环境#

  1. 更新软件包列表
    sudo apt-get update
  2. 查看系统默认安装的数据库版本
    执行命令:
    sudo apt-cache policy mysql-server

  3. 需要安装mysql5.7的版本就需要换源
    先备份文件:
    sudo cp /etc/apt/sources.list /etc/apt/sources.list.back
    然后更换apt源:修改sources.list文件
    sudo vim /etc/apt/sources.list
    #  阿里源
    deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

  4. 更新镜像源
    sudo gpg --keyserver keyserver.ubuntu.com --recv 3B4FE6ACC0B21F32
    sudo gpg --export --armor 3B4FE6ACC0B21F32 | sudo apt-key add -
    sudo apt-get update
  5. 查看默认安装的mysql数据库版本,可以看到默认的已经变成了mysql5.7的版本了哦!



  6. 安装Mysql5.7
    sudo apt-get -y install mysql-server-5.7
  7. 查看mysql是否安装成功
    sudo dpkg -l | grep mysql
    mysql -V
    sudo systemctl status mysql

  8.  

    设置开机自启
    sudo systemctl enable mysql
  9. 修改服务为全网启动
    打开mysql的配置文件:/etc/mysql/mysql.conf.d/mysqld.cnf


  10. 换回apt源
    cd /etc/apt
    sudo mv sources.list sources.list.old
    sudo mv sources.list.back  sources.list
    sudo apt-get update
  11. 进入mysql终端
    输入 sudo mysql  回车,默认是没有密码的哦!

  12. 设置允许远程访问
    use mysql;
    update user set host='%' where user = 'root' and host='localhost';
    grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
    flush privileges;

     

安装php7.4#

  1. 为了安装 PHP 7.4,我们可以使用 ondrej/php PPA:
    sudo apt install software-properties-common -y
    sudo add-apt-repository ppa:ondrej/php
    sudo apt update
  2. 安装 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
  3. 启动并使 PHP 7.4 FPM 在启动时自动启动
    sudo systemctl start php7.4-fpm
    sudo systemctl enable php7.4-fpm

     

作者:Carver-大脸猫

出处:https://www.cnblogs.com/carver/articles/18508645

版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。

转载请注明原处

posted @   Carver-大脸猫  阅读(19)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 25岁的心里话
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 按钮权限的设计及实现
点击右上角即可分享
微信分享提示
more_horiz
keyboard_arrow_up light_mode palette
选择主题
menu