Linux管理LAMP组件需分别操作各部分,核心命令及方法如下:
sudo apt update && sudo apt upgrade -ysudo yum update -ysudo 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)sudo systemctl start/stop/restart mysql(Ubuntu/Debian)sudo systemctl start/stop/restart mysqld(CentOS/RHEL)sudo mysql_secure_installation(设置root密码、删除匿名用户等)sudo mysql -u root -pmysqldump -u root -p 数据库名 > backup.sqlsudo apt install php libapache2-mod-php php-mysqlsudo yum install php php-mysqlnd/etc/php/版本号/apache2/php.inisudo apt install php-扩展名(如php-gd)sudo systemctl status apache2/mysqlsudo ufw allow 80/tcp(HTTP)sudo firewall-cmd --add-service=http --permanent注意:具体命令和路径可能因发行版略有差异,建议根据系统类型选择对应操作。