6 个实验 · 真机操作 · 含终端模拟
在 CentOS 上安装 Apache + MySQL + PHP
yum install -y httpd mariadb-server php php-mysqlsystemctl start httpd mariadbsystemctl enable httpd mariadbfirewall-cmd --permanent --add-service=httpfirewall-cmd --reloadecho " /var/www/html/index.php为后端 Tomcat 配置 Nginx 反代
yum install -y nginxvim /etc/nginx/conf.d/proxy.conf配置 upstream 和 proxy_passnginx -tsystemctl reload nginx配置 MySQL 主从同步
主库: vim /etc/my.cnf → log-bin=mysql-bin主库: GRANT REPLICATION SLAVE从库: CHANGE MASTER TO从库: START SLAVE从库: SHOW SLAVE STATUS\G使用 firewalld 开放服务
firewall-cmd --statefirewall-cmd --list-allfirewall-cmd --add-service=http --permanentfirewall-cmd --add-port=443/tcp --permanentfirewall-cmd --reload写一个系统监控脚本
#!/bin/bashecho "当前时间: $(date)"echo "CPU 负载: $(uptime)"echo "磁盘使用: $(df -h | head -2)"crontab -e 添加定时任务部署一个 Nginx 容器
docker pull nginx:latestdocker run -d -p 80:80 --name myweb nginxdocker psdocker logs mywebdocker exec -it myweb bash