Actions

Difference between revisions of "Copying a website from localhost to a remote host"

From Joomla! Documentation

(new faq)
m (Using Akeeba backup to move a site: clean up categories with <noinclude> tags)
 
(20 intermediate revisions by 8 users not shown)
Line 1: Line 1:
When you are first trying out Joomla!, it is often recommended that you install it on your local system (e.g., "localhost"), for example with XAMPP, and get your site running locally. In this case, you may do enough work on your local Joomla! site that you want to copy this site to your remote host. Fortunately, this is very easy to do.  
+
When you are first trying out Joomla!, it is often recommended that you install it on your local system. (e.g., "localhost"), for example with [http://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! 1.5 on your local computer, you have created a website, and you now wish to copy this website to your remote host. Here are the steps:
+
This article assumes you have installed Joomla! 1.5 on your local computer, you have created a website and you now wish to copy this website to your remote host.
  
# 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 that you wish to keep while you work with Joomla!, you may be able to create a subdomain to hold your Joomla! site. Make sure you note the subdomain name for later. The details of creating a subdomain will vary by host, so you will need to check with your host on this.
+
Here are the steps:
# Next you need to put Joomla! on the remote host. There are three options (just pick one):
+
 
##Install Joomla! on your host site. If you have not customized Joomla! in any way (for example, installed any extensions, changed the template, or created any template overrides), often the simplest thing is just to install Joomla! on the remote host. Many host companies provide scripts that make installing Joomla! very easy.
+
==Create a Place on Your Remote Host to Install Joomla!==
##Copy all of your Joomla! files and folders from your localhost Joomla! folder to the remote host Joomla! folder and manually edit the "configuration.php" file. If you have customized Joomla! by installing extensions, modifying the template, adding template overrides, and so on, then it may be easier just to copy the Joomla! files from the local host to the remote host than to re-do your customizations. The file "configuration.php" is the only file that contains settings specific to your system. So this file must be edited to match the host system.  
+
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, www.domain.com/subdirectory to hold your Joomla! site.
 +
 
 +
==Copy Files and Directories of Your Local Joomla Directory to the Remote Host==
 +
You have two methods:
 +
#Upload all files by FTP or
 +
#Upload only a compressed file by FTP
 +
 
 +
===Upload all Files by FTP===
 +
Normally, the easiest way to copy these files is using an FTP client program, such as [http://filezilla-project.org/ Filezilla].
 +
 
 +
Select all files from directory localhost (with XAMPP, the directory will be xampp/www/directory) and upload to the remote host HTML directory for a domain, or to the remote host HTML subdirectory.
 +
 
 +
{| class="wikitable"
 +
|+ Select Dir Host and Upload to remote host or subdirectory remote host
 +
! Dir LocalHost !! Upload to Html Root !! Or Upload Sub. Html Root
 +
|-
 +
| [[Image:Filezilladircopy.png|Select Dir.]] || [[Image:Filezilladirectory.png|Dir Filezilla.]] || [[Image:Filezillasubdirectory.png|Subdir Filezilla.]]
 +
|-
 +
 
 +
|}
 +
 
 +
===Upload a Compressed File===
 +
Copying a large number of individual files using FTP can sometimes 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 (eg. Linux) you can use the [http://www.gnu.org/software/gzip/ gzip program] to create .zip files, or the [http://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,
 +
<source lang="php">
 +
tar cvfz joomlabackup.tar.gz /path-to-joomla
 +
</source>
 +
 
 +
will create a gzip-compressed archive file, called joomlabackup.tar.gz, containing 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'''
 +
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
 +
   
 +
<source lang="php">
 +
cd /path-to-joomla
 +
tar xvfz joomlabackup.tar.gz
 +
</source>
 +
If the user or group IDs are not the same between the source and destination systems, then 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
 +
 
 +
<source lang="php">
 +
cd /path-to-joomla
 +
chown -R www-group.www-user *
 +
</source>
 +
 
 +
==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 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 it's 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.
 +
[[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 of the default options, including "SQL" as the export type.
 +
[[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.]]
 +
:::#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 host 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
 +
 
 +
At this point you have installed the database.
 +
 
 +
If you want to create a database copy, you can use also the MYSQL command line method.
 +
Usually you run mysqldump to create a database copy:
 +
<source lang="php">
 +
$ mysqldump -u user -p db-name > db-name.out
 +
</source>
 +
 
 +
Copy db-name.out file using sftp/ssh to remote MySQL server:
 +
<source lang="php">
 +
$ scp db-name.out user@remote.box.com:/backup
 +
</source>
 +
       
 +
Restore database at remote server (login over ssh):
 +
<source lang="php">
 +
$ mysql -u user -p db-name < db-name.out
 +
</source>
 +
 
 +
==Configure the Site. Edit the configuration.php File==
 +
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.
  
 
<source lang="php">
 
<source lang="php">
Line 17: Line 98:
 
var $password = 'your_local_db_password';
 
var $password = 'your_local_db_password';
 
</source>
 
</source>
 +
 +
Now, at you remote host system, the settings in the ''configuration.php'' file that you typically need to change are shown below
 +
 +
<source lang="php">
 +
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';
 +
</source>
 +
 
 +
If you uploaded Joomla! files to a subdirectory, remember that you are working on subdirectory, and the settings that you need, will be,
  
 
<source lang="php">
 
<source lang="php">
var $log_path = '/yourhome/test/logs';
+
var $log_path = '/var/www/vhost/domain.com/subdirectory/html/logs';
var $tmp_path = '/yourhome/test/tmp';
+
var $tmp_path = '/var/www/vhost/domain.com/subdirectory/html/tmp';
var $live_site = 'http://www.yoursite.com';
+
var $live_site = '';
var $host = 'your_host_mysql_db_name';
+
var $host = 'name your remote host';
var $user = 'your_mysql_user_name';
+
var $user = 'your_user_db_name';
var $db = 'groundswellnw_org_testdb';
+
var $db = 'your_db_name';
 
var $password = 'your_db_password';
 
var $password = 'your_db_password';
 
</source>
 
</source>
 +
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://www.domain.com/subdirectory</nowiki> (for navigatation to the site)
 +
 +
<nowiki>http://www.domain.com/subdirectory/administrator</nowiki> (login to the Joomla admin area with your user and password that your had at your localhost installed)
 +
 +
and if you installed it on root directory to see the site
 +
 +
<nowiki>http://www.domain.com/</nowiki> (for navigatation to the site)
 +
 +
<nowiki>http://www.domain.com/administrator</nowiki> (login to admin area)
 +
 +
== Using Akeeba backup to move a site ==
 +
 +
* Akeeba Backup produces a .jpa file
 +
 +
* The .jpa file contains all the folders/files and database files.
 +
 +
* The .jpa file also contains an installer
 +
 +
* Kickstart.php (from Akeeba) unpacks the .jpa file
 +
 +
* You then run the installer and install your site like a Joomla install.
 +
 +
* The installer has an option to change the configuration for restoring to a different location
  
Install Joomla! in the desired DreamHost directory. See [[Joomla!#Install Joomla!|Install Joomla!]] for detailed instructions. You do not need to install the Joomla! example website. ''Note: During the Joomla! installation, you created the following MySQL parameters: database name, host name, user name, and user password. Make sure to keep a record of these, since you will need them later in this process.'' At this point, you have a local Joomla! 1.5 installation and an empty Joomla! installation in your DreamHost folder.
+
After you create the Database for your Joomla download and install Akeeba, it can be download from [http://extensions.joomla.org/extensions/access-a-security/site-security/backup/1606 Joomla extension directory]. There is a link to full instructions there as well.
# Copy the required files from your local Joomla! folder to your DreamHost folder. Note that Joomla! content is stored in the MySQL database, which will be transferred in a later step.
+
## If you have not added or modified any Joomla! templates, extensions, or CSS files on your local system, you will only need to copy the images folder (assuming you added images) and any other files you have added or changed since you installed Joomla!.
+
## If you have added extensions or templates or modified one or more CSS files (or if you are not sure), then you can safely copy all of the Joomla! 1.5 files '''except for the configuration.php''' file. You want to keep the DreamHost configuration.php file and not overwrite this file with your local copy.
+
# Next, you need to copy the contents of your local MySQL database to the DreamHost MySQL database. This is done by creating an export file locally, copying the export file to the DreamHost server, and then importing the file into your DreamHost MySQL dabase, as follows:
+
## Open phpMyAdmin on your local system by navigating to it's 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.[[Image:screenshot_phpmyadmin1.png|frame|center]]
+
## Select the database you want to export in the upper right-hand list. In the example below, the database "joomla15" is selected. Keep all of the default options, including "SQL" as the export type.[[Image:screenshot_phpmyadmin2.png|frame|center]]
+
## 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|frame|center]]
+
## 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.
+
## Copy the export file to a folder on the DreamHost server, for example using FTP.
+
## Open up the phpMyAdmin on the DreamHost server. To do this, open your browser and navigate to the URL "http://" followed by the MySQL host name you named when you installed Joomla!. For example, if your MySQL host name is "mydatabase.joomla15.mywebsite.com", the URL for phpMyAdmin would be http://mydatabase.joomla15.mywebsite.com. You will be prompted to enter your MySQL user name and password that you created when you installed Joomla!.
+
## At this point, you need to import the contents of the export file created above. Before you can do that, however, all of the data from the existing Joomla! database must be deleted. An easy way to do that is to select the MySQL database for Joomla! from the drop-down list box in the upper left, as shown below.[[Image:screenshot_phpmyadmin4.png|frame|center]]
+
## The list of tables in the selected database will display. We want to delete all of these tables, since the Import will re-create them. Scroll down to the bottom of the list and select the "Check All" link. This will select all tables in the list. Then, in the drop-down list to the right of the Check All link, select "Drop", as shown below.[[Image:screenshot_phpmyadmin5.png|frame|center]]
+
## You will be asked to confirm that you really want to do this (since you are in effect deleting the entire database). Press Yes and you should get a message indicating that the query was successful.
+
## With the database still selected, press the Import Link at the top of the screen and browse to the location in your DreamHost folder where the .SQL export file was uploaded. Press Open to select the file and then press Go (lower left corner) to start the import. Again, you should get a message indicating that the query was successful.
+
  
Congratulations! At this point, your Joomla! website on DreamHost should be operational with the exact same information as your localhost site. If you installed it on a DreamHost subdomain, navigate to that subdomain to see or administer the site. For example, if your subdomain was named "mysubdomain", then navigating to http://www.mysubdomain.mywebsite.com should bring up your home page and http://www.mysubdomain.mywebsite.com/administer should bring up the login to the Joomla! admin area.
+
<noinclude>[[Category:Tutorials]]
 +
[[Category:Installation]]</noinclude>

Latest revision as of 15:34, 1 September 2012

When you are first trying out Joomla!, it is often recommended that you install it on your local system. (e.g., "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! 1.5 on your local computer, you have created a website and you now wish to copy this website to your remote host.

Here are the steps:

Contents

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, www.domain.com/subdirectory to hold your Joomla! site.

Copy Files and Directories of Your Local Joomla Directory to the Remote Host

You have two methods:

  1. Upload all files by FTP or
  2. Upload only a compressed file by FTP

Upload all Files by FTP

Normally, the easiest way to copy these files is using an FTP client program, such as Filezilla.

Select all files from directory localhost (with XAMPP, the directory will be xampp/www/directory) and upload to the remote host HTML directory for a domain, or to the remote host HTML subdirectory.

Select Dir Host and Upload to remote host or subdirectory remote host
Dir LocalHost Upload to Html Root Or Upload Sub. Html Root
Select Dir. Dir Filezilla. Subdir Filezilla.

Upload a Compressed File

Copying a large number of individual files using FTP can sometimes 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 (eg. 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, containing 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

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, then 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

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:

  1. Open phpMyAdmin on your local system by navigating to it's 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.
  2. The phpMyAdmin screen will display as shown below. Select the Export link.

ScreenShot Phpmyadmin.

  1. Select the database you want to export in the upper right-hand list. In the example below, the database "joomla15" is selected. Keep all of the default options, including "SQL" as the export type.

ScreenShot Phpmyadmin.

  1. Check the "Save as file" box at the bottom of the screen, and enter the name of the export file, as shown below. .

ScreenShot Phpmyadmin.

  1. 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.
  2. Open up the phpMyAdmin on the host server.
  3. Select the Import tab
  4. Click the Browse button under "File to import", then select the database file from your computer
  5. Click Go to import the database

At this point you have installed the database.

If you want to create a database copy, you can use also 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 database at remote server (login over ssh):

$ mysql -u user -p db-name < db-name.out

Configure the Site. Edit the configuration.php File

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 you 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, and 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://www.domain.com/subdirectory (for navigatation to the site)

http://www.domain.com/subdirectory/administrator (login to the Joomla admin area with your user and password that your had at your localhost installed)

and if you installed it on root directory to see the site

http://www.domain.com/ (for navigatation to the site)

http://www.domain.com/administrator (login to admin area)

Using Akeeba backup to move a site

  • Akeeba Backup produces a .jpa file
  • The .jpa file contains all the folders/files and database files.
  • The .jpa file also contains an installer
  • Kickstart.php (from Akeeba) unpacks the .jpa file
  • You then run the installer and install your site like a Joomla install.
  • The installer has an option to change the configuration for restoring to a different location

After you create the Database for your Joomla download and install Akeeba, it can be download from Joomla extension directory. There is a link to full instructions there as well.