在Debian系统中配置LNMP(Linux, Nginx, MySQL/MariaDB, PHP)环境时,您可能需要使用一些常用的命令来管理各个组件。以下是一些基本的命令:
安装Nginx:
sudo apt update
sudo apt install nginx
启动Nginx:
sudo systemctl start nginx
停止Nginx:
sudo systemctl stop nginx
重启Nginx:
sudo systemctl restart nginx
检查Nginx状态:
sudo systemctl status nginx
测试Nginx配置文件是否有语法错误:
sudo nginx -t
安装MySQL:
sudo apt update
sudo apt install mysql-server
安装MariaDB:
sudo apt update
sudo apt install mariadb-server
启动MySQL/MariaDB:
sudo systemctl start mysql
或者
sudo systemctl start mariadb
停止MySQL/MariaDB:
sudo systemctl stop mysql
或者
sudo systemctl stop mariadb
重启MySQL/MariaDB:
sudo systemctl restart mysql
或者
sudo systemctl restart mariadb
安全设置(MySQL特有):
sudo mysql_secure_installation
安装PHP及其常用模块:
sudo apt update
sudo apt install php-fpm php-mysql php-curl php-gd php-mbstring php-xml php-pear php-zip
重启PHP-FPM服务 (如果使用PHP-FPM):
sudo systemctl restart php7.4-fpm
注意:根据您安装的PHP版本,命令中的php7.4-fpm
可能需要替换为相应的版本号。
更新系统包列表:
sudo apt update
升级已安装的系统包:
sudo apt upgrade
查看防火墙状态 (如果使用UFW):
sudo ufw status
允许HTTP和HTTPS流量 (如果使用UFW):
sudo ufw allow 'Nginx Full'
这些命令涵盖了在Debian系统上设置和管理LNMP环境的基本需求。根据您的具体需求,您可能还需要安装其他软件包或进行额外的配置。