Laravel php 项目中“在此服务器上找不到请求的 URL”错误
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32394953/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"The requested URL was not found on this server" error in laravel php project
提问by
I started to develop a project with laravel. I installed it using this link how-to-install-laravel-on-ubuntu-lamp.
我开始用 Laravel 开发一个项目。我使用此链接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.
我安装composer
成功,并使用此命令:sudo composer create-project laravel/laravel /home/egz-pc/laravel-project
我创建laravel-project
了一个名为的新项目,然后使用 chmod 777 命令更改了权限。我重新启动 apache 并执行我的项目。
My problem is that when I type in browser: http://localhost/laravel-projectI'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?
我的问题是,当我在浏览器中输入:http://localhost/laravel-project我收到一个错误:The requested URL /laravel-project was not found on this server.
如果我在本地主机上的 /var/www/html 中创建一个项目,我没有问题,而且那个错误没有出现。我能做什么?
采纳答案by Golden_flash
The Apache server is installed on var/www/html.This is the default root directory of apache.
Apache服务器安装在var/www/html。这是apache的默认根目录。
Either change the root directory of Apache or move the project to var/www/html.
更改Apache的根目录或将项目移动到var/www/html。
To change Apache's root directory,
要更改 Apache 的根目录,
Run
跑
cd /etc/apache2/sites-available
Then open the 000-default.conf file using the command
然后使用命令打开 000-default.conf 文件
nano 000-default.conf
Edit the DocumentRoot
编辑 DocumentRoot
Then restart the apache server
然后重启apache服务器
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
如果您在更改 apache 的根目录后收到“禁止您无权访问 / 在此服务器上的权限”,请按照以下步骤操作
1.Find the apache2.conf located in etc/apache2 and open it using
1.找到位于etc/apache2中的apache2.conf并使用打开它
nano apache2.conf
2.Use ctrl+w and search for Directory (It should be in line 153)
2.使用 ctrl+w 并搜索目录(应该在第 153 行)
3.It should look like this
3.它应该是这样的
<Directory />
Options Indexes FollowSymLinks
AllowOverride All
Require all denied
</Directory>
4.Change it to
4.改成
<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.
我制作了一个脚本,可让您在 1 个命令中更改 Apache 根目录。
Link: Script for Apache
链接:Apache 脚本