0

When I place a Laravel project into Apache's document root, say /var/www/html, it works when I point a browser at it.

However if I put it under a directory under Apache's document root, for example /var/www/html/myProject, it doesn't work when I point a browser at it.

Is there anyway I can change this behavior?

Thank you very much.

Edit: When I put the Laravel project off a sub-directory off /var/www/html, Laravel complained that it could not write to the file laravel.log. After checking and changing the group ownership of the sub-directory, the index page came up normally.

However, the background image was missing, even after I changed the URI in the CSS stylesheet.

Furthermore, when I clicked on any link from the index page, I got a 404 Not Found Error. This is an Apache 404 and not a Laravel 404, which is styled differently.

OTOH, if I run the PHP server off this sub-directory and point my browser at localhost:8000, the links serve up pages correctly.

Thank you for your help.

fhcluk
  • 9
  • 3
  • you need to configure a virtual host for your site and set the virtual host root to be your Laravel project's `/public` directory. You should probably take a look at https://stackoverflow.com/questions/49184358/setting-document-root-for-laravel-project-on-apache-virtual-host – apokryfos Jul 07 '22 at 06:35
  • please check [ask] and edit your question to let us know what you observe, instead of saying "it doesn't work" – Olaf Kock Jul 07 '22 at 07:12
  • Hello, it's not quite the same as the other question. I can run the Laravel app by pointing the browser at /var/www/html/myProject, but any links of the homepage fails with a 404. OTOH, if I open a terminal, cd into the directory, and run "$ php artisan serve," then point my browser at "http://localhost:8000," the app runs fine. Thanks. – fhcluk Jul 12 '22 at 05:34

0 Answers0