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注意:具體命令和路徑可能因發行版略有差異,建議根據系統類型選擇對應操作。