我在Windows上遇到了流浪問題。運行vagrant up
,它在SSH驗證上暫停,似乎在VirtualBox控制檯中請求SSH登錄憑據。SSH驗證方法:在VirtualBox中使用私鑰調用登錄
的Windows 8.1控制檯輸出
C:\Users\leke\dev\Learning PHP 7>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Checking if box 'ubuntu/trusty32' is up to date...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 80 (guest) => 8080 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH address: 127.0.0.1:22
default: SSH username: vagrant
default: SSH auth method: private key
的Oracle VM VirtualBox輸出
Ubuntu 14.04.5 LTS vagrant-ubuntu-trusty-32 tty1
vagrant-ubuntu-trusty-32 login:
如果我用私鑰認證,我不應該需要輸入憑據,雖然(我不知道)。
下面是從書中學習PHP 7
流浪漢文件
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "ubuntu/trusty32"
config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1", id: 'ssh'
config.vm.provision "shell", path: "provisioner.sh"
end
provisioner.sh
#!/bin/bash
sudo apt-get install python-software-properties -y
sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php -y
sudo apt-get update
sudo apt-get install php7.0 php7.0-fpm php7.0-mysql -y
sudo apt-get --purge autoremove -y
sudo service php7.0-fpm restart
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
sudo debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
sudo apt-get -y install mysql-server mysql-client
sudo service mysql start
sudo apt-get install nginx -y
sudo cat > /etc/nginx/sites-available/default <<- EOM
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /vagrant;
index index.php index.html index.htm;
server_name server_domain_or_IP;
location/{
try_files \$uri \$uri/ /index.php?\$query_string;
}
location ~ \.php\$ {
try_files \$uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)\$;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME \$document_root\$fastcgi_script_name;
include fastcgi_params;
}
}
EOM
sudo service nginx restart
後,我得到一個超時錯誤消息了我的建立。我需要做什麼才能讓vagrant up
命令通過私鑰進行身份驗證,並希望正確執行?請注意,git已安裝,並且Windows路徑變量中存在ssh.exe。謝謝。
編輯:我設法找到憑據vagrant
和vagrant
,但登錄到虛擬機盒的終端後,Windows控制檯還停留在同一個地方。
更新
添加
config.vm.provider 'virtualbox' do |vb|
vb.customize ['modifyvm', :id, '--cableconnected1', 'on']
end
給了我另外一個問題。當我更改端口時,它會再次給我這個信息,或者給我最初的問題。
C:\Users\leke\dev\Learning PHP 7>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'ubuntu/trusty32'...
==> default: Matching MAC address for NAT networking...
==> default: Checking if box 'ubuntu/trusty32' is up to date...
==> default: A newer version of the box 'ubuntu/trusty32' is available! You currently
==> default: have version '20170502.0.0'. The latest is version '20170504.0.0'. Run
==> default: `vagrant box update` to update.
==> default: Setting the name of the VM: LearningPHP7_default_1494189218317_29456
==> default: Clearing any previously set forwarded ports...
Vagrant cannot forward the specified ports on this VM, since they
would collide with some other application that is already listening
on these ports. The forwarded port to 3344 is already in use
on the host machine.
To fix this, modify your current project's Vagrantfile to use another
port. Example, where '1234' would be replaced by a unique host port:
config.vm.network :forwarded_port, guest: 80, host: 1234
Sometimes, Vagrant will attempt to auto-correct this for you. In this
case, Vagrant was unable to. This is usually because the guest machine
is in a state which doesn't allow modifying port forwarding. You could
try 'vagrant reload' (equivalent of running a halt followed by an up)
so vagrant can attempt to auto-correct this upon booting. Be warned
that any unsaved work might be lost.
如果你可以連接到虛擬機,您可以檢查'/家庭/流浪者/ .ssh'' –
喜權, '.ssh'的權限是'drwx ------'所有者和組是流浪的。 – user126440