meeshka's avatar

DocumentRoot and public folder

Hi,

/var/www/html/ is my DocumentRoot and it currently has a WordPress installation.

What if, I install Laravel into /var/www/l5/ and push public directory to /var/www/html/ and rename it to something like l5-web. Further, modify the paths within front controller to look for required files in /var/www/l5

i.e

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

to

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

I did a quick test and it seems to work. Although not sure if this will cause any other issues? Any insights?

0 likes
5 replies
Snapey's avatar

If you use it, the path helper public() will no longer work since it expects it to be child of the Laravel install.

Its easy enough to do without it though.

1 like
meeshka's avatar

That's a good point. Any other thing that may trouble?

Snapey's avatar

You can fix the public path in index.php


/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__.'/../bootstrap/app.php';

// set the public path to this directory
// https://laracasts.com/discuss/channels/general-discussion/where-do-you-set-public-directory-laravel-5
$app->bind('path.public', function() {
    return __DIR__;
});

1 like
ricky2210's avatar

You can also try:

  • Copy /var/www/html/ contents to the laravel public folder.
  • Delete /var/www/html/ folder (backup first of course).
  • Symlink /var/www/html/ to laravel public folder.

This way, you don't need to modify index.php file.

Please or to participate in this conversation.