在Apache + mySQL环境中的AWS EC2上找不到Laravel ReST API URL 404 - 在此服务器上找不到请求URL

时间:2018-06-16 21:05:10

标签: laravel amazon-ec2

此问题是关于Apache + mySQL AWS EC2实例的AWS Laravel实施。

从xampp / htdocs / my_project_name复制工作的Laravel文件夹后,迁移到mySQL数据库和浏览器中的表创建工作正常。 但是,我无法使用Postman连接到我的API。 (404未找到)

我遵循这些解决方案链接 laravel the requested url was not found on this server https://laracasts.com/discuss/channels/general-discussion/laravel-5-the-requested-url-was-not-found-on-this-server

我设法修改了httpd.conf。但是,我找不到文件.htaccess (

我可以找到.htacces吗?抱歉愚蠢的问题,但我找不到:) - MilanNz 2015年3月11日12:30 @MilanNz .htaccess可以在应用程序的公共目录中找到。但是,这个答案的代码在vhost文件中。它的位置取决于您的服务器。 (例如,对于apache2和unix,它通常位于/ etc / apache2 / sites-available)

另外,我无法使用“service apache2 restart”重新启动Apache。 所以我“sudo reboot”编辑EC2实例并使用Postman重新连接,但仍未找到API网址。

我的网址可能有误。所以我在这里附上: 使用的网址是http://ec2-??-??-???-??.us-east-2.compute.amazonaws.com/my_project_name/public/api/resultCRUD/list 工作xampp网址为http://localhost/my_project_name/public/api/resultCRUD/list

Laravel项目文件夹位于AWS EC2上的/ var / www / html / my_project_name。

http://ec2-??-??-???-??.us-east-2.compute.amazonaws.com/phpinfo.phphttp://ec2-??-??-???-??.us-east-2.compute.amazonaws.com/phpMyAdmin/正在发挥作用。

非常感谢任何帮助。谢谢!

1 个答案:

答案 0 :(得分:1)

终于可以了。 我被困的原因是,当我使用RedHat时,大多数答案都是针对ubuntu的。 对于RedHat EC2实例,首先需要在https://pinecode.io/article/setting-up-laravel-56-on-aws-linux之后更改/etc/httpd/conf/httpd.conf的内容, 在这一步中,我实际上将所有“ AllowOverride None”更改为“ AllowOverride All”,而不仅仅是httpd.conf的第151行。

然后需要使用sudo服务重新启动httpd httpd restart 跟随https://gistpages.com/posts/enable_mod_rewrite_in_apache2_on_red_hat_linux

然后一切正常。

当我问这个问题时,将更改保存到httpd.conf后,我没有重新启动apache服务。

相关问题