# Move a local WordPress site to your hosting
Source: https://docs.webgee.com/en/hosting/wordpress/deploy-local-wordpress-setup-into-your-cpanel-account



Move a WordPress site you built locally onto your WebGee hosting. Applies to
shared, reseller and Premium hosting.

Four things have to move: the files, the database, the database credentials in
`wp-config.php`, and the site URL stored inside the database. Missing the last
one is the usual reason a migrated site loads a broken page.

## Before you begin [#before-you-begin]

From your local site, take:

* A copy of the **whole WordPress directory** — including `wp-content`, which
  holds your themes, plugins and uploads.
* A **database export** as `.sql`. Most local tools export this from
  phpMyAdmin, Adminer or their own interface.

Also note the **local URL** the site currently uses, such as
`http://localhost:8888` or `http://mysite.test`. You need it for step 5.

## 1. Add the domain [#1-add-the-domain]

In cPanel, open **Domains** and add the domain or subdomain you want the site to
live on. Note the **document root** it creates — usually `public_html` for the
main domain.

## 2. Create the database [#2-create-the-database]

1. In cPanel, open **MySQL Databases**.
2. Create a database.
3. Create a user, with a generated password.
4. Under **Add User To Database**, add the user to the database and grant
   **All Privileges**.

Keep the database name, username and password — you need all three in step 4.
Both names are prefixed with your cPanel username.

## 3. Upload the files [#3-upload-the-files]

Upload the contents of your WordPress directory into the document root, using
**File Manager** or FTP — see
[Upload files with FileZilla](/en/hosting/using-filezilla-to-upload-files-via-sftp-ssh-or-ftps-ssl-tls).

<Callout type="info">
  Upload the **contents** of the WordPress folder, not the folder itself. If you
  end up with `public_html/wordpress/wp-config.php`, your site will be at
  `example.com/wordpress` rather than `example.com`.
</Callout>

A zip uploaded and extracted through File Manager is far faster than
transferring thousands of small files over FTP.

## 4. Import the database [#4-import-the-database]

1. In cPanel, open **phpMyAdmin**.
2. Select your new database in the left sidebar.
3. Select **Import**, choose your `.sql` file, and select **Go**.

If the file is too large to upload, see
[Import a large database](/en/databases/how-to-import-a-large-database-into-mysql).

## 5. Update wp-config.php [#5-update-wp-configphp]

Edit `wp-config.php` in the document root and set your new credentials:

```php
define( 'DB_NAME', 'cpaneluser_wordpress' );
define( 'DB_USER', 'cpaneluser_wpuser' );
define( 'DB_PASSWORD', 'your-database-password' );
define( 'DB_HOST', 'localhost' );
```

`DB_HOST` stays `localhost` — the database runs on the same server as the site.

## 6. Replace the local URL in the database [#6-replace-the-local-url-in-the-database]

This is the step people miss. WordPress stores its own address in the database,
so the site will keep referring to `localhost` and load without styling, or
redirect you back to your own machine.

In phpMyAdmin, select your database, open the **SQL** tab and run:

```sql
UPDATE wp_options SET option_value = 'https://example.com'
  WHERE option_name IN ('siteurl', 'home');
```

<Callout type="warn">
  Change `wp_` if your site uses a different table prefix — check the
  `$table_prefix` line in `wp-config.php`.
</Callout>

That fixes the site address. Local URLs are usually also embedded in post
content, widgets and theme settings. The
[Better Search Replace](https://wordpress.org/plugins/better-search-replace/)
plugin handles those safely, including inside serialised data, which a plain SQL
find-and-replace will corrupt.

## Check it worked [#check-it-worked]

Visit `https://example.com`. The site should load with its styling intact. Sign
in at `/wp-admin` and check that images in existing posts display.

## If something is wrong [#if-something-is-wrong]

* **"Error establishing a database connection"** — the credentials in
  `wp-config.php` are wrong, or the user was not added to the database in step 2.
* **The page loads with no styling** — step 6 was skipped, or `wp_` was the
  wrong prefix.
* **You are redirected to `localhost`** — same cause.
* **Images are missing from posts** — their URLs still point at the local site.
  Run Better Search Replace.

## Related [#related]

* [Migrate a WordPress site from another host](/en/hosting/wordpress/migrating-a-wordpress-site-from-another-host-using-softaculous-remote-import)
* [Import a large database](/en/databases/how-to-import-a-large-database-into-mysql)
* [Reset your WordPress admin password](/en/hosting/wordpress/resetting-your-wordpress-admin-password-a-comprehensive-guide)
