Laravel Homestead(Windows) [英] Laravel Homestead (Windows)
问题描述
今天,我一直在尝试与Laravel Homestead一起安装Laravel库.但是我似乎无法使其正常运行.
Today I have been trying to install the Laravel library together with Laravel Homestead.. But I can't seem to get it working.
首先,Laravel文档告诉您要做:composer global require "laravel/homestead=~2.0"
,但是没有用.
The first thing, Laravel documentation tells you to do: composer global require "laravel/homestead=~2.0"
, but it didn't work.
所以我在互联网上搜索了一些内容,发现:composer global require "laravel/homestead=~3.0"
确实有效.
So I searched the internet some and found: composer global require "laravel/homestead=~3.0"
, which actually worked.
但是现在当我尝试在命令行中运行homestead
命令时,它会为我提供以下信息: http://prntscr.com/9perhj ,这是它唯一给我的东西.
But now when I try to run the homestead
command in my command line, it gives me this: http://prntscr.com/9perhj, that's the only thing it's giving me.
我已将目录添加到我的路径变量中.
I have added the directory to my path variable.
我希望有人能帮助我.
提前谢谢!
推荐答案
这是一个老问题,但是我认为我会提出答案,因为我花了很多时间才把它弄对,并且我记录了该过程.这样做,这样以后我就不会再遇到困难了.
This is an old question but I thought I'd put up my answer since it took me multiple tries to get it right and I documented the process while I was doing it so I wouldn't have such a hard time in the future.
注意:您不应在计算机上安装NginX,PHP,MySQL等. Vagrant Homestead虚拟盒子提供了所有这些功能.我遇到了一些问题,我的机器上装有NginX和MySQL,并且当它应该连接到虚拟机的MySQL时,它正在连接到本地计算机的MySQL.
Note: You should NOT have NginX, PHP, MySQL, etc. installed on your machine. The Vagrant Homestead virtual box provides all of this functionality. I had some issues where I had NginX and MySQL on my machine and it was connecting to my local machine's MySQL when it should be connecting to the virtual box's MySQL.
事不宜迟,这是我为Windows 7计算机设置的方法:
Without further ado, this is how I set it up for my Windows 7 machine:
-
先决条件:
Prerequisites:
VirtualBox:
VirtualBox:
https://www.virtualbox.org/wiki/Downloads
无业游民:
https://www.vagrantup.com/downloads.html
Git Bash:感觉像Linux终端的终端.您可以在Windows的Ubuntu服务器上完成所有操作.
Git Bash: A terminal that feels like a Linux terminal. You can do everything you do on an Ubuntu server in Windows.
https://git-scm.com/downloads
Putty:我用于连接到VirtualBox Homestead服务器的Telnet客户端
Putty: Telnet client that I used for connecting to my VirtualBox Homestead server
http://www.putty.org/
创建项目文件夹
create project folder
打开项目文件夹中的终端(类似E:\ Projects \ Vagrant)
open terminal in project folder (something like E:\Projects\Vagrant)
键入无用盒添加laravel/homestead"
type 'vagrant box add laravel/homestead'
输入'git clone https://github.com/laravel/homestead.git 宅基'
type 'git clone https://github.com/laravel/homestead.git Homestead'
这会将Homestead安装在指定的项目文件夹中.
This installs Homestead in the designated project folder.
键入"cd Homestead"
type 'cd Homestead'
键入"bash init.sh"或"init.bat"
type 'bash init.sh' OR 'init.bat'
这将在以下位置创建一个文件夹
This creates a folder in:
C:\Users\USERNAME\.homestead
具有以下文件:
Homestead.yaml
如果打开Homestead.yaml文件,它应该看起来像这样:
If you open the Homestead.yaml file it should look something like this:
---
ip: "192.168.10.10"
memory: 2048
cpus: 1
provider: virtualbox
authorize: ~/.ssh/id_rsa.pub
keys:
- ~/.ssh/id_rsa
folders:
- map: ~/Code
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
databases:
- homestead
〜/"文件夹等效于:
C:\Users\USERNAME\
更改:
folders:
- map: ~/Code
to: /home/vagrant/Code
sites:
- map: homestead.app
to: /home/vagrant/Code/Laravel/public
收件人:
folders:
- map: E:/Projects/Vagrant/Homestead
to: /home/vagrant/Homestead
sites:
- map: WEBSITE.dev
to: /home/vagrant/Homestead/Laravel/public
转到C:\ Windows \ System32 \ drivers \ etc
goto C:\Windows\System32\drivers\etc
在文本编辑器中打开文件主机"
open the file 'hosts' in a text editor
添加"192.168.10.10 WEBSITE.dev"(IP地址应与Homestead.yaml文件中的IP地址匹配)
add '192.168.10.10 WEBSITE.dev' (the IP address should match the IP address in the Homestead.yaml file)
在E:/Projects/Vagrant/Homestead文件夹中打开一个终端
open a terminal in E:/Projects/Vagrant/Homestead folder
输入'ssh-keygen -t rsa -C"USERNAME@gmail.com"'
type 'ssh-keygen -t rsa -C "USERNAME@gmail.com"'
这将创建文件夹C:\ Users \ USERNAME.ssh并设置您的SSH密钥
This creates the folder C:\Users\USERNAME.ssh and sets up your SSH Key
类型为'vagrant init laravel/homestead'
type 'vagrant init laravel/homestead'
输入无所作为"
您应该看到Homestead在VirtualBox中运行
You should see Homestead running in VirtualBox
完成后,您可以使用无用销毁"功能将其杀死
You can use 'vagrant destroy' to kill it when done
使用putty.exe登录到Homestead
Use putty.exe to log in to Homestead
IP地址:127.0.0.1 端口:2222
IP Address: 127.0.0.1 Port: 2222
登录为:无业游民 密码:无业游民
login as: vagrant password: vagrant
一切都准备就绪
这篇关于Laravel Homestead(Windows)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!