How to upload laravel app to shared hosting

Please follow these steps:

  • Create a subdomian name test.pharmabazaar.co
  • After successfully domain added in cPanel go to Filemanager->
    public_html and find a folder name test.pharmabazaar.co (Do Not Create
    it Manually). If you don’t find it delete the subdomain from cPanel and
    create the domain again.
  • Now from  cPanel find Let’s Encrypt SLL and click on it. On the new page scroll down and from issue a new certificate

Lets Encrypt SLL

  • Now go to file manager again and create a folder named testpharma outside the public_html (for example we have pharma folder) folder and upload complete laravel app folder in it. Upload via zip folder or FTP.
  • Once uploaded move the public folder from testpharma folder to test.pharmabazaar.co folder inside public_html folder.
  • Now open test.pharmabazaar.co and find index.php and change the path for bootstrap and autoload.php to testpharma folder outside public_html folder. See example in image.
  • Create the database with name testpharma in using MYSQL wizard from cPanel and edit your .env file same.
  • Export the database for your laravel apop from localhost/phpmyadmin and import it in testpharma database you created.
  • Create a symlink.php file to link laravel storage folder to your public folder to access media files publically. Upload symlink.php to test.pharmabazaar.com folder inside public_html.
    <?php

        symlink(‘/home/bwkdlfta/testpharma/storage/app/public/’, ‘/home/bwkdlfta/public_html/test.pharmabazaar.co/storage’);

    ?>
  • Go to test.pharmabazaar.com and delete the storage folder and then to go test.pharmabazaar.com/symlink.php it will create a folder in test.pharmabazaar.co named storage. If you don’t find any folder named storage with a link sign on it. Please check your code and retry.
  • Your application is ready to use. Now try accessing test.pharmabazaar.co your application should work. If not, enable app debug and find the error.