PHP / MySQL - Move from localhost to an online hosting

0

I created a website with PHP and a MySQL database using XAMPP. Now I would like to have the site online on a host, do I have to change the connection to the database where it says localhost?

What procedures do I have to do?

    
asked by anonymous 26.11.2017 / 14:16

2 answers

1

There are many procedures to follow which I will list in a general way, and may vary from case to case. If you do not feel safe, we recommend that you ask for a technician or someone experienced.

1. Domain name

Choose a domain name for your site (eg, myite.com). Choose a shortest possible name that has to do with the purpose of the site, as it will be an "identity" of the site.

If you would like a Brazilian domain (eg, com.br), enter the register.br and register your domain, because there is usually cheaper than hosting sites, except when they give you free domain registration when you book a hosting. This can vary greatly from company to company.

If you want to register a foreign domain (eg .com), you can do so directly from the hosting company if you have such a service.

  

It may take a few hours for the domain to take effect after   registration.

2. Hosting

Hire a hosting that will meet your demand (if the PHP version you use is supported, the database you use, comfortable traffic limit, enough storage space, etc.). They will inform you the FTP access data (server, username and password) which will be the means for you to send the files to the server.

If you have registered the domain in the registry.br, you will need to enter in the registration panel.br the DNS servers of your hosting, so that the domain points there (the DNS servers you can find in the hosting support) .

3. Creating the database and sending the files

Create the database on the hosting server and migrate the tables there. Hosts usually have an administrative dashboard (eg phpMyAdmin, Control Panel, etc.) where you can administer the database. Change in your PHP database connection file the host, user and password according to the remote database.

Use an FTP client program to send the files to the server. I recommend using Filezilla , which has an interface similar to the Windows file manager, just drag the files to the remote folder, which is usually called "public_html /" on the server.

4. Finishing

After all these steps: registered domain, created database and uploaded files, test by opening the site in the browser to see if everything is working.

These are the basic procedures. As said at the beginning, it may vary from case to case.

    
26.11.2017 / 17:30
0

First you need to hire a host. Once it has been hired then you will need to pick up your site files and upload it to the hosting storage (this is usually done via FTP if you do not use Git).

Remember to never never put passwords and users inside your code. They are environment-related, most hosts support passing environment variables, otherwise, you can create a file with the .ini extension and use the parse_ini_file function of PHP to bring your database data. p>

From there, you build a base on the hosting and point it out.

    
26.11.2017 / 16:08