laravel php artisan serve 命令有效,但 url 无效

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42338651/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 15:22:15  来源:igfitidea点击:

php artisan serve command works but url not working

laravel

提问by Shakun Chaudhary

In Laravel 5.4,

在 Laravel 5.4 中,

After running php artisan serve command fresh laravel setup works on this url localhost:8000but when i try to access with public url localhost/lara54/public. it is not working and gives white blank page. I tried this using virtual host in linux giving folder path upto public but still not working.

运行 php artisan serve 命令后,新的 laravel 设置可以在此 url 上运行,localhost:8000但是当我尝试使用公共 url 访问时localhost/lara54/public。它不工作并给出白色空白页。我在 linux 中使用虚拟主机尝试了这个,将文件夹路径设为 public,但仍然无法正常工作。

php artisan serve command also creates a virtual host what i am missing here to make this setup work with URL.

php artisan serve 命令还创建了一个虚拟主机,我在这里缺少它以使此设置与 URL 一起使用。

回答by Deepak Dholiyan

Try using the following --port param:

尝试使用以下 --port 参数:

php artisan serve --port=8000

Hope it helps you because this solves my problem.

希望它可以帮助您,因为这解决了我的问题。

回答by Bercove

Run this command it will work

运行此命令它将起作用

php -S 0.0.0.0:8000

回答by Jigneshsinh Rathod

give permission to following two directories:

授予以下两个目录的权限:

storage

bootstrap/cache

i hope its help you

我希望它对你有帮助

回答by Jigneshsinh Rathod

Default laravel command "php artisan server" return url "localhost:8000" in your browser url, you should type "http://localhost:8000". Because it's use default PHP built in Web Server (read at PHP.net) to serve Laravel Application Direcory for Development.

默认 Laravel 命令“php artisan server”在浏览器 url 中返回 url“localhost:8000”,你应该输入“ http://localhost:8000”。因为它使用内置在 Web 服务器中的默认 PHP(在PHP.net 上阅读)来为 Laravel 应用程序目录提供开发服务。

for production, it recommend use Nginx or Apache, you may read On DigitalOceanfor Nginxor for Apache

对于生产,建议使用 Nginx 或 Apache,您可以阅读 On DigitalOcean for NginxApache