Linux管理LAMP组件需分别操作各部分,核心命令及方法如下:
sudo apt update && sudo apt upgrade -y
sudo yum update -y
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)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 -p
mysqldump -u root -p 数据库名 > backup.sql
sudo apt install php libapache2-mod-php php-mysql
sudo yum install php php-mysqlnd
/etc/php/版本号/apache2/php.ini
sudo apt install php-扩展名
(如php-gd
)sudo systemctl status apache2/mysql
sudo ufw allow 80/tcp
(HTTP)sudo firewall-cmd --add-service=http --permanent
注意:具体命令和路径可能因发行版略有差异,建议根据系统类型选择对应操作。