利用 Linux LAMP 搭建云服务平台
一、架构与方案选型
二、标准落地步骤(以 CentOS 7 为例)
yum update -y && yum install -y wget curl vimsystemctl start firewalld && firewall-cmd --permanent --add-service={http,https,ssh} && firewall-cmd --reloadyum install -y httpdsystemctl start httpd && systemctl enable httpdhttp://服务器公网IP 出现 Apache 欢迎页。yum install -y mariadb-server mariadbsystemctl start mariadb && systemctl enable mariadbmysql_secure_installation(设置 root 强密码、删除匿名用户、禁止远程 root 等)。yum install -y epel-releaserpm -Uvh https://mirrors.tencent.com/remi/enterprise/remi-release-7.rpmyum-config-manager --enable remi-php83yum install -y php php-cli php-fpm php-mysqlnd php-zip php-gd php-mbstring php-curl php-xml php-bcmath php-jsonServerName localhost:80<Directory> 中 Require all denied 改为 Require all grantedDirectoryIndex index.php index.htmlAddType application/x-httpd-php .php 与 AddType application/x-httpd-php-source .phpssystemctl restart httpdecho "<?php phpinfo(); ?>" > /var/www/html/info.phphttp://服务器公网IP/info.php 看到 PHP 信息页即成功。三、将 LAMP 升级为可用的“云平台”
/etc/httpd/conf.d/ 下新增站点配置(ServerName、DocumentRoot、日志、目录权限),支持多站点隔离。<VirtualHost *:80> ServerName app.example.com DocumentRoot /var/www/myapp <Directory /var/www/myapp> Options Indexes FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog /var/log/httpd/myapp_error.log CustomLog /var/log/httpd/myapp_access.log combined </VirtualHost>systemctl restart httpdyum install -y certbot python3-certbot-apachecertbot --apache -d app.example.comecho "0 3 * * * /usr/bin/certbot renew --quiet" | crontab -opcache.enable=1; opcache.memory_consumption=128),开启 mod_deflate 压缩,配置浏览器与 CDN 缓存策略。mysql -u root -pCREATE DATABASE nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;GRANT ALL PRIVILEGES ON nextcloud.* TO 'ncuser'@'localhost' IDENTIFIED BY 'StrongPass!'; FLUSH PRIVILEGES;/var/www/nextcloudchown -R apache:apache /var/www/nextcloud/var/www/nextcloud,启用 HTTPS四、云上最佳实践与运维要点