skip to Main Content

I have a laravel app, which I test with php artisan serve.

I discovered that this is a bad practise, because it is not used on production.

I have installed apache2.4, it worked, when I open localhost I see ‘It Works’.

Now I try to start my laravel app through apache on my PC.

For this I have done the following steps:

  1. Edited the httpd.conf in Apacheconf, I uncommented this line:

LoadModule rewrite_module modules/mod_rewrite.so

  1. Edited the httpd-vhosts.conf in Apacheconfextra, I added:
<VirtualHost *:80>
    DocumentRoot "Y:/PHP-Projects"
    ServerName localhost 
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "Y:/PHP-Projects/Project-Admin-PHP/public"
    ServerName localhost.eu 
</VirtualHost>
  1. Edited the hosts file in WindowsSystem32driversetc, I added:

127.0.0.1 www.localhost.eu localhost.eu

After every step I restarted the Apache2.4 service, but I still cant access my laravel application. The only thing, what changed is that I now get ‘It Works‘ also on this domain: localhost.eu

What have I missed?

Currently I am starting my laravel app through php artisan serve. I can then access the app at localhost:8000.

Also I know I could set up homestead. But I discovered it too late. I have already configured and installed everything myself, and besides this one issue, everything works.

I’d like to understand how I would connect my laravel app to the apache server correctly myself.

2

Answers


  1. Add server alias on your file config

    <VirtualHost *:80>
        DocumentRoot "Y:/PHP-Projects/Project-Admin-PHP/public"
        ServerName localhost.eu
        ServerAlias www.localcost.eu
    </VirtualHost>
    
    Login or Signup to reply.
  2. Probably you forgot include file httpd-vhosts.conf file in httpd.conf. Sometimes this line commented by default and you should uncomment this line. After then you should restart apache2 service.

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