So you have created a beautiful looking website and you to want to host it on a web server. And you are wondering how to host PHP websites. Well, today I am gonna walk you through the process of hosting a PHP website for free.
Firstly, you should have a few different things ready to be able to host your site-
1. Your website files(eg. yourWebsite.zip, containing all your website files) – This is basically a zip file or a folder containing all your website files.
2. A hosting service account – A hosting service will provide you servers where you will host your website. You can buy one or check these Best Free Web Hosting Websites.
3. A domain – a name for your website. You can buy one or grab a free domain here. Note some free hosting services provide a free subdomain which eliminates the use of a separate domain. But you can still use it if you want to.
4. A computer with an internet connection.
In case you are wondering how to host WordPress. Here’s a guide for Hosting/Installing WordPress on Server and Localhost.
Now once you have all these things setup, we are ready for the hosting process. Hosting a PHP website has basically three parts – uploading website files, creating a database and adding database user and lastly, updating database user details accordingly in code files.
Follow the below steps to host your website:
- Adding domain and updating nameservers
1. First, log in to your hosting account. Then you will get your dashboard (a Cpanel). Cpanel provides you some tools for managing your website.
2. If your hosting service does not provide a free subdomain or you still want to use a custom domain. Then under Domains section in Cpanel Add Your Domain there.
3. Update the NameServers of your domain. By visiting your domain control panel. Updating the name servers is very important this way your domain will be mapped with the server’s IP address. For example, Nameservers are like NS1.example.com NS2.example.com as shown in the picture above.
** Updating Nameservers might take up to 72 hours for DNS propagation.
- Uploading website files to the server
4. Navigate to Online File Manager under the Files section in your Cpanel. This will open up the file manager. Then go to the /htdocs or /public_html or /www directory of your server and upload yourWesbite.zip file and extract it.
In case your website size is large and you can’t upload it via File Manager, try to upload it via FTP. Using FTP clients like FileZilla, SmartFTP, etc. You can find FTP details under the Account Details section.
Now your website files are uploaded and if your website is static and does not use a database you are done. Just visit your domain after successfully updating the Nameservers. And no need to follow the below steps.
- Creating a database and connecting it with the website
5. Navigate to phpMyAdmin under the Databases section in your Cpanel. PhpMyAdmin is basically a tool for creating, deleting, updating, importing, exporting and managing databases.
6. Create a new Database under phpMyAdmin and give it a name. And add a user to the database make sure to remember the username and the password. Also, import the database if you have any backup of it. Otherwise, create tables accordingly or leave it empty if you want to.
7. Update the Name, UserName and the Password of the database you created in your code files accordingly.
Congrats, you have successfully completed hosting your first PHP website. Did you like the guide? Please leave feedback under the comment section below. In case you are facing any error while following the steps feel free to contact us, we will be happy to help you. Cheers!!