Reputation:
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
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
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>
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