登录阿里云后首先
sudo apt-get update
apt-get install git curl clang make nodejs openssl libssl-dev libreadline6-dev zlib1g-dev libyaml-dev libxml2-dev libxslt1-dev libpq-dev libmysqlclient-dev libsqlite3-dev libcurl4-openssl-dev unzip
———————————————
安装rvm
$ curl -L https://get.rvm.io | bash -s stable
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bashrc
$ source ~/.bashrc
$ rvm -v
reboot重启rvm groop分组权限
-----
# rvm如果安装失败参考命令
curl -sSL https://get.rvm.io | bash -s stable
#或者
curl -L https://rvm.io | bash -s stable
安装RVM依赖等
$ rvm requirements
$ rvm pkg install readline
$ rvm pkg install openssl
$ rvm install 2.3.1
$ rvm use 2.3.1 --default
rvm gemset create 3color244
----------
安装MySQL
$ sudo apt-get install mysql-server
# 加数据库驱动
# mysql client is missing. You may need to 'apt-get install libmysqlclient-dev'
apt-get install libmysqlclient-dev
--------
在使用Ubuntu的时候发现不管是终端输入中文还是终端显示中文,都会出现中文显示为问号的问题。 .解决办法如下:
sudo locale-gen zh_CN.UTF-8 即可完成中文字符集的添加,之后中文就显示正常了。
出现上面问题的原因是rails生产环境没有配置secret_key_base变量,解决方法:
$ cd project
$ bundle exec rake secret # rails 4.2.6还需要bundle exec,请根据rails版本自行匹配
跑起来项目:
git clone your project 项目拉下来。
这样代码就下载到服务器上了,然后安装gem
$ cd project
$ bundle install
创建生产环境数据库并执行迁移
$ RAILS_ENV=production rake db:create
$ RAILS_ENV=production rake db:migrate
否则最终网站页面会显示(之前heroku部署时也经常遇到)
We're sorry, but something went wrong
重新compile assets,这样所有的图片,CSS,scripts才会加载
$ RAILS_ENV=production rake assets:precompile
版权声明:本文由 数控等离子切割机 http://www.hycsk.com 整理编辑!本文章来源于网络,如有侵权,请联系云栖社区,欢迎分享本文,转载请保留出处!
---------
Step6: 安装Passenger for Nginx (注意内存必须大于1g)
Nginx是HTTP服务器,运行nginx类似于本地开启rails server,才能实现网站的访问,首先安装passenger:
$ gem install passenger
然后通过source编译的方式安装Nginx
$ rvmsudo passenger-install-nginx-module
Step6: 安装Passenger for Nginx
rvmsudo passenger-install-nginx-module
一路回车即可,在这里选择1回车:
Automatically download and install Nginx?Nginx doesn't support loadable modules such as some other web servers do, so in order to install Nginx with Passenger support, it must be recompiled.Do you want this installer to download, compile and install Nginx for you?
1. Yes: download, compile and install Nginx for me. (recommended) The easiest way to get started. A stock Nginx 1.4.4 with Passenger support, but with no other additional third party modules, will be installed for you to a directory of your choice.
2. No: I want to customize my Nginx installation. (for advanced users) Choose this if you want to compile Nginx with more third party modules besides Passenger, or if you need to pass additional options to Nginx's 'configure' script. This installer will 1) ask you for the location of the Nginx source code, 2) run the 'configure' script according to your instructions, and 3) run 'make install'.
Whichever you choose, if you already have an existing Nginx configuration file, then it will be preserved.Enter your choice (1 or 2) or press Ctrl-C to abort:1[ENTER]
最后看到这句话即安装成功
Nginx with Passenger support was successfully installed.
http {
...
passenger_root /usr/local/rvm/gems/ruby-2.3.1@3color244/gems/passenger-5.0.30;
passenger_ruby /usr/local/rvm/gems/ruby-2.3.1@3color244/wrappers/ruby;
...
}
启动linux
ps auxw | grep nginx
sudo /opt/nginx/sbin/nginx
/opt/nginx/sbin/nginx -s reload
sudo apt-get update
apt-get install git curl clang make nodejs openssl libssl-dev libreadline6-dev zlib1g-dev libyaml-dev libxml2-dev libxslt1-dev libpq-dev libmysqlclient-dev libsqlite3-dev libcurl4-openssl-dev unzip
———————————————
安装rvm
$ curl -L https://get.rvm.io | bash -s stable
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bashrc
$ source ~/.bashrc
$ rvm -v
reboot重启rvm groop分组权限
-----
# rvm如果安装失败参考命令
curl -sSL https://get.rvm.io | bash -s stable
#或者
curl -L https://rvm.io | bash -s stable
安装RVM依赖等
$ rvm requirements
$ rvm pkg install readline
$ rvm pkg install openssl
$ rvm install 2.3.1
$ rvm use 2.3.1 --default
rvm gemset create 3color244
----------
安装MySQL
$ sudo apt-get install mysql-server
# 加数据库驱动
# mysql client is missing. You may need to 'apt-get install libmysqlclient-dev'
apt-get install libmysqlclient-dev
--------
在使用Ubuntu的时候发现不管是终端输入中文还是终端显示中文,都会出现中文显示为问号的问题。 .解决办法如下:
sudo locale-gen zh_CN.UTF-8 即可完成中文字符集的添加,之后中文就显示正常了。
出现上面问题的原因是rails生产环境没有配置secret_key_base变量,解决方法:
$ cd project
$ bundle exec rake secret # rails 4.2.6还需要bundle exec,请根据rails版本自行匹配
跑起来项目:
git clone your project 项目拉下来。
这样代码就下载到服务器上了,然后安装gem
$ cd project
$ bundle install
创建生产环境数据库并执行迁移
$ RAILS_ENV=production rake db:create
$ RAILS_ENV=production rake db:migrate
否则最终网站页面会显示(之前heroku部署时也经常遇到)
We're sorry, but something went wrong
重新compile assets,这样所有的图片,CSS,scripts才会加载
$ RAILS_ENV=production rake assets:precompile
版权声明:本文由 数控等离子切割机 http://www.hycsk.com 整理编辑!本文章来源于网络,如有侵权,请联系云栖社区,欢迎分享本文,转载请保留出处!
---------
Step6: 安装Passenger for Nginx (注意内存必须大于1g)
Nginx是HTTP服务器,运行nginx类似于本地开启rails server,才能实现网站的访问,首先安装passenger:
$ gem install passenger
然后通过source编译的方式安装Nginx
$ rvmsudo passenger-install-nginx-module
Step6: 安装Passenger for Nginx
rvmsudo passenger-install-nginx-module
一路回车即可,在这里选择1回车:
Automatically download and install Nginx?Nginx doesn't support loadable modules such as some other web servers do, so in order to install Nginx with Passenger support, it must be recompiled.Do you want this installer to download, compile and install Nginx for you?
1. Yes: download, compile and install Nginx for me. (recommended) The easiest way to get started. A stock Nginx 1.4.4 with Passenger support, but with no other additional third party modules, will be installed for you to a directory of your choice.
2. No: I want to customize my Nginx installation. (for advanced users) Choose this if you want to compile Nginx with more third party modules besides Passenger, or if you need to pass additional options to Nginx's 'configure' script. This installer will 1) ask you for the location of the Nginx source code, 2) run the 'configure' script according to your instructions, and 3) run 'make install'.
Whichever you choose, if you already have an existing Nginx configuration file, then it will be preserved.Enter your choice (1 or 2) or press Ctrl-C to abort:1[ENTER]
最后看到这句话即安装成功
Nginx with Passenger support was successfully installed.
http {
...
passenger_root /usr/local/rvm/gems/ruby-2.3.1@3color244/gems/passenger-5.0.30;
passenger_ruby /usr/local/rvm/gems/ruby-2.3.1@3color244/wrappers/ruby;
...
}
启动linux
ps auxw | grep nginx
sudo /opt/nginx/sbin/nginx
/opt/nginx/sbin/nginx -s reload