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.
( ->

Ho i did that:

i have linux server, so i logged in via SSH.

Backed up PHPBB forum files:

cd /home/sourceusername/public_html

tar cf filesbckp.tar

backed-up PHPBB database:

mysqldump -u mysql_username -pmysqlpassword mysql_databasename > databasebckp.sql

changed domain name in database dump:

sed -i 's|||g' ./databasebckp.sql
sed -i 's|||g' ./databasebckp.sql

then i logged in my hosting account where i want to host my forum from now on.

- created subdomain
- created new database & username for the forum + attached username permissions to database

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

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/

now your should work ok, if it works, modiffy .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 (.*)$1 [R=301,L]

your old domain ( visitors should be now redirected to your new domain subdomain (

make sure you dont forget to create mail boxes and cronjobs if you had any in your old hosting account

it might be usefull to request URL change in Google Webmaster tools: