Fli
05-08-2015, 05:14 PM
How to move PHPBB forum from one domain to another domains subdomain - via Linux SSH command line
I wanted to decrease my domain costs and decided to trash my forum domain and instead run the forum on another domain of mine as a subdomain.
(myforumname.net -> myforumname.mynewdomain.com)
Ho i did that:
i have Linux server, so i logged in via SSH and
A) backed up PHPBB forum files:
cd /home/sourceusername/public_html && tar cf filesbckp.tar # make sure that source and destination account has enough free space
B) or i have directly copied files over to new account:
rsync -av --progress --sparse --links --hard-links ./public_html/ -e "ssh -p 22" DestinationUser@DestinationServerNameOrIP:domains/newsubdomain.newdomain.tld/public_html/
backed-up PHPBB database
mysqldump -u mysql_username -pmysqlpassword mysql_databasename > databasebckp.sql
changed domain name in database dump:
sed -i 's|www.myforumname.net|myforumname.mynewdomain.com |g (http://www.myforumname.net|myforumname.mynewdomain.com|g) ' ./databasebckp.sql
sed -i 's|myforumname.net|myforumname.mynewdomain.com|g' ./databasebckp.sql
sed -i 's|MyForumName.net|MyForumName.mynewdomain.com|g' ./databasebckp.sql # capital letter case for site name and such
Make sure that the resulting databasebckp.sql file does not contain any more variants of old domain.
then i logged in my hosting account where i want to host my forum from now on.
- created subdomain myforumname.mynewdomain.com
- created new database & username for the forum + attached username permissions to database
- make sure PHP version match PHPBB requirements
then i can fill newly created database with data from my backup file:
mysql -u newmysql_username -pnewmysqlpassword newmysqldatabase < ./databasebckp.sql
go to newly created subdomain folder
cd /home/targetusername/public_html/subdomains/myforumname/
extract files backup located in old location to newlocation
tar xf /home/sourceusername/public_html/filesbckp.tar -C /home/targetusername/public_html/subdomains/myforumname/
set proper permissions to all extracted PHPBB files in newlocation:
cd /home/targetusername/public_html/subdomains/myforumname/
chown -R targetusername:targetusername *
edit config file in new location (in /home/targetusername/public_html/subdomains/myforumname) to update with mysql database login credentials:
vi config.php
replace old domain name by the new one inside new files, do it in this order:
cd /home/targetusername/public_html/subdomains/myforumname/
find . -type f -print0 | xargs -0 sed -i 's|www.old.tld|new.domain.com|g (http://www.old.tld|new.domain.com|g)'
find . -type f -print0 | xargs -0 sed -i 's|old.tld|new.domain.com|g'
find . -type f -print0 | xargs -0 sed -i 's|Old.tld|New.Domain.com|g' # capital letter case for site name and such
go to new location, subdomain folder and then into cache "folder":
cd /home/targetusername/public_html/subdomains/myforumname/cache
and delete all files except index.html and .htaccess
then copy .htaccess file from old hosting to new hosting
cp /home/sourceusername/public_html/.htaccess /home/targetusername/public_html/subdomains/myforumname/
inside .htaccess copy, rename your old domain to new tone:
vi /home/targetusername/public_html/subdomains/myforumname/.htaccess
now your myforumname.mynewdomain.com should work ok, if it works, modify .htaccess file in your source directory to start pointing your old domain visitors to your new subdomain:
vi /home/sourceusername/public_html/.htaccess
add into it example:
RewriteEngine On
RewriteRule (.*) http://myforumname.mynewdomain.com/$1 [R=301,L]
your old domain (myforumname.net) visitors should be now redirected to your new domain subdomain (myforumname.mynewdomain.com)
inside new forum administration, check main forum settings if it shows new domain.
make sure you don't forget to create mail boxes and cronjobs if you had any in your old hosting account
find backlinks to your old domain and update these to new address
it might be useful to request URL change in Google Webmaster tools: https://support.google.com/webmasters/answer/83106
disable automatic renewal of your old domain if applicable
schedule removal of the old hosting account with some delay or just keep its backup for some time
I wanted to decrease my domain costs and decided to trash my forum domain and instead run the forum on another domain of mine as a subdomain.
(myforumname.net -> myforumname.mynewdomain.com)
Ho i did that:
i have Linux server, so i logged in via SSH and
A) backed up PHPBB forum files:
cd /home/sourceusername/public_html && tar cf filesbckp.tar # make sure that source and destination account has enough free space
B) or i have directly copied files over to new account:
rsync -av --progress --sparse --links --hard-links ./public_html/ -e "ssh -p 22" DestinationUser@DestinationServerNameOrIP:domains/newsubdomain.newdomain.tld/public_html/
backed-up PHPBB database
mysqldump -u mysql_username -pmysqlpassword mysql_databasename > databasebckp.sql
changed domain name in database dump:
sed -i 's|www.myforumname.net|myforumname.mynewdomain.com |g (http://www.myforumname.net|myforumname.mynewdomain.com|g) ' ./databasebckp.sql
sed -i 's|myforumname.net|myforumname.mynewdomain.com|g' ./databasebckp.sql
sed -i 's|MyForumName.net|MyForumName.mynewdomain.com|g' ./databasebckp.sql # capital letter case for site name and such
Make sure that the resulting databasebckp.sql file does not contain any more variants of old domain.
then i logged in my hosting account where i want to host my forum from now on.
- created subdomain myforumname.mynewdomain.com
- created new database & username for the forum + attached username permissions to database
- make sure PHP version match PHPBB requirements
then i can fill newly created database with data from my backup file:
mysql -u newmysql_username -pnewmysqlpassword newmysqldatabase < ./databasebckp.sql
go to newly created subdomain folder
cd /home/targetusername/public_html/subdomains/myforumname/
extract files backup located in old location to newlocation
tar xf /home/sourceusername/public_html/filesbckp.tar -C /home/targetusername/public_html/subdomains/myforumname/
set proper permissions to all extracted PHPBB files in newlocation:
cd /home/targetusername/public_html/subdomains/myforumname/
chown -R targetusername:targetusername *
edit config file in new location (in /home/targetusername/public_html/subdomains/myforumname) to update with mysql database login credentials:
vi config.php
replace old domain name by the new one inside new files, do it in this order:
cd /home/targetusername/public_html/subdomains/myforumname/
find . -type f -print0 | xargs -0 sed -i 's|www.old.tld|new.domain.com|g (http://www.old.tld|new.domain.com|g)'
find . -type f -print0 | xargs -0 sed -i 's|old.tld|new.domain.com|g'
find . -type f -print0 | xargs -0 sed -i 's|Old.tld|New.Domain.com|g' # capital letter case for site name and such
go to new location, subdomain folder and then into cache "folder":
cd /home/targetusername/public_html/subdomains/myforumname/cache
and delete all files except index.html and .htaccess
then copy .htaccess file from old hosting to new hosting
cp /home/sourceusername/public_html/.htaccess /home/targetusername/public_html/subdomains/myforumname/
inside .htaccess copy, rename your old domain to new tone:
vi /home/targetusername/public_html/subdomains/myforumname/.htaccess
now your myforumname.mynewdomain.com should work ok, if it works, modify .htaccess file in your source directory to start pointing your old domain visitors to your new subdomain:
vi /home/sourceusername/public_html/.htaccess
add into it example:
RewriteEngine On
RewriteRule (.*) http://myforumname.mynewdomain.com/$1 [R=301,L]
your old domain (myforumname.net) visitors should be now redirected to your new domain subdomain (myforumname.mynewdomain.com)
inside new forum administration, check main forum settings if it shows new domain.
make sure you don't forget to create mail boxes and cronjobs if you had any in your old hosting account
find backlinks to your old domain and update these to new address
it might be useful to request URL change in Google Webmaster tools: https://support.google.com/webmasters/answer/83106
disable automatic renewal of your old domain if applicable
schedule removal of the old hosting account with some delay or just keep its backup for some time