为什么 laravel homestead 没有运行 Apache
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28691337/
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
Why laravel homestead is not running Apache
提问by Mohamed Kawsara
Obviously, I've Laravel project that really needs the .htaccess
rules and Nginx doesn't seem to be the best solution for me,
显然,我有一个真正需要.htaccess
规则的Laravel 项目,而 Nginx 对我来说似乎不是最好的解决方案,
1- my question is why Laravel didn't provide homestead with Apache! After a small research that I made I found online toolfor converting the rules but the output didn't work (was too short), whereas, Apache is more likely known and usable, plus it's easier to define rules for security and pretty URLs ..etc. ( at least for me )
1-我的问题是为什么 Laravel 没有为 Homestead 提供 Apache!在我进行了一次小型研究后,我找到了用于转换规则的在线工具,但输出不起作用(太短),而 Apache 更有可能为人所知和可用,而且更容易为安全性和漂亮的 URL 定义规则。 。等等。( 至少对于我来说 )
2- Please give me answers explaining why they choose Nginx!, more importantly I need to know what Seniors and Experts will use ( Nginx, Apache )
2- 请给我答案,解释他们为什么选择 Nginx!,更重要的是我需要知道老年人和专家将使用什么(Nginx、Apache)
3- Do you advise me to install Apache on Homestead?
3- 你建议我在 Homestead 上安装 Apache 吗?
采纳答案by MartinJH
Steps are as follows here.
操作步骤如下这里。
SSH into vagrant ->
vagrant ssh
Stop Nginx ->
sudo service nginx stop
Remove it ->
sudo apt-get purge nginx
Update you repos ->
sudo apt-get update
Install apache ->
sudo apt-get install apache2
Restart it ->
sudo service apache2 restart
SSH 进入 vagrant ->
vagrant ssh
停止 Nginx ->
sudo service nginx stop
删除它->
sudo apt-get purge nginx
更新你的回购 ->
sudo apt-get update
安装apache->
sudo apt-get install apache2
重新启动它->
sudo service apache2 restart
You are now on Apache server, update the apache conf file as your needs.
您现在在 Apache 服务器上,根据需要更新 apache conf 文件。
回答by Martijn Imhoff
- Laravel homestead is currently able to install apache using your Homestead.yaml file.
- Laravel homestead 目前可以使用你的 Homestead.yaml 文件安装 apache。
Add a key to your sites called type
. Set it to apache
. like so:
为您的网站添加一个名为type
. 将其设置为apache
。像这样:
sites:
- map: laravel.local
to: "/home/vagrant/laravel"
type: apache
Make sure you don't mix up apache and nginx, that won't work.
确保你没有混淆 apache 和 nginx,那是行不通的。
Then run vagrant up
and to install apache and provision the right config files.
然后运行vagrant up
并安装 apache 并提供正确的配置文件。
If it doesn't work, then first make sure to updateto the latest version of homestead.
如果它不起作用,那么首先确保更新到最新版本的宅基地。
Here is an interesting article on the matter: https://www.nginx.com/blog/nginx-vs-apache-our-view/. TLDR: Nginx is faster.
Only when you have an existing project and you really need to use apache. Or in case your application is going to run on an apache server. Starting fresh? Use nginx.
这是一篇关于此事的有趣文章:https: //www.nginx.com/blog/nginx-vs-apache-our-view/。TLDR:Nginx 更快。
只有当你有一个现有的项目并且你真的需要使用 apache 时。或者,如果您的应用程序将在 apache 服务器上运行。新鲜开始?使用 nginx。
回答by Wader
What exactly are you trying to do and perhaps we can supply a solution to your problem. You shouldn't really need to be rewriting URLs with .htaccess as Laravel's routing handles this.
您到底想做什么,也许我们可以为您的问题提供解决方案。你真的不需要用 .htaccess 重写 URL,因为 Laravel 的路由会处理这个。
1) Regardless of software, if you're needing to configure the webserver for each specific project, its probably better to go and configure your own vagrant box that is relevant for that project.
1)无论软件如何,如果您需要为每个特定项目配置网络服务器,最好去配置与该项目相关的自己的流浪盒。
2) Nginx outperforms apache and reduces a lot of the bloat that simply isn't needed. Its also what forge uses and so homestead uses in turn so its mocking the forge environment.
2) Nginx 优于 apache 并减少了很多根本不需要的膨胀。它也是forge使用的东西,所以homestead依次使用所以它嘲笑forge环境。
3) See point 1, configure your own vagrant box for this project.
3)看第1点,为这个项目配置自己的vagrant box。