下面给你一套**在 Debian 上迁移 Apache(含网站、配置、数据)**的常见做法,适用于:
apache2 -v
php -v
lsb_release -a
记录:
mod_php、mod_ssl、mod_rewrite)systemctl stop apache2
tar czf apache-config.tar.gz /etc/apache2
主要目录:
/etc/apache2/sites-available/etc/apache2/sites-enabled/etc/apache2/mods-enabled/etc/apache2/conf-enabledtar czf www.tar.gz /var/www
如果是多站点,逐个目录打包更清晰。
mysqldump -u root -p --all-databases > db.sql
apt update
apt install apache2
如原服务器用 PHP:
apt install php libapache2-mod-php
tar xzf apache-config.tar.gz -C /
或只恢复关键目录:
cp -r sites-available /etc/apache2/
cp -r sites-enabled /etc/apache2/
tar xzf www.tar.gz -C /
确保权限正确:
chown -R www-data:www-data /var/www
mysql -u root -p < db.sql
a2enmod rewrite ssl
a2ensite your-site.conf
检查配置:
apache2ctl configtest
systemctl restart apache2
systemctl enable apache2
DocumentRoot 权限<Directory> 配置a2enmod php
systemctl restart apache2
迁移:
/etc/ssl/certs/
/etc/ssl/private/
如果你愿意,可以告诉我:
我可以给你更精确的迁移命令。