#404 error from apache2 with laravel / working well with "php artisan serve" but nor with apache2
47 messages · Page 1 of 1 (latest)
Please put some effort into providing context to your question, or nobody can help you.
Read this: https://discord.com/channels/297040613688475649/1270372863412801587
i searched for posts in #1019646242709569617 but nothing like me
https://www.youtube.com/watch?v=kcFBZxVTmBU i watched this video to do the project
Aujourd'hui on découvre comment créer un site avec PHP et Laravel
🖥️ Héberge ton site avec Hostinger : https://www.hostg.xyz/SHBis
(- 10% avec la code GRAVEN)
🔗Liens de la video :
Comparaison Laravel vs Symfony : https://www.youtube.com/watch?v=OQBAtkpA2sk
🔗 Timecode
00:00 - Intro
01:23 - Préparatifs
03:10 - Création du Projet
06:44 - Premier...
on welcom.blade.php i have put a link to thi page
all of this is with apache2 server on debian 12
You have to set up vhosts with apache2, so you point the document root to the Laravel public directory
but if i do "php artisan serve" cmd, all is working fine
yes i have done that but not working
You need to reload/restart apache2 after changing vhosts.
I do not remember the command for that, but you can Google it
yes i have restarted
its sudo systemctl restart apache2
SeverName needs to be your actual domain
also repas-site isn't a TLD? is this local?
idk why you dont just use .test like most people, but anyways, your ServerName needs to be repas-site.repas-site in that case and also edit your hostsfile to point that domain to localhost (seems you've done that already)
i dont need to modify domain because its working for welcome page
im not gonna argue if its correct or not, you're the one asking for help, not me. good luck
i dont understand why you said to me to change servername if its working for 1 page because its working for all page or none
If it's working, why are you asking for help then? I've pointed out to you, that your vhosts is likely misconfigured. I told you what to check, pointed out those 4 lines you shared look wrong according to what Apache gives as examples. You didn't provide much detail, even though I said in my first message please provide context. You took a cropped screenshot with minimal config and didn't share the config path either. If you placed it in it's own config, you need to write some bonkers apache command to enable it as well. Many of us don't use apache today, nginx is preferred or even something like caddy. I do not know what you want from me, if you're not going to take my responses into practice.
the domain is working, not all the config or code
@frozen cape feel free to help instead of clowning about
Which is what I am saying? You most likely have a misconfigured vhosts, have you looked up vhosts examples for Laravel via Google and put it into practice? You shared like 20% of the config to begin with
which part of config d you need?
The vhosts and your .htaccess probably
Or you could swap to NGINX and just copy the config from here: https://laravel.com/docs/11.x/deployment#nginx
Sorry if you find my reactions offensive, I am thinking your responses are valid and on-point despite "not being taken into practice" and the whole interaction feels funny.
A quick search would show how Apache configuration works, and it also seemed to me ServerName needs to match the host part of the HTTP request, so that does look like a good place to start.
Laravel has an htaccess already so use that and just configure the vhosts: https://github.com/laravel/laravel/blob/11.x/public/.htaccess
Issue most likely caused by your .htaccess then
But if you're not familiar with Apache or NGINX, I'd advise to familiarize yourself with NGINX instead
the one in public is that:
You should not have two .htaccess
ho ok
I haven't used Apache with Laravel for ages (I did this around L4, before moving entirely with Nginx) so I couldn't say for sure, but it doesn't hurt to put the correct values into practice.
You needed to make sure that there aren't any other .htaccess overwriting the configuration (since I remember Apache reading every single .htaccess file in each directory up to the project directory)
There are other help as well like this one in configuring Apache, and honestly we couldn't know better how you're configuring yours or what steps you have tried.
<VirtualHost *:80>
ServerName repas-site.repas-site
DocumentRoot /var/www/repas-site/public
<Directory /var/www/repas-site/public>
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
this is a bare minimum vhosts for apache from a quick google, i do not use apache so i cannot say with certainty what else you need to put here
lots of StackOverflow answers with more context available
yes i thinks its the minimu
So does it work after only having the .htaccess in public and with the above config?
See this SO post for detailed answers regarding Apache: https://stackoverflow.com/questions/49184358/setting-document-root-for-laravel-project-on-apache-virtual-host
Directory tag is needed, i believed that directory and filesmatch is same but with different params