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:
- Edited the
httpd.conf
inApacheconf
, I uncommented this line:
LoadModule rewrite_module modules/mod_rewrite.so
- Edited the
httpd-vhosts.conf
inApacheconfextra
, 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>
- Edited the
hosts
file inWindowsSystem32driversetc
, 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
Add server alias on your file config
Probably you forgot include file
httpd-vhosts.conf
file inhttpd.conf
. Sometimes this line commented by default and you should uncomment this line. After then you should restart apache2 service.