0

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.

balaraman
  • 397
  • 1
  • 7
  • 21
  • 4
    using apache or nginx. i guess artisan serve just launches the php inbuilt dev server – delboy1978uk Jan 28 '20 at 15:23
  • Laravel has great documentation: https://laravel.com/docs/6.x – Zoltan Vinkler Jan 28 '20 at 15:27
  • `php artisan serve` should only be used for development purposes. For production you should use a dedicated webserver like apache or nginx. – Jerodev Jan 28 '20 at 15:34
  • If I have developed entirely in laravel then I could create a virtual host in apache conf file and make it as worked. But I used Vuejs as a frontend and Laravel as a backend. In this scenario How should I configure in apache web server? @Jerodev – balaraman Jan 28 '20 at 15:41

2 Answers2

1

Local Development Server

If you have PHP installed locally and you would like to use PHP's built-in development server to serve your application, you may use the serve Artisan command.


Deployment

When you're ready to deploy your Laravel application, you should use a dedicated webserver like Apache or Nginx.

Wahyu Kristianto
  • 8,719
  • 6
  • 43
  • 68
  • If I have developed entirely in laravel then I could create a virtual host in apache conf file and make it as worked. But I used Vuejs as a frontend and Laravel as a backend. In this scenario How should I configure in apache web server? – balaraman Jan 29 '20 at 05:48
0

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.

balaraman
  • 397
  • 1
  • 7
  • 21