You have developed a Laravel Web Application and now want to upload it on Shared Hosting/Cpanel? There are various sources that guide you how to do it but in this blog I am going to show you the simplest and easiest way to upload your awesome application to the internet.
Note: I will use namecheap hosting for this blog.
- Buy domain name and hosting
- Login to Cpanel with valid credentials
Before moving any further make sure you have made a backup of original source code of your application. After that follow these steps:
In your Cpanel dashboard home page click Databases-> MySQL Database Wizard. Write the name of database for your application. Following image shows that db name will have “cpanelusername_” by default and you have to attach any string you want to the db name. I prefer “db” or “database”. After writing your desired string click “Next Step” button.
In this step you have to create a user for the created database. Write the username which will have “cpanelusername_” as default prefix and the string you write in username field will be attached after the prefix. Then fill in “Password” and “Password (Again)” with password you like or you can click on “Generate Password” button which will open a pop up. Copy the password at a safe place and check the checkbox on pop up. Click “Use Password” and it will populate password fields with strong password that you saved. After that click “Create User”
In this step check the “All Privileges” checkbox and click “Next Step”
Open your local phpmyadmin (localhost/phpmyadmin). Select your project db and click on “Export”. This will open a screen. Scroll down and click “Export”. A file will get downloaded.
In your Cpanel dashboard home go to Databases->phpMyAdmin. Click on “Import”. This will open a screen. Browse the file that you exported in previous step and click “Import” on the bottom of screen.
Make zip file of complete project folder on local. Click on “File Manager” on Cpanel dashboard. In the root directory (same directory where public_html resides) create a folder and name it whatever you like (lets say portfolio) and then go to that folder. Click “Upload” and a screen will open up where you will browse the zip file of your project and then click upload. After completing the upload go to the folder where you uploaded the file. In my case it is portfolio folder.
Extract the contents of zip file in same directory and delete the zip file. Open the project folder and move all the content to portfolio and then remove the project folder (which is now empty) from portfolio. Then move the contents of portfolio/public to public_html.
In public_html right click on index.php file and click “Edit”. Change the following lines of code:
After that just save the file.
Edit .env file located in folder(in my case it is portfolio) that was created in root. Update the following db details according to live database and save the changes.
Create new file named symlink_create.php in public_html then edit it and write the following code in it and save it.
Then open this file in browser like domainname.com/symlink_create.php and a blank page will open up. Now the storage folder symlink has been created. After that delete the file from public_html.
And your web app has been successfully uploaded to internet. You can check this by opening it in your browser with domain name.
If there are any issues in your uploading process or you need any assistance than feel free to contact me