John Davidson

php - Deploying Laravel 9 application to BlueHost

0 comments
Message:


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.



My Answer:
Since you are using shared hosting, deploying a Laravel application can be a bit tricky. Here are some steps you can follow to deploy your Laravel application to BlueHost:

1. Zip your Laravel application files on your local machine.
2. Upload the zipped file to your BlueHost account using the cPanel File Manager.
3. Extract the zipped file in the public_html directory.
4. Rename the extracted folder to something like "laravelapp".
5. Edit the index.php file in the public_html directory and update the following line:

php
require __DIR__.'/../bootstrap/autoload.php';


to:

php
require __DIR__.'/laravelapp/bootstrap/autoload.php';


6. Edit the server.php file in the public_html directory and update the following line:

php
require_once __DIR__.'/public/index.php';


to:

php
require_once __DIR__.'/laravelapp/public/index.php';


7. Create a new database in your BlueHost account and import your local database into it.
8. Update the .env file in the laravelapp directory with your database credentials.
9. Finally, visit your domain in a web browser to see if your Laravel application is live.

These steps should help you deploy your Laravel application to BlueHost. If you encounter any issues, you can reach out to BlueHost support for assistance.

Rate this post

4 of 5 based on 2561 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us