upload my project laravel to a shared host

2019-05-21 00:29发布

问题:

I have a shared hosting service hostinger. as I can upload my laravel 5.2 and configure project?

and I tried using:

namespace App\Providers;

use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider {
/**
 * Bootstrap any application services.
 *
 * @return void
 */
public function boot() {
    //
}

/**
 * Register any application services.
 *
 * @return void
 */
public function register() {

    $this->app->bind('path.public', function () {
        return base_path() . '/public_html';
    });
   }
}

but still nothing.

回答1:

I guess easiest and better approach in this situation will be creating of a symlink between public_html and public folders. Example for Ubuntu/Debian:

ln -s /path-to-pub/public_html /path-to-pub/public

This solution is better because when you'll decide to move your project to VPN, dedicated server etc., you will not need to remember about any modifications you made and rewrite any code.



回答2:

Put this code:

$app->bind('path.public', function () {
    return base_path() . '/public_html';
});

to bootstrap/app.php and You are good to go. (I assuming that You renamed public directory already.)