MarceloG's avatar

Deploy on shared server

Hi!, i'm trying to deploy my L5.5 app on a shared server but, even though i apply the recipe for this task (copying all folders except public and changing the bootstrap file to recognize the new folders structure)

I have some issues, mix() and Storage::url() functions they do not work as I assumed. mix fails with error manifest not found and the another with 404. In both cases the path retrieved is wrong although my public_path is, by example, /home/my_folder/public_html/my_laravel_public_folder. In this cases the url is http://my-site.com/app.js in mix case and http://my-site.com/storage/my-pics-folder/hash.png

Some help!

Regards in advance

0 likes
8 replies
mcstepp's avatar

There's a hidden mix method to (re)set the public path:

mix.setPublicPath('path/to/public');

MarceloG's avatar

Thanks! i try with this, but i'm figure that some where this is configurable.

Snapey's avatar

don't make your laravel folder publically accessible !

1 like
MarceloG's avatar

Hi, thanks a lot @mcstepp, but i follow another workaround

My solution here:

  1. I get a subdomain to deploy my app, so the public_html in this case is empty.
  2. I don't change the default folder structure.
  3. Instead i make a symlink to the public folder ( @Snapey suggestion) to make all more safe.
ljlizarraga's avatar

My solution here:

rename the project folder to laravel

rename and move /laravel/public to /public_html

structure example

/laravel /public_html

in public_html/index.php

change require DIR.'/../vendor/autoload.php'; for require DIR.'/../laravel/vendor/autoload.php'; change $app = require_once DIR.'/../bootstrap/app.php'; for $app = require_once DIR.'/../laravel/bootstrap/app.php';

in /laravel/app/Providers/AppServiceProvider.php

paste this

/**
 * Register any application services.
 *
 * @return void
 */
public function boot()
{
    Schema::defaultStringLength(191);
}
public function register()
{
    $this->app->bind('path.public', function (){
        return base_path().'/../public_html';
    });
}

------------------------------------------

composer update

npm install

example

mix.setPublicPath('../public_html');

mix.js('resources/assets/js/app.js', 'asset/js') .sass('resources/assets/sass/app.scss', 'asset/css');

//browserSync Example too..

mix.browserSync({ proxy: 'http://project.dev', //browser: ["google chrome", "firefox"], open: false, files: [ 'app//', '../public_html//', 'resources/views//', 'resources/lang//', 'resources/assets//', 'routes//' ], /* notify: { styles: { top: 'auto', bottom: '0' } },*/ });

Snapey's avatar

Jeez, what a P*** about!

Folks, its not that hard! just put all your framework one folder higher than the folder that the hosting company tells you.

If they say put all your content in /public_html then don't. Just put the contents of your public folder in there and put everything else in its parent.

Job done.

MarceloG's avatar

I change my aproach using deployer and just make a symlink between public and the public_html folder, and just work fine without change nothing.


public_html -> deploy/current/public
deploy
    current
        public
        other_laravel_files_and_folders

ErikRobles's avatar

@SNAPEY - Hello Snapey. I have a quick question (or 2). If my host does not provide a public or public folder, what would the procedure be , and second, I am running my project in a sub-directory to my main website. For example www.mysite.com/laravelapp ??? Thank you in advance for your help with this.

Please or to participate in this conversation.