Technology Sharing

  • 首页
  • 资料分享
  • 在线工具
    • 随机密码生成器
  • 介绍
  • RSS
  • privacy
  • 云产品推广
    • 腾讯云
    • 阿里云
Share IT knowledge
  1. 首页
  2. linux
  3. 正文

部署lnmp环境(ubuntu20.04)

2022年6月27日 329点热度 0人点赞 2条评论

阿里云建站 腾讯云建站

nginx安装配置

以下是官方给出的 nginx 安装步骤,详情可参考这里

安装依赖程序

apt install curl gnupg2 ca-certificates lsb-release -y

导入stable nginx 安装源

echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
    | sudo tee /etc/apt/sources.list.d/nginx.list

设置安装源倾向性

echo -e "Package: *\nPin: origin nginx.org\nPin: release o=nginx\nPin-Priority: 900\n" \
    | sudo tee /etc/apt/preferences.d/99nginx

导入nginx官方签名

curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key

验证下载的文件是否包含正确的密钥

gpg --dry-run --quiet --import --import-options show-only /tmp/nginx_signing.key

输出如下指纹信息则正确:573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62

pub   rsa2048 2011-08-19 [SC] [expires: 2024-06-14]
      573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62
uid                      nginx signing key <signing-key@nginx.com>

最后,将密钥移动到 apt 可信密钥存储(注意“asc”文件扩展名更改):

mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx_signing.asc

安装nginx

apt update -y
apt install nginx -y

确认nginx 服务正常运行,执行

systemctl status nginx.service
PHP 8.0 安装配置

安装依赖软件

apt install software-properties-common -y 

启用php 软件库

add-apt-repository ppa:ondrej/php

按Enter继续执行

安装 php8.0及扩展

apt install -y php8.0 php8.0-cli php8.0-common php8.0-fpm php8.0-gd php8.0-mbstring php8.0-mysql php8.0-igbinary php8.0-msgpack php8.0-redis php8.0-xml php8.0-curl

修改 php.ini 主配置文件,做如下替换

sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /etc/php/8.0/fpm/php.ini
sed -i 's/memory_limit = 128M/memory_limit = 256M/g' /etc/php/8.0/fpm/php.ini

配置 php8.0-fpm
其他配置不用动,只改动如下几项,将php-fpm的用户和组均设置为 nginx

sed -i 's/user = www-data/user = nginx/' /etc/php/8.0/fpm/pool.d/www.conf
sed -i 's/group = www-data/group = nginx/' /etc/php/8.0/fpm/pool.d/www.conf
sed -i 's/listen.owner = www-data/listen.owner = nginx/' /etc/php/8.0/fpm/pool.d/www.conf
sed -i 's/listen.group = www-data/listen.group = nginx/' /etc/php/8.0/fpm/pool.d/www.conf

重启服务

systemctl restart php8.0-fpm.service

确认php8.0-fpm 服务正常运行,执行

systemctl status php8.0-fpm.service
MariaDB 安装配置

安装

apt update 
apt install -y mariadb-server  mariadb-client

MariaDB安全设置,包括设置root密码,移除root远程登陆等

mysql_secure_installation

重启数据库:

systemctl restart mariadb

确认mariadb 服务正常运行,执行

systemctl status mariadb.service
打赏微海报分享
标签: 暂无
最后更新:2023年5月18日

nico

Linux运维工程师 软考网络工程师 && 软考信息安全工程师

点赞
下一篇 >

文章评论

  • heihei

    不错

    2022年6月28日
    回复
    • nico

      @heihei 谢谢认可

      2022年6月28日
      回复
  • razz evil exclaim smile redface biggrin eek confused idea lol mad twisted rolleyes wink cool arrow neutral cry mrgreen drooling persevering
    取消回复

    nico

    Linux运维工程师
    软考网络工程师 && 软考信息安全工程师

    最新 热点 随机
    最新 热点 随机
    linux部署JDK环境 [Solved] MariaDB import issue: Error at line 1: Unknown command '\-'. Could not retrieve mirrorlist http://mirrorlist.centos.org/ CentOS 7 Kubernetes如何删除卡在“Terminating”状态的命名空间 解决GitLab Runner签名无效 如何禁用 Ubuntu "Daemons using outdated libraries" 弹出窗口
    Python自动化 | 比对两份Excel/Word文件 Centos7 升级redis版本 Nginx 设置浏览器缓存过期时间 Nginx: SSL_do_handshake() failed… and that’s OK! 安装 PHP 8.2 中的 gRPC 和 protobuf 扩展 [SOLVED] extension "vector" is not available
    最近评论
    woodcockkienzlelsj8o9+73s48g9rr3m0@gmail.com 发布于 10 个月前(07月17日) necessitatibus corporis et odit nam quo harum et c...
    RonaldG 发布于 10 个月前(07月07日) Very interesting topic, thank you for putting up.&...
    小黑 发布于 1 年前(12月28日) 不错
    nico 发布于 2 年前(02月09日) 嘻嘻嘻!!!
    Bruse 发布于 2 年前(02月09日) 我来啦!!!
    nico 发布于 2 年前(12月10日) 方便查询
    Justin 发布于 2 年前(12月10日) 写的很好,谢谢分享!我 Mark 一下~
    nico 发布于 3 年前(11月18日) 主题的原因吧
    Justin 发布于 3 年前(09月22日) 这篇文章的质量很高呀!写得很详细~ 话说你的文章是隐藏了发布时间吗?
    Justin 发布于 3 年前(08月27日) 好家伙,这标题乍一看还以为你打算进军英文技术写作领域了🤓

    COPYRIGHT © 2023 Technology Sharing. ALL RIGHTS RESERVED.

    备案图标 皖公网安备34132402000202 皖ICP备2023004851号-1