user4782429
user4782429

Reputation:

"The requested URL was not found on this server" error in laravel php project

I started to develop a project with laravel. I installed it using this link how-to-install-laravel-on-ubuntu-lamp.

I installed composer successfully, and using this command : sudo composer create-project laravel/laravel /home/egz-pc/laravel-project I created new project named laravel-project then a changed permissions using chmod 777 command.I restart apache and execute my project.

My problem is that when I type in browser: http://localhost/laravel-project I'm getting an error: The requested URL /laravel-project was not found on this server. If I create a project in /var/www/html on my local host I have no problems, and that error does not appear. What can I do?

Upvotes: 4

Views: 6763

Answers (1)

Golden_flash
Golden_flash

Reputation: 492

The Apache server is installed on var/www/html.This is the default root directory of apache.

Either change the root directory of Apache or move the project to var/www/html.

To change Apache's root directory,

Run

 cd /etc/apache2/sites-available

Then open the 000-default.conf file using the command

 nano 000-default.conf 

Edit the DocumentRoot

enter image description here

Then restart the apache server

sudo service apache2 restart

If you get "Forbidden You don't have permission to access / on this server" after changing the root of apache then do follow these steps

1.Find the apache2.conf located in etc/apache2 and open it using

 nano apache2.conf

2.Use ctrl+w and search for Directory (It should be in line 153)

3.It should look like this

<Directory />
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all denied
</Directory>

4.Change it to

<Directory />
    Options Indexes FollowSymLinks Includes ExecCGI
    AllowOverride All
    Require all granted
</Directory>

enter image description here 5.Restart apache2 and it should work.

EDIT:

I have made a script that lets you change Apache root directory in 1 command.

Link: Script for Apache

Upvotes: 4

Related Questions