skip to Main Content

I have a new laptop, and am now trying to run a laravel application.
First, am trying to setup a virtual host for the project so that I can access blog.local

I went my hosts file and setup the drivers like the following:

127.0.0.1       localhost
127.0.0.1       test.local
127.0.0.1       blog.local

The for the apache configuration I have the following:

<VirtualHost *:80>
    DocumentRoot "C:XAMPPhtdocs"
    ServerName localhost
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "C:XAMPPhtdocsblog"
    ServerName blog.local
</VirtualHost>

When I try to access my url I do not see the site but the files only:

enter image description here

For this and future projects, how can I create a local url and see the front-end when I visit it?

2

Answers


  1. You need to address your public folder,

    <VirtualHost *:80>
        DocumentRoot "C:XAMPPhtdocsblogpublic"
        ServerName blog.local
    </VirtualHost>
    
    Login or Signup to reply.
  2. The document root is a directory (a folder) that is stored on your host’s servers and that is designated for holding web pages. When someone else looks at your website, this is the location they will be accessing.

    Change the DocumentRoot to according to your PHP project is located.

    <VirtualHost *:80>
        DocumentRoot "C:/xampp/htdocs/blog/public"
        ServerName blog.local
    </VirtualHost>
    

    Restart the servers after making any changes! If you don’t reset the server to apply the changes, nothing will work even though you know you’ve done everything right.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search