May Sale! All accounts are 40% off this week.

ottaviane's avatar

[SOLVED]Laravel routing not working after upgrade of LAMP and php8.0

thanks to: @jlrdw @Tray2 @Snapey

Solution:

sudo a2enmod rewrite
sudo service apache2 restart
 

apache module:

<VirtualHost *:80>
   ServerAdmin [email protected]
   ServerName mysite
   ServerAlias www.mysite

   DocumentRoot /var/www/mysite/public
    <Directory /var/www/mysite>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>
    ErrorLog /error.log
    CustomLog /access.log combined
</VirtualHost>

ORIGINAL QUESTION:

Hi all, after a total upgrade of my Ubuntu server and LAMP to last version my Laravel projects doesn't works having routing problems. I finally understood that my problem is in Apache config. If I make php artisan route:list is all ok. If I use php artisan serve work all fine. But if I use LAMP server to serve my site, routes does'nt works. Only the home page is loaded. This is my apache config module that worked fine before upgrade:

<VirtualHost *:80>
   ServerAdmin [email protected]
   ServerName SquadrarioWeb   
   DocumentRoot /var/www/SquadrarioWeb/public
    <Directory /var/www/SquadrarioWeb>
         Options Indexes MultiViews
         AllowOverride None
         Require all granted
    </Directory>
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Now I'm using php 8.0 and Apache2.4.48. DocumentRoot is correct and stat is ok. All privileges are ok. What am I doing wrong?

0 likes
11 replies
jlrdw's avatar

Try clearing all the various cache including config.

Is it the same laravel version.

ottaviane's avatar

@jlrdw thank you very mutch. Laravel is version 7 ok I made this:

php artisan config:clear
php artisan route:clear
php artisan view:clear
php artisan cache:clear

but the problem is the same. It does'nt resolved. I made a new installation of a new laravel blog but its routes does'nt work! What can I verify?

ottaviane's avatar

I found that if I visit

http://SquadrarioWeb/anithing_is_in_public_folder 

are served well, but all passes from laravel route system I obtain 404 error:

sudo tail -f /var/log/apache2/access.log

127.0.0.1 - - [11/Dec/2021:20:17:23 +0100] "GET / HTTP/1.1" 200 2102 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0"
127.0.0.1 - - [11/Dec/2021:20:17:23 +0100] "GET /js/mainApp.js HTTP/1.1" 200 367994 "http://squadrarioweb/" "Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0"
127.0.0.1 - - [11/Dec/2021:20:17:23 +0100] "GET /js/popper.js.map HTTP/1.1" 404 492 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0"
127.0.0.1 - - [11/Dec/2021:20:17:24 +0100] "GET /roboto/getSedi HTTP/1.1" 404 491 "http://squadrarioweb/" "Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0"
127.0.0.1 - - [11/Dec/2021:20:17:24 +0100] "POST /getPersonaleOpDistaccamenti HTTP/1.1" 404 491 "http://squadrarioweb/" "Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0"
127.0.0.1 - - [11/Dec/2021:20:17:24 +0100] "POST /getPersonaleOpCentrale HTTP/1.1" 404 491 "http://squadrarioweb/" "Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0"
127.0.0.1 - - [11/Dec/2021:20:17:24 +0100] "POST /getPersonaleNonOp HTTP/1.1" 404 491 "http://squadrarioweb/" "Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0"
127.0.0.1 - - [11/Dec/2021:20:17:24 +0100] "GET /js/popper.js.map HTTP/1.1" 404 491 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0"
127.0.0.1 - - [11/Dec/2021:20:47:34 +0100] "GET /img/ HTTP/1.1" 200 916 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0"
127.0.0.1 - - [11/Dec/2021:20:47:34 +0100] "GET /icons/blank.gif HTTP/1.1" 200 431 "http://squadrarioweb/img/" "Mozilla/5.0 (X11; Linux x86_64; rv:93.0) Gecko/20100101 Firefox/93.0"

where can I find documentation explaining routing mechanism Laravel/Apache? What class is responsible of routing?

Here a partial result of php artisan route:list

|        | POST     | roboto                                          |                     | App\Http\Controllers\roboto\robotoController@roboto                                                              | web                |
|        |          |                                                 |                     |                                                                                                                  | mygroups           |
|        |          |                                                 |                     |                                                                                                                  | ttlSession         |
|        |          |                                                 |                     |                                                                                                                  | isSquadrarioEditor |
|        | POST     | roboto/addNewUser                               |                     | App\Http\Controllers\roboto\robotoController@addNewUser                                                          | web                |
|        |          |                                                 |                     |                                                                                                                  | mygroups           |
|        |          |                                                 |                     |                                                                                                                  | ttlSession         |
|        |          |                                                 |                     |                                                                                                                  | isSquadrarioEditor |
|        | POST     | roboto/execute                                  |                     | App\Http\Controllers\roboto\robotoController@execute                                                             | web                |
|        |          |                                                 |                     |                                                                                                                  | mygroups           |
|        |          |                                                 |                     |                                                                                                                  | ttlSession         |
|        |          |                                                 |                     |                                                                                                                  | isSquadrarioEditor |
|        | GET|HEAD | roboto/getAllUsers                              |                     | App\Http\Controllers\roboto\robotoController@getAllUsers                                                         | web                |
|        |          |                                                 |                     |                                                                                                                  | mygroups           |
|        |          |                                                 |                     |                                                                                                                  | ttlSession         |
|        |          |                                                 |                     |                                                                                                                  | isSquadrarioEditor |
|        | GET|HEAD | roboto/getGradi                                 |                     | App\Http\Controllers\roboto\robotoController@getGradi                                                            | web                |
|        |          |                                                 |                     |                                                                                                                  | mygroups           |
|        |          |                                                 |                     |                                                                                                                  | ttlSession         |
|        |          |                                                 |                     |                                                                                                                  | isSquadrarioEditor |
|        | GET|HEAD | roboto/getSedi                                  |                     | App\Http\Controllers\roboto\robotoController@getSedi                                                             | web                |
|        |          |                                                 |                     |                                                                                                                  | mygroups           |
|        |          |                                                 |                     |                                                                                                                  | ttlSession         |
|        | POST     | roboto/getUserInfo                              |                     | App\Http\Controllers\roboto\robotoController@getUserInfo                                                         | web                |
|        |          |                                                 |                     |                                                                                                                  | mygroups           |
jlrdw's avatar

@ottaviane is that the same virtual host setup you had previously?

Edit

Also delete all files in bootstrap\cache except .gitignore

1 like
Tray2's avatar

@ottaviane Make sure that you have enables mod_rewrite. It most likely got turned off when you updated.

3 likes
ottaviane's avatar

@Tray2 Yes, it was turned off and now I did

sudo a2enmod rewrite 

and restarted apache and the problem was resolved

1 like
Snapey's avatar

check your .htaccess file in the public folder

2 likes
samir_maharjan's avatar

Here is my issue. ipaddress/laravel/public gives generate key error after generating key give this error

Not Found The requested URL was not found on this server.

Apache/2.4.41 (Ubuntu) Server at 103.69.126.36 Port 80 how can i solve this error

Please or to participate in this conversation.