Having trouble deploying Laravel site to Bluehost subdomain - Hack The Tech - Latest News related to Computer and Technology

Hack The Tech - Latest News related to Computer and Technology

Get Daily Latest News related to Computer and Technology and hack the world.

Sunday, July 16, 2023

Having trouble deploying Laravel site to Bluehost subdomain

[Update: At this point, I have been able to resolve all my deployment problems but one. The most recent one is that I had an Access denied for user 'bob'@'localhost' (using password: YES) error whenever I attempted to access a route that required a db connection. The problem arises from using cPanel on Bluehost with shared hosting. The way that cPanel handles this is to prefix your database name and your user names with characters 2-9 of your domain name plus an underscore character. So, for example, my neighborhood database was actually called obertrod_neighborhood, and the user name bob was actually obertrod_bob. When I altered the DB_DATABASE and DB_USERNAME values in the .env file to reflect this, I got access to the database.]

I have been over a number of posts where someone was attempting to deploy a Laravel site to bluehost. While it seems like plenty of people have had difficulty deploying Laravel to Bluehost, I haven't found any posts that appear to address my specific situation.

  1. I have a fully working site that I developed on my own machine. I use php artisan serve to fire up localhost:8000. On my browser, navigating to localhost:8000 fires up the landing page, which is exposed as a / route. All the other routes (e.g. /users) run as expected.
  2. The site's routes access a MySQL datbase. I didn't use migrations. I created the database directly on my machine with MySQL Workbench.
  3. Bluehost subdomain is neighborhood.robertrodes.com.
  4. An index.html file that prints "test" to the screen runs correctly on the subdomain, so the subdomain itself is in working order.
  5. I created the MySQL database on the Bluehost subdomain by dumping my local database to a .sql file, uploading it, and using phpMyAdmin to run the file. The database appears to be in working order; the schema is correct and I'm able to use phpMyAdmin to perform all CRUD operations without issue.
  6. I first tried installing the Laravel framework using Bluehost's softacular service, and uploading all the model, views, controllers, routes and css files to the appropriate folders. I was able to get the landing page to display (the / route), but all the other routes give a 404 error after the site reroutes to public.
  7. I tried not using the Bluehost installation, and just copying all of my files from the localhost version to the blank subdomain. This one sometimes comes up 403 forbidden, and sometimes reroutes to neighborhood/robertrodes.com/public/public (go figure) and responds with a 404 error. [Edit: This was a problem with caching. Now the site shows a test value correctly, and the main landing page navigating to the public folder from the URL.]
  8. The current state of the subdomain is that the local version of the site resides in the root folder of the subdomain.

Looks like I'm in over my head, and Bluehost doesn't support Laravel. I haven't been able to find anything relevant in the Laravel doc, either. Can someone give me a hand troubleshooting this?

In particular, I suspect that I have some files that are pointing things to wrong places. If I could get clear on where the files are that handle configurations and where to find things I can probably fix it from there.

For example, I can't find a file where requests to neighborhood.robertrodes.com get redirected to neighborhood.robertrodes.com/public/public (that's what happens). [Edit: not any more. This was a caching problem, resolved by clearing the cache.] There isn't a .php file in the root folder. In the public folder, index.php doesn't have the word public in it.



source https://stackoverflow.com/questions/76689979/having-trouble-deploying-laravel-site-to-bluehost-subdomain

No comments:

Post a Comment