1

Login route using localhost/project/public/login url shows error:

The requested URL /test/public/login was not found on this server. Apache/2.4.34 (Ubuntu) Server at localhost Port 80

But using php artisan serve command it works perfectly fine.

What could be wrong?

arghtype
  • 4,376
  • 11
  • 45
  • 60
Himani Bhatt
  • 41
  • 1
  • 7

3 Answers3

1

solved: OS: ubuntu 18.10

/etc/apache2/apache2.conf

add this line into this apache2.conf file:

<Directory /var/www/html/> AllowOverride all </Directory>

Himani Bhatt
  • 41
  • 1
  • 7
1

The most common error in this situaion is related to unable mod_rewrite in apache do this :

sudo a2enmod rewrite
systemctl restart apache2
mohammad asghari
  • 1,817
  • 1
  • 16
  • 23
0

There are many reasons why your local host is not working. Following could be one of the reasons:

1.Make sure that in /etc/apache2/sites-available/your-conf.conf file contains these things :

    ServerName     www.your-url.test
    ServerAlias    your-url.test
    ServerAdmin    webmaster@localhost
    DocumentRoot   /your-path/your-project/public

    <Directory /your-path/your-project>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
    </Directory>
  1. Problem could be with your PHP version. In our machine, there are two php:

     1. For CLI(command line interface)
     2. For apache server
    

    Your laravel application may require higher or lower version of php in apache server. For fixing that either update your php version in apache server to your required version or either setup the fpm for your projects. Then your localhost will start working.

  2. There could be an error in your laravel application. For checking that use command: sudo tail -f /var/log/apache2/error.log

After hitting this command you'll see the errors that your laravel application is throwing.

But since your laravel application is running fine using serve command, so most likely problem in your case will be because of different PHP versions in CLI and apache server(front-end). So you should either setup fpm or either upgrade or downgrade the apache server php version.

I had the same problem and i fixed it by setting up the fpm for my projects. Thanks