在本教程中,我们将在Windows、Ruby2.4.0、Rails 5.0.1和PostgreSQL上设置Ubuntu。
-
首先在您的计算机上启用开发人员模式
https://www.youtube.com/watch?v=S6NvjvL3xaI
-
https://www.youtube.com/watch?v=g_5hxfFKDL8
-
然后重新启动计算机。
-
> bash
-
您将看到下一条消息
This will install Ubuntu on Windows, distributed by Canonical
and licensed under its terms available here:
https://aka.ms/uowterms
Press "y" to continue: y
-
Downloading from the Windows Store... 100%
Extracting filesystem, this will take a few minutesâ¦.
-
bash会向您请求一个用户,请记住这个用户,因为每次您需要bash中的根权限时,bash都会向您询问。同样,当你给密码计时时,你不会看到击键,这是正常的,只需继续输入并按
当你完成的时候。
Please create a default UNIX user account. The username does not need to match your Windows username.
For more information visit: https://aka.ms.wslusers
Enter new UNIX username:
Enter new UNIX password:
-
mnt/c/Users/your_username
目录。
安装RVM和Ruby
-
$ gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
-
然后安装GNUP2
$ sudo apt-get install gnupg2
sudo
在命令中,您将被要求输入密码。
-
https://get.rvm.io
$ cat rvm.sh | bash -s stable
$ source ~/.rvm/scripts/rvm
-
$ rvm install ruby-2.4.0
如果需要安装其他版本的Ruby,请运行如下相同的命令
$ rvm install ruby-2.3.5
$ rvm --default use 2.3.5
$ ruby -v
-
安装rubys包管理器bundler
$ gem install bundler
-
$ curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
$ sudo apt-get install -y nodejs
-
安装导轨
$ gem install rails
-
下载PostgreSQL安装程序并按照安装说明操作
https://www.openscg.com/bigsql/postgresql/installers.jsp/
-
database.yml
-
安装完成后,返回bash并键入下一个命令
$psql -p 5432 -h localhost -U your_postgresql_username
-
psql (9.5.6, server 9.6.2)
WARNING: psql major version 9.5, server major version 9.6.
Some psql features might not work.
Type "help" for help.
postgres=#
-
-
development:
database: your_app_name_development
username: your_postgres_user
password: your_postgres_password
host: localhost
port: 5432
test:
database: your_app_name_test
username: your_postgres_user
password: your_postgres_password
host: localhost
port: 5432
-
$ cd Projects/my_app
要了解有关bash导航的更多信息,请访问
https://www.pluralsight.com/guides/beginner-linux-navigation-manual
-
$ rake db:create
-
$ rails s
-
去你的浏览器访问
$ localhost:3000
>bash -l
https://www.digitalocean.com/community/tutorials/how-to-install-ruby-and-set-up-a-local-programming-environment-on-windows-10
https://medium.com/@colinrubbert/installing-ruby-on-rails-in-windows-10-w-bash-postgresql-e48e55954fbf