You’ve been working on a site on your local computer because it’s easier, but then you realized that everything needs to be transferred to hosting, and that’s where the problem arises. You thought it was just a simple copy-paste solution, but the problem is much bigger.
Especially for beginners, this may seem like too much of a procedure and complication, but it’s actually very simple with just a few clicks.
First of all, let’s list what’s needed (assuming this is a WordPress site).
So, we have the site files, which include wp-content, wp-admin, wp-include, and similar…
Then we have the database that you created in phpMyAdmin.
First, let’s locate the files.
If you are using XAMPP, your site files are located in: C:/xampp/htdocs
If you are using WAMP, your site files are located in: C:/wamp/www
Once you have all the files, select them all, right-click and zip them (using 7zip or WinRAR).
Now you have the zipped file, it’s best to copy-paste it to the desktop for easier access. Let’s say we named the zip file “mysite.zip”.
Export baze
Now it’s time for the database. Where is the database?
Open phpMyAdmin, usually at the link http://localhost/phpmyadmin
When you open it, on the left side you have some databases and your database that you created; in our case, it’s “TEST”.
Click on your database and then in the top right corner click “Export” as shown in the picture:
That’s all for exporting or backing up the database. This way, you also create a backup of the database in case something goes wrong, so you can restore the database and everything will be okay.
Now we have the “test.sql” file, which we probably saved on the desktop. But to reduce the file size, we need to zip it.
Right-click on the file and find the option “Add to archive…” This option exists for both WinRAR and 7zip. In WinRAR, it’s immediately to the right, and in 7zip, it’s a sub-option.
You will be prompted to save it as “test.zip”, but change it to “test.sql.zip” as in the example above. Only then will it work, otherwise, it will report an invalid file.
After zipping the database correctly and zipping the files correctly, all that remains is to transfer everything to the hosting account.
Transferring site files to hosting
Transferring files via FTP server to hosting:
First, download an FTP program (WinSCP recommended)
Configure it as shown in the picture:
FTP, No encryption, Hostname should be ftp.site.com (replace site.com with your domain), don’t touch the port, UserName and Password should be the credentials you received in the email when your hosting account was activated, then click login.
Next, upload all the files or the file to our hosting account in the public_html folder (or, if it’s an Addon Domain, in that domain’s folder).
On the left side, select where your site files are, as mentioned at the beginning:
If you are using XAMPP, your site files are located in: C:/xampp/htdocs
If you are using WAMP, your site files are located in: C:/wamp/www
We have zip file if we did that or a list of files. You can transfer only one such file and then unpack it later or transfer all files at once.
On the right side, open the public_html folder (or if it is an Addon Domain, then in that domain folder), and on the left side, have your files. Select all files and go to upload or click and hold and drag to the right side.
Once the upload is finished, the next step follows.
We have finished uploading all files, and now in public_html (or if it is an Addon domain, then in that domain folder), we have wp-content, wp-admin, and so on.
The next thing to do is to log in to cPanel (link, username, and password you received in the activation email for hosting).
Creating a database
Go to MySQL Database Wizard in cPanel. The first item is “Step 1: Create A Database”. Enter the name of the database, for example, sajtweb, and the first part will be cpanelusername_sajtweb. Then click “Next Step”.
Step 2: Create Database User, in this step we create a user for the database. Here we can insert sajtkor, and it will be cpanelusername_sajtkor, then the crucial part is the password, which we create using a password generator. We recommend using a password generator because if you put admin1234, you risk the site being infected or hacked, so always use a password generator. Once we have added the password, go to “Create User”.
Step 3: Add user to database, click on ALL PRIVILEGES, and then click “Next Step”. We have finished this part of the work on creating the database.
90% is done, and now we need to upload the database and edit the config file.
After creating the database, go back to the cPanel home page, click on phpMyAdmin, and when a new window opens, you will notice that it is the same as on your computer. Then click again on this new database we created, which is cpanelusername_sajtweb. After clicking on it, on the right side, go to “Import” as we went to export, now it’s import. The following window will appear, and in the first step, choose the file we created, if you remember and zipped it, that is test.sql.zip. The next step is to click the “Go” button, wait a bit, and the upload and setup of the database are done.
After completing this, on the left side, click on wp_options, and on the right side, you will see as in the picture:
in this part, we go to double click where it says “http://localhost/wp” or something similar for you, but it definitely says localhost, replace it with your domain in the format: “http://hostgistic.com/” put this for both “siteurl” and “home”, after entering, click anywhere else, and it will save automatically.
There is only 1 step left, which is editing the config file.
Connecting the site to the database
We are back on the cPanel home page, go to File Manager, click on public_html (or if it is an Addon Domain, then in that domain folder), and you will see all the files we uploaded (I assume the upload is done at this moment). Click on wp-config.php and go to “Edit”.
When a new window opens with this file in the fields:
/** The name of the database for WordPress */
define(‘DB_NAME’, ‘prefiks_wpbaza’);
/** MySQL database username */
define(‘DB_USER’, ‘prefiks_wpuser’);
/** MySQL database password */
define(‘DB_PASSWORD’, ‘admin1234’);
/** MySQL hostname */
define(‘DB_HOST’, ‘localhost’);
Instead of prefix_wpbaza, enter the database we created, cpanelusername_sajtbaza
Instead of prefix_wpuser, enter the user we created, cpanelusername_sajtkor
Instead of admin1234, enter the password we created using a password generator
When all of this is done, click save in the upper right corner.
Once everything is finished, we can open the site in the browser, and it should work.
If you encounter error number 500, you probably did not insert the .htaccess file into public_html (or if it is an Addon Domain, then in that domain folder). Insert it or follow the step when we modified the wp_options siteurl and home in the database. If you have done both of these steps, there should be no problems.
Anyway, we are here every day from 9 am to midnight, so you can contact us with any problem.