如何在 XAMPP Apache 上正确部署 Laravel 应用程序?

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

How to correctly deploy a Laravel application on XAMPP Apache?

phplaravellaravel-5xampp

提问by LordNeo

I am pretty new in Laraveland I am finding the following problem.

我在Laravel 中很新,我发现了以下问题。

I have put my application in this folder:

我已将我的应用程序放在此文件夹中:

C:\xampp\htdocs\HotelRegistration\

Starting it via the statment:

通过语句启动它:

php artisan serve

it is correctly started here: http://127.0.0.1:8000

它在这里正确启动:http: //127.0.0.1: 8000

For some reason I need to run it with XAMPP Apacheserver instead the one provided by php artisan serve

出于某种原因,我需要使用XAMPP Apache服务器而不是php artisan serve提供的服务器来运行它

So I started Apachefrom XAMPP but trying to open:

所以我从 XAMPP启动了Apache,但试图打开:

http://127.0.0.1:80/HotelRegistration/

but so the application can't start and I obtain the list of directory and file contained in this folder.

但因此应用程序无法启动,我获得了该文件夹中包含的目录和文件的列表。

Why? What is wrong? What am I missing? Maybe something related to virtual host? How can I fix this issue?

为什么?怎么了?我错过了什么?也许与虚拟主机有关?我该如何解决这个问题?

Tnx

田纳西州

回答by LordNeo

php artisan servecreates a web server that shows the publicfolder of your app.

php artisan serve创建一个显示public应用程序文件夹的网络服务器。

As a good practice, you should setup your hosting to show that public folder while hidding the rest of the program from unwanted visitors.

作为一个好习惯,您应该设置您的主机以显示该公用文件夹,同时对不受欢迎的访问者隐藏程序的其余部分。

Check this links about it:

检查这个链接:

https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e

https://medium.com/laravel-news/the-simple-guide-to-deploy-laravel-5-application-on-shared-hosting-1a8d0aee923e

https://deployer.org/blog/how-to-deploy-laravel

https://deployer.org/blog/how-to-deploy-laravel

For development, that isn't too much of a trouble.

对于开发来说,这并不算太麻烦。

回答by Gmnayem

You can use the below to run your application. But it can fail to load the basic css file.

您可以使用以下内容来运行您的应用程序。但它可能无法加载基本的 css 文件。

http://localhost/HotelRegistration/public/

Hope its help you.

希望它对你有帮助。

回答by Gmnayem

Solved by myself, I create a virtual host in Apache and using this URL works

自己解决了,我在Apache中创建了一个虚拟主机并且使用这个URL有效