Deploying Laravel 9 application to BlueHost

Viewed 39

I am a beginner. I just created my first complete Laravel application, and I want to make it go live. I already have domain and hosting services (domain with Name.com and BlueHost for hosting). I have been trying to do it the way I learned in school, but it hasn't been successful. What I've tried:

  1. Upload the files to the cPanel File Manager. It would show 403 Forbidden. I saw some over questions about it, where they say to run a command in to change the preferences. The thing is that I don't have access to a server terminal (because it's a shared terminal. YES, I know shared hosting isn't the best for Laravel. But it's all I can afford at the moment).
  2. Using CyberDuck and SSH to upload the files. Also did not work, the same outcome as before.
  3. Using Git to clone the GitHub repository into the host. It didn't work because it would say that the repository I was trying to add to (public_html) already had files. I don't understand why I can't add more files to that repository.

I am not sure what to do now. I can't find this information anywhere.

1 Answers

To deploy a Laravel 9 application to Cpanel-based hosting your need to follow these steps-

First of all, Upload your application with the vendor folder and the .env file. Then, if you are deploying your app to a sub-domain/addon-domain

  • Point your domain to "your_application_folder/public"
  • Edit .env file and update your database credentials and other settings for production, e.g. APP_ENV=production

Your application should be live after these actions and work properly.

If you are deploying your app to the primary domain. Then

  • Delete all previous files from public_html folder and upload the application there.
  • Now create a .htaccess file in public_html folder and put the codes below to the
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
  • Do the .env file update as above

At this point, your application should be live.

Related