Difference between revisions of "Copying a website from localhost to a remote host"
From Joomla! Documentation
m (→Using Akeeba backup to move a site: clean up categories with <noinclude> tags) |
(Several markup changes. URL correction.) |
||
(6 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
− | + | <noinclude><languages /></noinclude> | |
− | + | When you are first trying out Joomla!, it is often recommended that you install it on your local system. ''localhost'' for example with [https://en.wikipedia.org/wiki/XAMPP XAMPP], and get your site running locally. Eventually you may want to copy this site to your remote host. Fortunately, this is easy to do. | |
− | + | This article assumes you have installed Joomla! on your local computer, you have created a website and you now wish to copy this website to your remote host. | |
− | == | + | == Using Akeeba Backup to Move a Site (Preferred Method) == |
− | + | * Akeeba Backup produces a ''.jpa'' file. | |
+ | * The ''.jpa'' file contains all the folders, files and the contents of the database. | ||
+ | * The ''.jpa'' file also contains an installer. | ||
+ | * The ''kickstart.php'' file from [https://www.akeeba.com/products/akeeba-kickstart.html Akeeba] unpacks the ''.jpa'' file. | ||
+ | * You then run the ''kickstart.php'' program and install your site. | ||
+ | * The installer has an option to change the configuration for restoring to a different location. | ||
− | ==Copy Files and Directories of Your Local Joomla Directory to the Remote Host== | + | Akeeba Backup can be downloaded from [https://extensions.joomla.org/extension/access-a-security/site-security/akeeba-backup/ Joomla extension directory]. There is a link to full instructions there as well. |
+ | |||
+ | == Alternate Method == | ||
+ | === Create a Place on Your Remote Host to Install Joomla! === | ||
+ | If this is a new site, it will just be your home directory. If you have an existing site, for example ''www.domain.com'', that you wish to keep while you work with Joomla!, you may be able to create a subdomain, for example, ''mytest.domain.com'' to hold your Joomla! site. | ||
+ | |||
+ | === Copy Files and Directories of Your Local Joomla Directory to the Remote Host === | ||
You have two methods: | You have two methods: | ||
− | #Upload all files by FTP | + | # Upload all files by FTP |
− | #Upload only a compressed file by FTP | + | # Upload only a compressed file by FTP |
− | ===Upload | + | ==== Upload All Files by FTP ==== |
− | Normally, the easiest way to copy these files is using an FTP client program, such as [ | + | Normally, the easiest way to copy these files is using an FTP client program, such as [https://filezilla-project.org Filezilla]. |
− | Select all files from directory localhost ( | + | Select all files from the directory localhost. (With XAMPP, the directory will be ''/xampp/www/directory''.) Upload to the remote host HTML directory for a domain or to the remote host HTML subdirectory. |
{| class="wikitable" | {| class="wikitable" | ||
Line 24: | Line 35: | ||
| [[Image:Filezilladircopy.png|Select Dir.]] || [[Image:Filezilladirectory.png|Dir Filezilla.]] || [[Image:Filezillasubdirectory.png|Subdir Filezilla.]] | | [[Image:Filezilladircopy.png|Select Dir.]] || [[Image:Filezilladirectory.png|Dir Filezilla.]] || [[Image:Filezillasubdirectory.png|Subdir Filezilla.]] | ||
|- | |- | ||
− | |||
|} | |} | ||
− | ===Upload a Compressed File=== | + | ==== Upload a Compressed File ==== |
− | Copying a large number of individual files using FTP can | + | Copying a large number of individual files using FTP can be unreliable. If you have command-line access to the both source and destination systems, you can create a compressed archive file containing all the files on the source system. Then transfer that single file to the destination system where it can be decompressed. |
− | + | ===== Creating an Archive File ===== | |
− | On Unix-style systems | + | On Unix-style systems such as Linux, you can use the [https://www.gnu.org/software/gzip/ Gzip program] to create ''.zip'' files, or the [https://www.gnu.org/software/tar/ Tar program] to create ''.tar.gz'' or ''.tar.bz2'' files. For detailed instructions, type ''man gzip'' or ''man tar'' at the command line. For example, |
− | < | + | <syntaxhighlight lang="php"> |
tar cvfz joomlabackup.tar.gz /path-to-joomla | tar cvfz joomlabackup.tar.gz /path-to-joomla | ||
− | </ | + | </syntaxhighlight> |
− | will create a gzip-compressed archive file, called joomlabackup.tar.gz | + | will create a gzip-compressed archive file, called ''joomlabackup.tar.gz''. It contains all the files in your Joomla! installation. |
− | Important note! You need to make sure you are | + | Important note! You need to make sure you are '''not''' in the folder you are trying to backup when you run the tar command or you will create an endless loop. |
− | + | ===== Extracting an Archive File ===== | |
Having copied the archive file to the destination system, you now need to unpack it. Use the equivalent command that you used to create the archive file. For example, to unpack the archive file created in the example above, enter | Having copied the archive file to the destination system, you now need to unpack it. Use the equivalent command that you used to create the archive file. For example, to unpack the archive file created in the example above, enter | ||
− | + | ||
− | < | + | <syntaxhighlight lang="php"> |
cd /path-to-joomla | cd /path-to-joomla | ||
tar xvfz joomlabackup.tar.gz | tar xvfz joomlabackup.tar.gz | ||
− | </ | + | </syntaxhighlight> |
− | If the user or group IDs are not the same between the source and destination systems, | + | If the user or group IDs are not the same between the source and destination systems, you will need to amend the ownership of the files you just extracted. For example, on an Apache system, you might need to enter the command |
− | < | + | <syntaxhighlight lang="php"> |
cd /path-to-joomla | cd /path-to-joomla | ||
chown -R www-group.www-user * | chown -R www-group.www-user * | ||
− | </ | + | </syntaxhighlight> |
− | ==Copy the Contents of Your Local MySQL Database to the Host MySQL Database== | + | === Copy the Contents of Your Local MySQL Database to the Host MySQL Database === |
− | In Joomla!, all the contents of the site (articles, menus, users, and so on) are stored in the | + | In Joomla!, all the contents of the site (articles, menus, users, and so on) are stored in the MySQL database. You need to copy this information to the host database. This is done by creating an export file on your local system and then importing this file into your host MySQL database, as follows: |
− | :::#Open phpMyAdmin on your local system by navigating to | + | :::#Open phpMyAdmin on your local system by navigating to its URL with your browser. On your local system, this URL will normally be ''//localhost/phpmyadmin''. Note: If you have a password on your database, you will be prompted for it. |
:::#The phpMyAdmin screen will display as shown below. Select the Export link. | :::#The phpMyAdmin screen will display as shown below. Select the Export link. | ||
[[Image:screenshotphpmyadmin_1.png|ScreenShot Phpmyadmin.]] | [[Image:screenshotphpmyadmin_1.png|ScreenShot Phpmyadmin.]] | ||
− | ::: | + | :::Select the database you want to export in the upper right-hand list. In the example below, the database ''joomla15'' is selected. Keep all the default options, including ''SQL'' as the export type. |
[[Image:screenshotphpmyadmin_2.png|ScreenShot Phpmyadmin.]] | [[Image:screenshotphpmyadmin_2.png|ScreenShot Phpmyadmin.]] | ||
− | ::: | + | :::Check the ''Save as file'' box at the bottom of the screen and enter the name of the export file, as shown below. |
[[Image:Screenshot_phpmyadmin3.png|ScreenShot Phpmyadmin.]] | [[Image:Screenshot_phpmyadmin3.png|ScreenShot Phpmyadmin.]] | ||
− | ::: | + | :::Press the ''Go'' button in the lower right corner. An ''Open/Save/Cancel'' dialog will display. Press ''Save'' and select a folder to save the file in. The export will complete and the file will be saved in the chosen location. |
− | :::#Open up the phpMyAdmin on the | + | :::#Open up the phpMyAdmin on the remote server. |
− | :::#Select the Import tab | + | :::#Select the ''Import'' tab. |
− | :::#Click the Browse button under | + | :::#Click the ''Browse'' button under ''File to import''. Then select the database file from your computer. |
− | :::#Click Go to import the database | + | :::#Click ''Go'' to import the database. |
At this point you have installed the database. | At this point you have installed the database. | ||
− | If you want to create a database copy, you can use | + | If you want to create a database copy, you can also use the MySQL command line method. |
− | Usually you run mysqldump to create a database copy: | + | Usually you run ''mysqldump'' to create a database copy: |
− | < | + | <syntaxhighlight lang="php"> |
$ mysqldump -u user -p db-name > db-name.out | $ mysqldump -u user -p db-name > db-name.out | ||
− | </ | + | </syntaxhighlight> |
Copy db-name.out file using sftp/ssh to remote MySQL server: | Copy db-name.out file using sftp/ssh to remote MySQL server: | ||
− | < | + | <syntaxhighlight lang="php"> |
$ scp db-name.out user@remote.box.com:/backup | $ scp db-name.out user@remote.box.com:/backup | ||
− | </ | + | </syntaxhighlight> |
− | + | ||
− | Restore database at remote server (login over | + | Restore the database at the remote server (login over SSH): |
− | < | + | <syntaxhighlight lang="php"> |
$ mysql -u user -p db-name < db-name.out | $ mysql -u user -p db-name < db-name.out | ||
− | </ | + | </syntaxhighlight> |
− | ==Configure the Site | + | === Configure the Site and Edit the ''configuration.php'' File === |
− | Manually edit | + | Manually edit ''configuration.php'' to tell Joomla! about your site. The file ''configuration.php'' contains settings specific to your system. This file was created for you when you installed Joomla! on your localhost. The settings in the ''configuration.php'' file that you typically need to change are shown below. This example is from a Windows XP localhost system. |
− | < | + | <syntaxhighlight lang="php"> |
var $log_path = 'C:\\xampp\\htdocs\\joomla15\\logs'; | var $log_path = 'C:\\xampp\\htdocs\\joomla15\\logs'; | ||
var $tmp_path = 'C:\\xampp\\htdocs\\joomla15\\tmp'; | var $tmp_path = 'C:\\xampp\\htdocs\\joomla15\\tmp'; | ||
Line 97: | Line 107: | ||
var $db = 'your_local_db_name'; | var $db = 'your_local_db_name'; | ||
var $password = 'your_local_db_password'; | var $password = 'your_local_db_password'; | ||
− | </ | + | </syntaxhighlight> |
− | Now | + | Now at your remote host system, the settings in the ''configuration.php'' file that you typically need to change are shown below: |
− | + | <syntaxhighlight lang="php"> | |
var $log_path = '/var/www/vhost/domain.com/home/html/logs'; | var $log_path = '/var/www/vhost/domain.com/home/html/logs'; | ||
var $tmp_path = '/var/www/vhost/domain.com/home/html/tmp'; | var $tmp_path = '/var/www/vhost/domain.com/home/html/tmp'; | ||
Line 109: | Line 119: | ||
var $db = 'your_db_name'; | var $db = 'your_db_name'; | ||
var $password = 'your_db_password'; | var $password = 'your_db_password'; | ||
− | </ | + | </syntaxhighlight> |
− | |||
− | |||
− | < | + | If you uploaded Joomla! files to a subdirectory, remember that you are working on subdirectory. The settings that you need will be: |
+ | |||
+ | <syntaxhighlight lang="php"> | ||
var $log_path = '/var/www/vhost/domain.com/subdirectory/html/logs'; | var $log_path = '/var/www/vhost/domain.com/subdirectory/html/logs'; | ||
var $tmp_path = '/var/www/vhost/domain.com/subdirectory/html/tmp'; | var $tmp_path = '/var/www/vhost/domain.com/subdirectory/html/tmp'; | ||
Line 121: | Line 131: | ||
var $db = 'your_db_name'; | var $db = 'your_db_name'; | ||
var $password = 'your_db_password'; | var $password = 'your_db_password'; | ||
− | </ | + | </syntaxhighlight> |
− | At this point, your Joomla! | + | At this point, your Joomla! website on your host should be operational with the same information as your localhost site. If you installed it on a subdirectory, navigate to that subdirectory to see or administer the site. |
− | <nowiki>http:// | + | <nowiki>http://mytest.domain.com/</nowiki> (for navigation to the site) |
− | <nowiki>http:// | + | <nowiki>http://mytest.domain.com/administrator</nowiki> (Login to the Joomla admin area with your user and password that you had at your localhost installation.) |
− | and if you installed it on root directory to see the site | + | and if you installed it on root directory, to see the site: |
− | <nowiki>http://www.domain.com/</nowiki> (for | + | <nowiki>http://www.domain.com/</nowiki> (for navigation to the site) |
<nowiki>http://www.domain.com/administrator</nowiki> (login to admin area) | <nowiki>http://www.domain.com/administrator</nowiki> (login to admin area) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
<noinclude>[[Category:Tutorials]] | <noinclude>[[Category:Tutorials]] | ||
− | [[Category:Installation]]</noinclude> | + | [[Category:Installation]] |
+ | [[Category:Update Working Group]] | ||
+ | </noinclude> | ||
+ | <noinclude>[[Category:Needs to be marked for translation]]</noinclude> |
Latest revision as of 10:32, 10 October 2022
When you are first trying out Joomla!, it is often recommended that you install it on your local system. localhost for example with XAMPP, and get your site running locally. Eventually you may want to copy this site to your remote host. Fortunately, this is easy to do.
This article assumes you have installed Joomla! on your local computer, you have created a website and you now wish to copy this website to your remote host.
Using Akeeba Backup to Move a Site (Preferred Method)[edit]
- Akeeba Backup produces a .jpa file.
- The .jpa file contains all the folders, files and the contents of the database.
- The .jpa file also contains an installer.
- The kickstart.php file from Akeeba unpacks the .jpa file.
- You then run the kickstart.php program and install your site.
- The installer has an option to change the configuration for restoring to a different location.
Akeeba Backup can be downloaded from Joomla extension directory. There is a link to full instructions there as well.
Alternate Method[edit]
Create a Place on Your Remote Host to Install Joomla![edit]
If this is a new site, it will just be your home directory. If you have an existing site, for example www.domain.com, that you wish to keep while you work with Joomla!, you may be able to create a subdomain, for example, mytest.domain.com to hold your Joomla! site.
Copy Files and Directories of Your Local Joomla Directory to the Remote Host[edit]
You have two methods:
- Upload all files by FTP
- Upload only a compressed file by FTP
Upload All Files by FTP[edit]
Normally, the easiest way to copy these files is using an FTP client program, such as Filezilla.
Select all files from the directory localhost. (With XAMPP, the directory will be /xampp/www/directory.) Upload to the remote host HTML directory for a domain or to the remote host HTML subdirectory.
Dir LocalHost | Upload to Html Root | Or Upload Sub. Html Root |
---|---|---|
Upload a Compressed File[edit]
Copying a large number of individual files using FTP can be unreliable. If you have command-line access to the both source and destination systems, you can create a compressed archive file containing all the files on the source system. Then transfer that single file to the destination system where it can be decompressed.
Creating an Archive File[edit]
On Unix-style systems such as Linux, you can use the Gzip program to create .zip files, or the Tar program to create .tar.gz or .tar.bz2 files. For detailed instructions, type man gzip or man tar at the command line. For example,
tar cvfz joomlabackup.tar.gz /path-to-joomla
will create a gzip-compressed archive file, called joomlabackup.tar.gz. It contains all the files in your Joomla! installation. Important note! You need to make sure you are not in the folder you are trying to backup when you run the tar command or you will create an endless loop.
Extracting an Archive File[edit]
Having copied the archive file to the destination system, you now need to unpack it. Use the equivalent command that you used to create the archive file. For example, to unpack the archive file created in the example above, enter
cd /path-to-joomla
tar xvfz joomlabackup.tar.gz
If the user or group IDs are not the same between the source and destination systems, you will need to amend the ownership of the files you just extracted. For example, on an Apache system, you might need to enter the command
cd /path-to-joomla
chown -R www-group.www-user *
Copy the Contents of Your Local MySQL Database to the Host MySQL Database[edit]
In Joomla!, all the contents of the site (articles, menus, users, and so on) are stored in the MySQL database. You need to copy this information to the host database. This is done by creating an export file on your local system and then importing this file into your host MySQL database, as follows:
- Open phpMyAdmin on your local system by navigating to its URL with your browser. On your local system, this URL will normally be //localhost/phpmyadmin. Note: If you have a password on your database, you will be prompted for it.
- The phpMyAdmin screen will display as shown below. Select the Export link.
- Select the database you want to export in the upper right-hand list. In the example below, the database joomla15 is selected. Keep all the default options, including SQL as the export type.
- Check the Save as file box at the bottom of the screen and enter the name of the export file, as shown below.
- Press the Go button in the lower right corner. An Open/Save/Cancel dialog will display. Press Save and select a folder to save the file in. The export will complete and the file will be saved in the chosen location.
- Open up the phpMyAdmin on the remote server.
- Select the Import tab.
- Click the Browse button under File to import. Then select the database file from your computer.
- Click Go to import the database.
- Press the Go button in the lower right corner. An Open/Save/Cancel dialog will display. Press Save and select a folder to save the file in. The export will complete and the file will be saved in the chosen location.
At this point you have installed the database.
If you want to create a database copy, you can also use the MySQL command line method. Usually you run mysqldump to create a database copy:
$ mysqldump -u user -p db-name > db-name.out
Copy db-name.out file using sftp/ssh to remote MySQL server:
$ scp db-name.out user@remote.box.com:/backup
Restore the database at the remote server (login over SSH):
$ mysql -u user -p db-name < db-name.out
Configure the Site and Edit the configuration.php File[edit]
Manually edit configuration.php to tell Joomla! about your site. The file configuration.php contains settings specific to your system. This file was created for you when you installed Joomla! on your localhost. The settings in the configuration.php file that you typically need to change are shown below. This example is from a Windows XP localhost system.
var $log_path = 'C:\\xampp\\htdocs\\joomla15\\logs';
var $tmp_path = 'C:\\xampp\\htdocs\\joomla15\\tmp';
var $live_site = '';
var $host = 'localhost';
var $user = 'root';
var $db = 'your_local_db_name';
var $password = 'your_local_db_password';
Now at your remote host system, the settings in the configuration.php file that you typically need to change are shown below:
var $log_path = '/var/www/vhost/domain.com/home/html/logs';
var $tmp_path = '/var/www/vhost/domain.com/home/html/tmp';
var $live_site = '';
var $host = 'name your remote host';
var $user = 'your_user_db_name';
var $db = 'your_db_name';
var $password = 'your_db_password';
If you uploaded Joomla! files to a subdirectory, remember that you are working on subdirectory. The settings that you need will be:
var $log_path = '/var/www/vhost/domain.com/subdirectory/html/logs';
var $tmp_path = '/var/www/vhost/domain.com/subdirectory/html/tmp';
var $live_site = '';
var $host = 'name your remote host';
var $user = 'your_user_db_name';
var $db = 'your_db_name';
var $password = 'your_db_password';
At this point, your Joomla! website on your host should be operational with the same information as your localhost site. If you installed it on a subdirectory, navigate to that subdirectory to see or administer the site.
http://mytest.domain.com/ (for navigation to the site)
http://mytest.domain.com/administrator (Login to the Joomla admin area with your user and password that you had at your localhost installation.)
and if you installed it on root directory, to see the site:
http://www.domain.com/ (for navigation to the site)
http://www.domain.com/administrator (login to admin area)