ubuntu

Ubuntu下如何更新LNMP组件

小樊
35
2025-06-02 21:52:39
栏目: 智能运维

在 Ubuntu 下更新 LNMP 组件(Linux, Nginx, MySQL/MariaDB, PHP)的方法如下:

  1. 更新系统软件包列表:
sudo apt-get update
  1. 更新所有已安装的软件包:
sudo apt-get upgrade
  1. 如果你想单独更新 Nginx、MySQL/MariaDB 或 PHP,可以使用以下命令:

    • 更新 Nginx:
    sudo apt-get install nginx
    
    • 更新 MySQL:
    sudo apt-get install mysql-server
    
    • 更新 MariaDB:
    sudo apt-get install mariadb-server
    
    • 更新 PHP(以 PHP 7.4 为例):
    sudo apt-get install php7.4-fpm php7.4-mysql php7.4-xml php7.4-mbstring php7.4-curl php7.4-gd
    

    请根据你的需求选择相应的 PHP 版本和扩展。

  2. 在更新完成后,重启相应的服务以使更改生效:

    • 重启 Nginx:
    sudo systemctl restart nginx
    
    • 重启 MySQL:
    sudo systemctl restart mysql
    
    • 重启 MariaDB:
    sudo systemctl restart mariadb
    
    • 重启 PHP-FPM(以 PHP 7.4 为例):
    sudo systemctl restart php7.4-fpm
    
  3. 检查服务状态以确保它们已成功启动:

    • 检查 Nginx 状态:
    sudo systemctl status nginx
    
    • 检查 MySQL 状态:
    sudo systemctl status mysql
    
    • 检查 MariaDB 状态:
    sudo systemctl status mariadb
    
    • 检查 PHP-FPM 状态(以 PHP 7.4 为例):
    sudo systemctl status php7.4-fpm
    

现在,你已经成功更新了 Ubuntu 下的 LNMP 组件。请注意,根据你的实际需求,你可能需要安装其他 PHP 扩展或调整配置文件。

0
看了该问题的人还看了