登陆云端之后,发现报错如下:
ssh [email protected]
The authenticity of host '47.88.0.215 (47.88.0.215)' can't be established.
ECDSA key fingerprint is 25:8a:5a:c8:c6:8e:d2:e3:d9:9b:e2:1c:c1:08:7a:3b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '47.88.0.215' (ECDSA) to the list of known hosts.
[email protected]'s password:
#添加用户yz00
root@iZu1uesm75bZ:~# adduser yz00 --ingroup sudo
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:",
LC_ALL = (unset),
LC_PAPER = "zh_CN.UTF-8",
.......
perl: warning: Falling back to the standard locale ("C").
Adding user `yz00' ...
Adding new user `yz00' (1000) with group `sudo' ...
Creating home directory `/home/yz00' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
create好了之后开始查看远端语系:
root@iZu1uesm75bZ:~# locale -a
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
.......
#所以,远端需下载 zh_CN.UTF-8
root@LePlanet:~# sudo locale-gen zh_CN.UTF-8
Generating locales...
zh_CN.UTF-8... done
Generation complete.
#root@iZu1uesm75bZ:~# sudo locale-gen
Generating locales...
en_AG.UTF-8... done
en_AU.UTF-8... done
en_BW.UTF-8... done
......
Generation complete.
1.然后切换到 yz00 这个用户
su yz00 cd
2. 安装依赖以及ruby语言
sudo apt-get update sudo apt-get install git-core curl zlib1g-dev build-essential \ libssl-dev libreadline-dev libyaml-dev libsqlite3-dev sqlite3 \ libxml2-dev libxslt1-dev libcurl4-openssl-dev software-properties-common cd git clone git://github.com/sstephenson/rbenv.git .rbenv echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc exec $SHELL git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build echo 'export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"' >> ~/.bashrc exec $SHELL
rbenv install 2.1.5
rbenv global 2.1.5
检查ruby版本
ruby -v
3.安装mysql数据库
sudo apt-get install mysql-server mysql-client libmysqlclient-dev
数据库root密码:123
4.安装 nginx 和 passenger
nginx 是一个高速的 web 服务器, passenger 是跑 rails 应用需要的“应用服务器”,总之它们都是服务器。
安装需要的密钥:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7 vi /etc/apt/sources.list
此时报错
E45: 'readonly' option is set (add ! to override)
这些错误往往是我们使用ssh时出现的
vim filename改为vi filename即可,修改完之后
:wq! 即可退出
安装 nginx 和 passenger,注意这样安装,就不用执行
passenger-install-nginx-module
了,以前的运行这个命令的时候经常 会出现由于内存不够导致执行失败,很烦人的。
sudo apt-get install nginx-extras passenger
这时候报错Operation too slow.
关闭命令行之后,重启连接yz00即可。
此时访问对应的域名(http://XXXX.com/)就ok了。
6.安装 javascript 的运行环境,这个是跑 rails 应用必须的。
sudo apt-get install nodejs
7.把代码移过去
scp -r yz00@XXXX(对应域名):
输入密码即可
8.
安装 bundler,并用它来把项目需要的依赖包都安装好
gem install bundler rbenv rehash cd meetup/ bundle
报错又来了....JS环境出了问题
Important: You may need to add a javascript runtime to your Gemfile in order for bootstrap's LESS files to compile to CSS.
**********************************************
ExecJS supports these runtimes:
therubyracer - Google V8 embedded within Ruby
therubyrhino - Mozilla Rhino embedded within JRuby
Node.js
Apple JavaScriptCore - Included with Mac OS X
Microsoft Windows Script Host (JScript)
**********************************************
gem install execjs gem 'therubyracer'
9.填写需要的配置
cd config vim database.yml # 填写数据库的密码
default: &default adapter: mysql2
encoding: utf8
pool: 5 username: root
password: development:
<<: *default
database: db/development.sqlite3 test:
<<: *default database:
db/test.sqlite3 production:
<<: *default
database: shuqian_production
username: root
password: 123(install时设置为123)
10.创建数据库
bundle exec rake db:create db:migrate RAILS_ENV=production
11.把 js/css 等 asset 文件做预处理
bundle exec rake assets:precompile RAILS_ENV=production # precompile 这一句如果不加 RAILS_ENV 设置还是会有问题的,font-awesome 字体文件加载不了
这样的结果是在,public/ 之下出现了很多代哈希值的文件名,粗略的可以认为这样的措施就是为了提高网站访问速度。
12.修改 nginx 和 passenger 配置
打开 nginx 的配置文件:
sudo vim /etc/nginx/nginx.conf
/passen,查找下面两行
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini; passenger_ruby /usr/bin/ruby;
将第二行改为,可以用ctrl+X+F自动补齐代码
passenger_ruby /home/yz00/.rbenv/shims/ruby;
然后要来为 signup 项目,专门创建一个服务器配置文件。
cd /etc/nginx/sites-enabled rm default sudo vim meetup.conf
shuqian.conf 中的内容如下
server { listen 80 default; server_name http://hhcd.cn/; passenger_enabled on; gzip on; root /home/yz00/shuqian/public; }
nginx 的配置修改后,不要忘了重启 nginx 服务器
sudo service nginx restart
touch tmp/restart.txt
上述命令重新加载设置