- 浏览: 302722 次
- 性别:
- 来自: 武汉
文章分类
最新评论
-
masuweng:
如何给新人机会 -
masuweng:
多sql结果集按列合并新结果报表实现方案 -
Ahe:
赞
坚持长跑方能赢 -
masuweng:
好好好
程序员如何更好的了解自己所做的事情 -
小楠人:
laoguan123 写道楼主好,使用过一些excel导入导出 ...
excell导入导出
登录阿里云后首先
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
#载入 RVM 环境
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bashrc
$ source ~/.bashrc
$ rvm -v
mac安装rvm下:
https://www.jianshu.com/p/c073e6fc01f5
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.4.1
$ rvm use 2.4.1 --default
rvm gemset create 3color244
----------
安装memcached:
sudo apt-get install memcached
ruby元编程的首次尝试和 memcached的使用
https://blog.csdn.net/select603/article/details/8472112
安装MySQL
$ sudo apt-get install mysql-server
sudo apt-get install mysql-server=5.5.40-0ubuntu0.12.04.1
----
Ubuntu 使用apt-get install安装制定版本的mysql
https://blog.csdn.net/dazhi_100/article/details/41980959
sudo apt install mysql-server-5.6
sudo apt install mysql-client-5.6
# 加数据库驱动
# 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
redis安装:
sudo apt-get install redis-server
后台启动sidekiq
RAILS_ENV=production bundle exec sidekiq -d -C config/sidekiq.yml
or
bundle exec sidekiq | logger -t sidekiq
sidekiq安装及使用
https://www.cnblogs.com/znsongshu/p/10349774.html
---------
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.
启动linux
ps auxw | grep nginx
sudo /opt/nginx/sbin/nginx
/opt/nginx/sbin/nginx -s reload
lsof -i:3001
参考:
[url] https://ruby-china.org/topics/32851[/url]
Integrating Action Cable with Passenger + Nginx:
https://www.phusionpassenger.com/library/config/nginx/action_cable_integration/
卸载 nginx 彻底删除
https://blog.csdn.net/sinat_34344123/article/details/79105254
-----------------由于用到了ActionCable需要用puma代替-------------------
使用 Nginx + Puma 部署 Rails 应用
https://www.jianshu.com/p/7a25c0e4daa6
Puma: 为并发而生的Ruby Web服务器
https://www.jianshu.com/p/1bbc6ef924ce?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation
Nginx + Puma 配置
puma服务启动:
puma -e production
bin/rails s -e production
1. 安装 Nginx
unbuntu 下直接通过 apt-get 安装就可以了。
sudo apt-get install nginx
查找错误,处理方法:
sudo nginx -t
重启 Nginx
$ sudo service nginx restart
nginx 配置文件
/etc/nginx/sites-enabled/default
puma.rb文件配置:
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
#载入 RVM 环境
$ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bashrc
$ source ~/.bashrc
$ rvm -v
mac安装rvm下:
https://www.jianshu.com/p/c073e6fc01f5
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.4.1
$ rvm use 2.4.1 --default
rvm gemset create 3color244
----------
安装memcached:
sudo apt-get install memcached
ruby元编程的首次尝试和 memcached的使用
https://blog.csdn.net/select603/article/details/8472112
安装MySQL
$ sudo apt-get install mysql-server
sudo apt-get install mysql-server=5.5.40-0ubuntu0.12.04.1
----
Ubuntu 使用apt-get install安装制定版本的mysql
https://blog.csdn.net/dazhi_100/article/details/41980959
sudo apt install mysql-server-5.6
sudo apt install mysql-client-5.6
# 加数据库驱动
# 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
redis安装:
sudo apt-get install redis-server
后台启动sidekiq
RAILS_ENV=production bundle exec sidekiq -d -C config/sidekiq.yml
or
bundle exec sidekiq | logger -t sidekiq
sidekiq安装及使用
https://www.cnblogs.com/znsongshu/p/10349774.html
---------
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.4.1@chemicalin/gems/passenger-5.0.30; passenger_ruby /usr/local/rvm/gems/ruby-2.4.1@chemicalin/wrappers/ruby; include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 3001; server_name localhost; passenger_enabled on; root /opt/www/chemicalin/public; #charset koi8-r; } }
启动linux
ps auxw | grep nginx
sudo /opt/nginx/sbin/nginx
/opt/nginx/sbin/nginx -s reload
lsof -i:3001
参考:
[url] https://ruby-china.org/topics/32851[/url]
Integrating Action Cable with Passenger + Nginx:
https://www.phusionpassenger.com/library/config/nginx/action_cable_integration/
卸载 nginx 彻底删除
https://blog.csdn.net/sinat_34344123/article/details/79105254
-----------------由于用到了ActionCable需要用puma代替-------------------
使用 Nginx + Puma 部署 Rails 应用
https://www.jianshu.com/p/7a25c0e4daa6
Puma: 为并发而生的Ruby Web服务器
https://www.jianshu.com/p/1bbc6ef924ce?utm_campaign=maleskine&utm_content=note&utm_medium=seo_notes&utm_source=recommendation
Nginx + Puma 配置
puma服务启动:
puma -e production
bin/rails s -e production
1. 安装 Nginx
unbuntu 下直接通过 apt-get 安装就可以了。
sudo apt-get install nginx
查找错误,处理方法:
sudo nginx -t
重启 Nginx
$ sudo service nginx restart
nginx 配置文件
/etc/nginx/sites-enabled/default
http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; upstream app { server unix:///opt/www/chemicalin/tmp/sockets/puma.sock; } server { listen 3001; server_name localhost; # passenger_enabled on; # root /opt/www/chemicalin/public; #charset koi8-r; location /cable { proxy_pass http://localhost:3000; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; } location / { root /opt/www/chemicalin/public; index index.html index.htm; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; if (-f $request_filename.html) { rewrite (.*) $1.html break; } if (!-f $request_filename) { proxy_pass http://app; break; } } }
puma.rb文件配置:
dir = ENV['PWD'] sdir = ENV['PWD'] plugin :tmp_restart port 3000 workers 4 threads 5, 64 environment 'production' directory dir daemonize true prune_bundler true preload_app! bind "unix://#{File.expand_path('tmp/sockets/puma.sock', sdir)}" pidfile "#{File.expand_path('tmp/pids/puma.pid', sdir)}" state_path "#{File.expand_path('tmp/sockets/puma.state', sdir)}" activate_control_app "unix://#{File.expand_path('tmp/sockets/pumactl.sock', sdir)}" stdout_redirect "#{File.expand_path('log/puma.stdout.log', sdir)}", "#{File.expand_path('log/puma.stdout.log', sdir)}" on_worker_boot do ActiveRecord::Base.establish_connection if defined?(ActiveRecord) end on_restart do puts '- * - On Production restart - * -' puts 'pidfile: ' puts @options[:pidfile] puts 'binds: ' puts @options[:binds] puts 'control_url: ' puts @options[:control_url] puts '- * - * - * -' end
发表评论
-
git仓库创建
2020-09-04 15:33 713推送现有文件夹 cd existing_folder git ... -
puma高并发
2020-08-19 09:31 478nginx突发大量502报错 top看一下,cpu的占用并不高 ... -
git
2019-05-05 18:26 422git tag — 标签相关操作 http://blog.c ... -
searchkick
2019-04-10 11:30 0# 通用查询块(条件) def general_ ... -
导入线下excell业务数据按权重匹配线上数据
2019-03-07 11:00 904业务场景:(系统间还没有接口对调,订单号暂时需要线下处理) 线 ... -
两对象同时映射一对一和一对多
2019-02-20 10:14 856class Kpi::Team < Applicat ... -
ruby一些类加载方式
2018-12-21 10:12 568require_dependency 'order/sco ... -
基于ruby的gem remotipart的异步上传文件
2018-12-21 10:11 537针对某一对象保存实例化之前,异步上传图片保存。 gem ' ... -
基于html2canvas的长图分享
2018-12-21 10:11 1162<span class="ui label ... -
rails处理上传读取excell&生成excell
2018-12-20 14:15 995gem 'spreadsheet' gem 'roo', ... -
基于ruby Mechanize的爬虫
2018-12-20 13:09 689def self.sang_carwler ... -
一些常用加密方式
2018-12-20 13:02 732sign = OpenSSL::Digest::SHA256. ... -
ruby 调用restful接口示例
2018-12-20 12:02 931链接参数中添加token def self.query_p ... -
rails错误日志记录
2018-12-19 14:41 778Rails中对日志的处理采用的是“消息-订阅”机制,各部分组件 ... -
railsAPI接收Base64文件
2018-12-18 11:05 1044tmp_dir = " ... -
ruby 调用savon接口示例
2018-12-18 10:51 1036例子一 module Api module Aob ... -
关于国际商城现货展示与购物车的费用设计
2018-11-15 18:34 448关于国际商城现货展示 ... -
基于多线程的全局变量
2018-10-31 19:50 1181def current_nation def ... -
hash最小值过滤算法
2018-10-31 09:52 1092[["数量","包装" ... -
打包订单单据发给货代
2018-09-11 15:43 1181pdf&excell&png # rend ...
相关推荐
Ruby on Rails:部署Rails应用至Heroku.docx
《再次发一本部署rails的书》是一本专注于Rails应用部署实践的书籍,旨在帮助开发者们理解和掌握将Rails项目上线到生产环境的全过程。Rails是Ruby编程语言的一个热门Web开发框架,以其“约定优于配置”(Convention ...
在构建高性能、高可用性的Web应用环境中,"基于Ubuntu Nginx Mongrel Mysql部署rails monit-5.0"的方案是一个常见的选择。这个方案结合了多种强大的工具和技术,以确保应用程序的稳定运行和高效管理。以下是这些关键...
moonshine, 简单的Rails 部署和配置管理 15分钟部署 Rails 2,3或者应用 MoonshineMoonshine的Rails 部署和配置管理正确完成。通过利用 Capistrano 和 puppet,Moonshine允许你在 15分钟内拥有一个工作应用服务器,...
capistrano-3-rails-template, 使用 Capistrano 3部署 Rails 应用程序的模板 Capistrano 3 Rails 配置概述这是部署带有的Ruby on Rails 应用程序的示例配置,包括使用Unicorn和Sidekiq后台员工部署的零停机。...
我做 rails 开发人员已经一年多了,每次我必须部署一个 rails 应用程序时,我总是想拿至少 15 只无辜的小猫,用一把浸在强酸中的长柄斧暴露它们的内脏足以扭曲时空连续体。 让我告诉你两个主要原因:1. 建立基础...
使用Docker部署Rails应用程序 讲师: 本课程将介绍使用Docker容器部署标准数据库支持的Rails应用程序的过程。 由于该过程的功能集和易于部署,更有价值的部署的潜力,该过程正变得越来越受欢迎。 在本课程中,我们...
标题 "rails 部署 nginx" 涉及到的是在Web开发中使用Ruby on Rails框架结合Nginx服务器进行应用部署的相关知识。Nginx以其高性能、稳定性以及反向代理和负载均衡能力,常被用作Rails应用的前端服务器。下面将详细...
**标题解析:** "使用Mina轻松部署Rails(而且确实非常快!)" 这个标题指出,我们将探讨如何利用Mina工具高效且迅速地部署Ruby on Rails应用。Mina是一个轻量级、基于任务的部署工具,它允许开发者以SSH协议在远程...
Ruby on Rails,通常简称为Rails,是一个基于Ruby编程语言的开源Web应用框架,遵循MVC(Model-View-Controller)架构模式。这个“Rails项目源代码”是一个使用Rails构建的图片分享网站的完整源代码,它揭示了如何...
博文链接:https://swachian.iteye.com/blog/175033
了解并正确运用MVC模式是构建高效、可维护的Rails应用的关键。 #### 6. Helpers, Forms, and Layouts(辅助方法、表单和布局) Rails提供了一系列辅助方法来简化HTML的生成和页面的布局。同时,表单是Web应用中不...
### Ruby on Rails 安装与部署知识要点 #### 一、前言 在进行 Ruby on Rails 的安装与部署过程中,我们需要关注几个核心方面:系统版本兼容性、软件依赖包的选择与安装、Ruby 语言环境的配置以及 Rails 应用的具体...
而在Rails开发中,合适的编辑器可以提高代码编写和管理的效率,Linux命令行则对于部署和维护开发环境有着重要作用。 为了确保读者能够通过实践加深理解,书中还安排了一系列练习作业,从最基础的“Hello World”...
Heroku、DigitalOcean和AWS等云平台为Rails应用提供了便捷的部署选项。 总的来说,Ruby on Rails实践涉及的知识点包括但不限于:Ruby语言基础、Rails框架结构、MVC模式、ActiveRecord、路由、测试驱动开发、插件和...
花了两周时间 Google 部署方法,找的的许多方法都没有用,最终被我用控制变量法,一条一条修改配置文件修改成功了。 首先是 /etc/nginx/vhosts/limlog.sloger.info.conf 和 config/puma.rb # # /etc/nginx/vhosts/...