1

We tried deploying our laravel server by uploading our laravel folder to the linux server. We put the public folder in the public_html/laravelsite and the everything else in the a folder called laravelsite. We added

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

to our AppServiceProvider. But when viewing the site in the browser we get the following errors.

app.css:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error) bootstrap.js:1

Failed to load resource: the server responded with a status of 500 (Internal Server Error) app.js:1

Failed to load resource: the server responded with a status of 500 (Internal Server Error) bootstrap.js:1

Failed to load resource: the server responded with a status of 500 (Internal Server Error) app.js:1

Failed to load resource: the server responded with a status of 500 (Internal Server Error) app.css:1

app.css:1 Failed to load resource: the server responded with a status of 500 (Internal Server Error) app.css:1

I commented the code that produces the errors in the landing.blade So we looked at the following post

How can I change the public path to something containing an underscore in Laravel Mix?

But doing that did not work out for us.

landing.blade(landing page)

<!DOCTYPE html>
<!-- hidden override for w3 style this has to be removed before this goes in production !!!!!!!! -->
<html style="overflow:hidden">

<head>
    <meta property="og:image" content="/favicon.png" />
    <title>Laravel Site</title>
    <meta name="description" content="Welcome to out Laravel Site. Come on in!" />
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="csrf-token" content="{{csrf_token()}}">
    <!-- This is the first error -->
    <link href=" {{ mix('css/app.css') }}" rel="stylesheet">
    <link href='https://fonts.googleapis.com/css?family=Raleway:800' rel='stylesheet'>
    <link href='https://fonts.googleapis.com/css?family=Raleway:500' rel='stylesheet' type='text/css'>
    <link href=" {{ asset('css/animate.css') }}" rel="stylesheet">
    <link href=" {{ asset('css/text-editor.css') }}" rel="stylesheet">
    <link href='https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons' rel="stylesheet">
    <script src="https://d3-geomap.github.io/d3-geomap/vendor/d3.geomap.dependencies.min.js"></script>
    <script src="https://d3-geomap.github.io/d3-geomap/js/d3.geomap.min.js"></script>
</head>

<body style="background-color: #f2f2f2;">
    <div id="app">
        <app></app>
    </div>
        <!-- This is the second error -->
    <script src="{{ mix('js/bootstrap.js') }}"></script>
        <!-- This is the third error -->
    <script src="{{ mix('js/app.js') }}"></script>
</body>

</html>

webpack.mix

let mix = require("laravel-mix");

mix.setPublicPath("public_html/laravelsite/");
/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */
mix.webpackConfig({
  resolve: {
    extensions: [".js", ".vue", ".json"],
    alias: {
      vue$: "vue/dist/vue.esm.js",
      "@": __dirname + "/resources/assets/js"
    }
  }
});

mix
  .js("resources/assets/js/app.js", "public_html/laravelsite/js")
  .setResourceRoot("")
  .js("resources/assets/js/bootstrap.js", "public_html/laravelsite/js")
  .sass("resources/assets/sass/app.scss", "public_html/laravelsite/css");

It is trying to load the files at http://websitename.com/css/app.css , so it's probably looking in the public_html folder. But inside that folder we have another folder called laravelsite so it should be looking for http://websitename.com/laravelsite/css/app.css

anonymous-dev
  • 2,897
  • 9
  • 48
  • 112
  • Possible duplicate of [Uncaught Exception: Unable to locate Mix file](https://stackoverflow.com/questions/51191510/uncaught-exception-unable-to-locate-mix-file) – Salim Djerbouh Oct 10 '19 at 10:30
  • We tried npm install and run dev and it did not work – anonymous-dev Oct 10 '19 at 11:02
  • Place your public folder content in public_html folder. Other files folder outsite the public_html folder. Then update index.php file's correct path th boostrap and vendors. Finally xraeate a symlink to your storage folder – Garry Oct 12 '19 at 16:55
  • @kas we did all of that already – anonymous-dev Oct 14 '19 at 08:46
  • Actually you dont need to point path to public_html except symlink Like i appservice provider or webpack.mix – Garry Oct 14 '19 at 13:20
  • maybe a solution is to compile it on the dev machine and then push it with the files already in the public folder. This may happen because of the shared hosting. if this is working you can put it on bitbucket and run the npm with the docker instance from the pipelines or in gitLab also. – Morpheus_ro Oct 14 '19 at 14:02
  • @Morpheus_ro that's the way i do – Garry Oct 15 '19 at 09:35
  • then is there any `gitingore` file in the public folder? so then the files are ignored – Morpheus_ro Oct 15 '19 at 12:07

1 Answers1

0

When the laravel application is booted, laravel has issues with finding the "true root directory". You may need to change the boot directory and the storage directory in config.

Jamie Ross
  • 246
  • 1
  • 3
  • 13