Currently, as we know, Laravel is one of the most famous PHP frameworks. Therefore, now we will discuss how to upload Laravel files to hosting on Biznet Gio, especially for NEO Web Hosting (NWH) users.
Guide on how to upload Laravel to web hosting. Follow the step by step guide to start your project. Did you know that there is one of the next steps you need to take after you've finished developing a website in Laravel? So, what is it? Well, that step is to upload it to the hosting.
Why is it mandatory for you to upload Laravel to hosting? Of course, this is not without reason. But one of the main goals is that the website that you have created can be accessed online by internet users.
Maybe, for some people or beginners how to upload Laravel to hosting looks difficult to do. However, the method is actually quite easy to do even for beginners. So, you don't need to hesitate or worry about not being able to do it.
How to Upload Laravel to Hosting
Actually, there are two ways you can try to upload Laravel to hosting, namely by combining the public folder with the Laravel folder, or separating the two folders. Well, the easiest way is through the first method.
At first, there are a few things you need to prepare to get started with Laravel hosting. These include starting from network access to cPanel hosting, hosting that supports Laravel, as well as the Laravel files themselves. When everything is complete, just follow the following method!
Prepare the following things, namely:
a. cPanel Hosting Account
In order to be able to upload your Laravel files to hosting, you need a cPanel hosting account first. Only then can your Laravel files be uploaded to the main domain or to its subdomains.
b. Internet Network Access
Of course, you need internet network access. Because, this step cannot be done without an internet network connection.
c. Laravel Website Files
To upload your Laravel files to hosting, you also need to prepare Laravel-based website files in zip format. The goal is to facilitate the upload process.
Now, after you have prepared all of the above, the next step is to upload Laravel to hosting. how do? Immediately, here's how to upload Laravel to hosting!
1. Route to Laravel Folder
Note that Laravel goes directly into the root folder so it doesn't access its public folder which it needs. Therefore, it is necessary to create a route so that when accessing the domain, access will be directed directly to the index.php file in the folder.
To do this, follow the steps below:
- Step 1: create an index.php file in the Laravel root folder. first of all make a file type index.txt then edit the .txt file and fill it with the script file index.txt.
- Step 2: After that, save and change the file format to .PHP. Next, change the file format again to index.txt to .php.
Well, this one method is one way that you can use. Another way to do Laravel hosting is by modifying the .htaccess file in the Laravel root folder on the hosting.
2. Compress All Laravel Files
The next step is to collect all Laravel files into one by compressing these files. The goal is for it to be extractable on cPanel, then select the file extension to .zip.
3. Access the cPanel Hosting Page
The next method is to log in to the cPanel page. Here, you can open the cPanel page according to the URL provided when registering with your hosting service.
After you register an account with cPanel, you can also log in to the cPanel hosting page via the members area. Next, select the intended website account to manage it.
4. Upload Laravel Files to Hosting
For this step, you will use the main folder, namely public_html, so that the .zip file from the local folder is uploaded to the public folder. So, here you can upload the .zip file to public_html or another folder. However, make sure you upload it to the folder that will be used to access the Laravel file. Now, after accessing the folder, click the "Upload" feature to upload the Laravel file to hosting.
The way to do this is by selecting and uploading a file to public_html. Then click "Select File" and select the Laravel file in .zip format.
Wait until the process of uploading your Laravel files to hosting has finished uploading. When the .zip file has finished uploading, right click on the file then select the "Extract" option.
5. Laravel Upload Results Test
So, the final step after you upload the Laravel file to hosting, is to test the results of uploading the Laravel file. The method is very easy, namely by entering the access domain or subdomain where the Laravel files are stored.
If the file has been uploaded successfully and there are no problems, then your Laravel file can be accessed online. Finished! Thus, you have successfully uploaded the Laravel file to hosting.
After successfully uploading your Laravel file to hosting, it's also a good idea to know how to upload the database table. Who knows, maybe you will have to participate in uploading files in the form of the required database tables. So, the steps themselves are as follows!
How to Upload Laravel Database Tables
You can follow the steps below to upload a Laravel database table:
- Step 1: Create a new database on your cPanel page. Well, you can prepare it first then upload it.
- Step 2: Export your Laravel project database which is located on your local computer/PC. In this step, the export method is via the console.
- Step 3: Open phpmyadmin on your cPanel page, then go to the database you created earlier. Only after that click the "Import" option, then browse to the SQL file that you have created. Then click "Go" and wait until the "Success Notification" appears.
- Step 4: You need to edit database.php in the “File Manager” menu on the cPanel page. After that, edit the projectname/config/database.php file until finished.
- Step 5: Change the database, user and password sections according to the user and password you created in the first step. When finished, immediately click the "Save Changes" option.
- Step 6: Edit the .env file by reopening the File Manager menu then edit the .env file which is in the root directory. Then, change the database, user and password sections according to the data you have changed.
If you have done all the steps, click "Save Changes" and you're done! So, after that you can try to access Laravel again which has been uploaded via the database you just created.
Now Upload Laravel to Hosting!
How, isn't it very easy to upload Laravel to hosting?! So, up to this point you have followed the step by step to completion. So, of course, by following the steps above, your website or application will run smoothly on your hosting server.
If you have made a configuration and uploaded a Laravel file, you can check whether the Laravel file upload was successful or not by accessing the main domain or subdomain in a web browser. Hope this article helps you..!!