Search code examples
phplaravellaravel-artisan

Laravel 9: run project without using php artisan serve command


I want to run my laravel 9 app without 'php artisan serve' i know how to do it in older version but laravel 9 don't have the server.php file in root directory so how to do it now

and i don't want to use 'localhost/project/public/' url

I am currently on laravel: version 9.19 OS: Ubuntu 22.04.1 LTS php: 8.1.2 Server: Apache/2.4.52 (Ubuntu)


Solution

  • First step is to add your project to list of virtual hosts in XAMPP that is located in \apache\conf\extra > httpd-vhosts.conf

    It can be something like:

    <VirtualHost *:80>
        DocumentRoot "{pathToProject}\public"
        ServerName projectname.localhost
        <Directory "{pathToProject}">
            AllowOverride All
            Require all granted
        </Directory>
    </VirtualHost>
    

    Second step is to add host in your hosts file that is located in same disk as your OS then \Windows\System32\drivers\etc > hosts It should probably be something like 127.0.0.1 projectname.localhost

    If you've changed default address settings, you will have to change address in hosts as well.

    Restart XAMPP and you're good to go.