在阿里云(aliyun)服务器上搭建RubyOnRails环境
2023-06-13 09:15:28 时间
1、阿里云的一键安装web全环境
下载一键安装web全环境sh.zip压缩包
上传至服务器,解压、执行脚本,具体步骤详见这里
$mvsh.zip/home/tmp/&cd/home/tmp $unzipsh.zip $chmod-R777sh&cdsh #任意选择一种方法执行脚本 #方法一 $./install.sh #方法二 $./install_nginx_xxx.sh $./install_mysql_xxx.sh
2、安装RVM与指定的Ruby版本
安装RVM与指定的Ruby版本
$curl-Lhttps://get.rvm.io|bash-sstable--ruby=1.9.3 #注意安装完成后,根据提示执行source命令
查看是否安装成功
$ruby-v ruby1.9.3p448(2013-06-27revision41675)[i686-linux] $gem-v 2.1.9
更换gemsource,提高gem下载速度
$gemsource-rhttps://rubygems.org/$gemsource-ahttp://ruby.taobao.org
3、安装git、编译javascript运行时环境node.js
安装git工具
$yuminstallgit
编译node.js(javascript运行时环境)
$gitclonehttps://github.com/joyent/node.git $cdnode $./configure&&make&&makeinstall #如果无法编译,说名需要叫python升级到2.6或2.7 #如果缺少bz2,需要yuminstallbzip2-devel后,重新编译python
克隆你的项目
$gitclonepath/to/your/project.git #安装项目指定gem包 $cdpath/to/your/project $bundleinstall
4、配置unicorn文件并运行生产环境
查看unicorn配置实例config/unicorn.rb
启动unicron生产环境
$unicorn_rails-cconfig/unicorn.rb-Eproduction-D
关闭unicorn进程
$kill-9$(cattmp/pids/unicorn.pid)
5、配置nginx虚拟主机
添加nginx虚拟主机配置
$vim/path/to/your/nginx/vhosts/xxxx.conf
配置内容(将汉字替换成相应有效内容):
upstreamunicorn_server { serverunix:项目根目录/tmp/sockets/unicorn.sockfail_timeout=0; } server { listen80; server_name域名; root项目根目录/public; location/ { proxy_redirectoff; proxy_set_headerHost$host; proxy_set_headerX-Forwarded-Host$host; proxy_set_headerX-Forwarded-Server$host; proxy_set_headerX-Real-IP$remote_addr; proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for; proxy_bufferingon; if(!-f$request_filename){ proxy_passhttp://unicorn_server; break; } } location~^/(assets)/ { expiresmax; add_headerCache-Controlpublic; } }
友情提示
低内存服务器添加内存释放任务
$vim/etc/crontab
在最后一行添加如下内容(每天凌晨1点释放内存):
001***echo3>/proc/sys/vm/drop_caches
相关文章
- Linux下安装Tomcat服务器和部署Web应用
- DNS服务器搭建(Linux版本)
- 服务器与域名备案
- 利用frp内网穿透工具给阿里云服务器减压 - wuuconix's blog
- gzip的使用 - TCP聊天文件服务器v2.3 - 文件传输建立缓存制度和.gz的解压缩/压缩解决运行内存过大
- Linux 服务器上快速配置阿里巴巴 OPSX NTP服务
- 教你阿里云服务器怎么做域名解析步骤
- 搭建专属服务器:阿里云Linux服务器(阿里云的linux服务器)
- 阿里云Linux虚拟主机:远离服务器烦恼,信心满满的服务体验(阿里云linux虚拟主机)
- 管理Linux服务器的静态路由:如何删除?(删除静态路由Linux)
- 快速搭建云服务器:阿里云Linux镜像下载(阿里云linux镜像下载)
- 安装Linux,让服务器更强大!(给服务器装linux系统)
- 架设快乐靠自己:鸟哥的Linux私房菜服务器架设之旅(鸟哥的linux私房菜服务器)
- 部署阿里云快捷部署Linux服务器简易指南(阿里linux服务器)
- 使用阿里云Linux快速搭建FTP服务器(阿里云linuxftp)
- 阿里云服务器挂载数据盘
- 快速搭建Linux服务器RPC安装配置(linux配置rcp)
- 服务器Xshell快速连接Linux服务器的技巧(xshell连接linux)
- Linux服务器实现域名解析的深度配置(linux域名解析配置)
- Linux服务器网站配置:实现快速有效上线(linux 网站配置)
- 阿里云服务器新建用户具体方法