#404 error from apache2 with laravel / working well with "php artisan serve" but nor with apache2

47 messages · Page 1 of 1 (latest)

hushed sinew
#

.

craggy bear
hushed sinew
#

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...

▶ Play video
#

on welcom.blade.php i have put a link to thi page

#

all of this is with apache2 server on debian 12

craggy bear
#

You have to set up vhosts with apache2, so you point the document root to the Laravel public directory

hushed sinew
#

but if i do "php artisan serve" cmd, all is working fine

hushed sinew
craggy bear
#

I do not remember the command for that, but you can Google it

hushed sinew
hushed sinew
#

its sudo systemctl restart apache2

craggy bear
#

SeverName needs to be your actual domain

#

also repas-site isn't a TLD? is this local?

hushed sinew
#

all is for local

#

the link to not found page is "Planifier un repas"

craggy bear
#

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)

hushed sinew
#

i dont need to modify domain because its working for welcome page

craggy bear
#

im not gonna argue if its correct or not, you're the one asking for help, not me. good luck

hushed sinew
craggy bear
#

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.

hushed sinew
craggy bear
#

@frozen cape feel free to help instead of clowning about

craggy bear
hushed sinew
craggy bear
#

The vhosts and your .htaccess probably

hushed sinew
frozen cape
#

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.

craggy bear
#

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

hushed sinew
#

the one in public is that:

craggy bear
#

You should not have two .htaccess

hushed sinew
frozen cape
#

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.

craggy bear
#
<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

hushed sinew
#

yes i thinks its the minimu

craggy bear
#

So does it work after only having the .htaccess in public and with the above config?

hushed sinew
#

Directory tag is needed, i believed that directory and filesmatch is same but with different params