My laravel 8 project is running in a local environment with Ubuntu 18.04, Apache 2.4.29 and php 7.3.22. It is working, but in my prod server with the same versions I got 404 for all routes. I already enabled rewrite module sudo a2enmod rewrite
and my virtual host is like bellow:
DocumentRoot /home/ubuntu/project/public
<Directory /home/ubuntu/project/public/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
also I changed storage forder owner sudo chown -R ubuntu:www-data storage
3
Answers
your virtual host should have the contain below:
your vitual host should look like this in order to work:
Test is the name of the project which can be as you want.
You can access your project on test.local without php artisan serve
Edit: dont forget to add an entry to the machine hosts file as follow:
add this line:
ctrl+o
to save andctrl+x
to exitLast step, just restart the apache:
sudo service apache2 restart
PS: If
127.0.0.1
is already taken you can set another ip like:127.0.0.2
If you’re using apache and your virtual host config is
ok
and you are using thisAllowOverride all
Options Indexes FollowSymLinks
in your<Directory>
Just run this command:
And restart your apache by this command:
It’s working for me.