阅读量:3
Linux管理LAMP组件需分别操作各部分,核心命令及方法如下:
一、系统级管理
- 更新系统:
- Ubuntu/Debian:
sudo apt update && sudo apt upgrade -y - CentOS/RHEL:
sudo yum update -y
- Ubuntu/Debian:
二、Apache管理
- 服务控制:
sudo systemctl start/stop/restart apache2(Ubuntu/Debian)
sudo systemctl start/stop/restart httpd(CentOS/RHEL) - 模块管理:
sudo a2enmod 模块名(启用模块,如rewrite)
sudo a2dismod 模块名(禁用模块) - 配置文件:
路径:/etc/apache2/apache2.conf(Ubuntu/Debian)或/etc/httpd/conf/httpd.conf(CentOS/RHEL)
修改后需重启Apache生效。
三、MySQL/MariaDB管理
- 服务控制:
sudo systemctl start/stop/restart mysql(Ubuntu/Debian)
sudo systemctl start/stop/restart mysqld(CentOS/RHEL) - 安全配置:
sudo mysql_secure_installation(设置root密码、删除匿名用户等) - 数据库操作:
登录MySQL:sudo mysql -u root -p
备份数据库:mysqldump -u root -p 数据库名 > backup.sql
四、PHP管理
- 安装与更新:
Ubuntu/Debian:sudo apt install php libapache2-mod-php php-mysql
CentOS/RHEL:sudo yum install php php-mysqlnd - 配置文件:
路径:/etc/php/版本号/apache2/php.ini
修改后需重启Apache生效。 - 扩展管理:
安装扩展:sudo apt install php-扩展名(如php-gd)
五、通用操作
- 查看状态:
sudo systemctl status apache2/mysql - 防火墙配置:
Ubuntu:sudo ufw allow 80/tcp(HTTP)
CentOS:sudo firewall-cmd --add-service=http --permanent
注意:具体命令和路径可能因发行版略有差异,建议根据系统类型选择对应操作。
以上就是关于“Linux怎样管理LAMP组件”的相关介绍,筋斗云是国内较早的云主机应用的服务商,拥有10余年行业经验,提供丰富的云服务器、租用服务器等相关产品服务。云服务器资源弹性伸缩,主机vCPU、内存性能强悍、超高I/O速度、故障秒级恢复;电子化备案,提交快速,专业团队7×24小时服务支持!
简单好用、高性价比云服务器租用链接:https://www.jindouyun.cn/product/cvm