Search code examples
javascriptphplaravelvue.jslaravel-vue

Laravel with Vuejs run project without php artisan serve


I am developing a VueJs application in Laravel. In my local environment I have to use php artisan serve command to serve my project. In server I am using php artisan serve --host 0.0.0.0 --port 8000 command to run my project. I have configured apache web server.

Here my question is How should I run the project on the server without using php artisan serve command?. Thanks in advance.


Solution

  • change the webpack mix file (project_root_path/webpack.mix.js) with the following

    mix.js('resources/js/app.js', 'public/js')
     .sass('resources/sass/app.scss', 'public/css')
     .setResourceRoot("/public/");
    
     mix.webpackConfig({
        output: {
            publicPath: '/public/',
        }
     });
    

    map the project folder into apache config file (/etc/apache2/sites-available/000-default.conf)

    VirtualHost *:8000>
        DocumentRoot /var/www/html/ProjectRoot
        Header set Cache-Control max-age=101930
    
        <Directory /var/www/html/ProjectRoot/public>
            Header set Cache-Control "no-cache"
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
    

    enable the port in (/etc/apache2/ports.conf). add the following line

    Listen 8000
    

    restart the apache server and check the url.