本文目录:
- 1、centos6.4怎么开发rails
- 2、如何在 CentOS 上安装 Gitlab
- 3、如何在centos下安装ruby
- 4、centos5.5怎么安装gitlab
- 5、centos 怎么查找ruby安装路径
- 6、如何在Mac OS X上安装 Ruby运行环境
centos6.4怎么开发rails
使用rvm 安装
参考
第一步:安装rvm
增加专属用户
用root登录 , 修改/etc/sudoers 文件 增加 “用户名 ALL=(ALL) ALL“,使得此用户可以做sudo 命令
用普通用户登录sudo yum update
sudo yum install curl
确定现在是普通用户登录!!!(rvm implode 是卸载 rvm)
curl -L get.rvm.io | bash -s stable
source ~/.rvm/scripts/rvm
rvm requirements
sudo yum install gcc-c++ mysql-devel postgresql postgresql-devel sqlite sqlite-devel curl-devel openssl-devel zlib-devel ImageMagick ImageMagick-devel libtool
sudo yum install subversion bash curl git patch
sudo yum install libxml2 libxml2-devel libxslt libxslt-devel
sudo yum install libyaml*
第二步:安装ruby
rvm list known
rvm get branch rys/features/centos-epel-rep
rvm autolibs enable
rvm reload
rvm install 2.0.0
ruby -v
gem list
gem sources -l
gem sources --remove 要删除的源
gem sources -a
第三步:安装rails
gem install rails --version 4.1.6
rails -v
第四步:安装 node.js
[plain] view plain copy
wget
tar zxvf node-v0.10.0.tar.gz
cd node-v0.10.0.tar.gz
./configure
make
make install
第五步: 安装passenger(App Server)
gem install passenger
passenger -v
找到passenger的bin目录
./passenger-2.2.14/bin/passenger-install-nginx-module
或者通过(自己一直采用这个方法)cd ./.rvm/gems/ruby-2.0.0-p0/gems/passenger-3.0.19/bin/
rvmsudo passenger-install-nginx-module
来安装所需要的 pcre 和 openssl(在ruby 2.0下 好像又问题,会产生 cannot load such file -- rubygems/builder 这种错误)
第六步:安装nginx(WebServer)
nginx安装需要pcre and openssl
官网:
wget
tar zxvf pcre-8.32.tar.gz
cd pcre-8.32
./configure
make
make install
官网:
wget
tar zxvf openssl-1.0.1e.tar.gz
cd openssl-1.0.1e
./config
make
make install
wget
tar zxvf nginx-1.3.16.tar.gz
./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/lib
make
make install
运行 nginx
/usr/local/nginx/sbin/nginx
如果出现 error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
解决办法:
1. ldd $(which /usr/local/nginx/sbin/nginx)
出现
linux-vdso.so.1 = (0x00007fff9e7ff000)
libpthread.so.0 = /lib64/libpthread.so.0 (0x00007f6d3cece000)
libcrypt.so.1 = /lib64/libcrypt.so.1 (0x00007f6d3cc97000)
libpcre.so.1 = not found
libcrypto.so.10 = /usr/lib64/libcrypto.so.10 (0x00007f6d3c8fc000)
libz.so.1 = /lib64/libz.so.1 (0x00007f6d3c6e6000)
libc.so.6 = /lib64/libc.so.6 (0x00007f6d3c352000)
/lib64/ld-linux-x86-64.so.2 (0x00007f6d3d0f5000)
libfreebl3.so = /lib64/libfreebl3.so (0x00007f6d3c0f0000)
libdl.so.2 = /lib64/libdl.so.2 (0x00007f6d3beec000)
可以看见 libpcre.so.1 没有被发现
通过 find / -name libpcre.so.1 命令 发现文件存在
/usr/local/lib/libpcre.so.1
然后 通过cp 或者 ls 建立一个链接。即可解决这个问题。
修改nginx的端口的方法
vim /usr/local/nginx/conf/nginx.conf
server {
listen 8081;
...
附上出处链接:
如何在 CentOS 上安装 Gitlab
#gitlab基于ruby开发模仿Github的版本控制软件,因为是开源的,,但是我们确实有这样的需求,相比Gtihub来说可以减少很多成本.
#从安装ruby、git、数据库、web、和gitlab到访问,一定要有耐心.
#安装环境
##[root@localhost config]# uname -r
##2.6.32-279.el6.x86_64
##[root@localhost config]# cat /etc/redhat-release
##CentOS release 6.3 (Final)
一.安装依赖
## 安装epel-release
yum -y install
#安装ruby依赖包
## packages (from rvm install message):
yum -y install libicu-devel patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel mysql-devel
#安装或者更新git
yum -y remove git
yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
wget
tar -zxf git-1.8.3.4.tar.gz
cd git-1.8.3.4
make prefix=/usr all
make prefix=/usr install
cd ..
#安装前版本
[root@gitlab ~]# git –version
git version 1.7.1
#安装后版本
[root@gitlab ~]# git –version
git version 1.8.3.4
二.安装RVM
#RVM工具
curl -L get.rvm.io | bash -s stable
#出现以下信息为安装成功
# Administrator,
#
# Thank you for using RVM!
# We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal team.
#加载RVM,改名(使用淘宝源)
source /etc/profile.d/rvm.sh
cp /usr/local/rvm/config/db /usr/local/rvm/config/db.bk
sed -i 's#' /usr/local/rvm/config/db
sed -i 's#cache.ruby-lang.org/pub/ruby#ruby.taobao.org/mirrors/ruby#' /usr/local/rvm/config/db
#安装libyaml(防止后期报错,可不装)
rvm pkg install libyaml
三.安装ruby
#安装ruby
#rvm install 2.0.0-p247 –with-libyaml-dir=/usr/local/rvm/usr
#rvm –default use 2.0.0-p247
rvm install 2.0.0-p353 –with-libyaml-dir=/usr/local/rvm/usr
rvm –default use 2.0.0-p353
#引用淘宝ruby源
gem sources –remove
gem sources -a
gem sources -l
#安装bundler
gem install bundler –no-ri –no-rdoc
四.安装gitlab-shell
#创建用户git
adduser –system –create-home –comment 'GitLab' git
#复制gitlab-shell到本地
su – git -c "git clone "
su – git -c "cd gitlab-shell;git checkout v1.7.0"
##修改配置文件
su – git -c "cp gitlab-shell/config.yml.example gitlab-shell/config.yml"
##安装
su – git -c "gitlab-shell/bin/install"
五.安装Redis和mysql
#安装Redis,据说高级特性需要
yum -y install redis ;service redis start ; chkconfig redis on
#安装mysql
#安装Mysql数据库.略过,以及数据库操作
##yum install -y mysql-server mysql-devel ; chkconfig mysqld on ; service mysqld start
#编译安装宣告下变量
##export PATH="/opt/mysql/bin:$PATH"
##echo "export PATH="/opt/mysql/bin:$PATH""/etc/profile
##修改root密码
#echo "UPDATE mysql.user SET Password=PASSWORD('$MYSQL_ROOT_PW') WHERE User='root'; FLUSH PRIVILEGES;" | mysql -u root
##创建gitlab数据库
#echo "CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';" | mysql -u root
CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
##创建连接数据库用户
grant all on gitlabhq_production.* to gitlab@localhost identified by '123456';
六.安装gitlab
#复制GitLab到本地
su – git -c "git clone gitlab"
## 检查
su – git -c "cd gitlab;git checkout 5-4-stable"
#以下操作在/home/git/gitlab
cd /home/git/gitlab
### 复制配置文件
su git -c "cp config/gitlab.yml.example config/gitlab.yml"
### 修改配置文件主机名(可以不做)
sed -i "s/ host: localhost/ host: gitlab.test/g" config/gitlab.yml
### 修改邮件地址
sed -i "s/from: gitlab@localhost/from: gitlab@gitlab.test/g" config/gitlab.yml
#修改puma.rb文件
su git -c "cp config/puma.rb.example config/puma.rb"
sed -i "s/0.0.0.0:9292/127.0.0.1:3000/g" /home/git/gitlab/config/puma.rb
sed -i "s/# bind/bind/g" /home/git/gitlab/config/puma.rb
#为git用户授权
su git -c "chown -R git /home/git/gitlab/log/;chmod -R u+rwx /home/git/gitlab/log/;chown -R git /home/git/gitlab/tmp/;chmod -R u+rwx /home/git/gitlab/tmp/;mkdir /home/git/gitlab-satellites;mkdir /home/git/gitlab/tmp/pids/;chmod -R u+rwx /home/git/gitlab/tmp/pids/;mkdir /home/git/gitlab/tmp/sockets/;chmod -R u+rwx /home/git/gitlab/tmp/sockets/;mkdir /home/git/gitlab/public/uploads;chmod -R u+rwX /home/git/gitlab/public/uploads"
### 复制数据配置文件
su git -c "cp config/database.yml.mysql config/database.yml"
### 设置mysql用户和密码
sed -i "s/root/gitlab/g" config/database.yml
sed -i "s/secure password/123456/g" config/database.yml
### 配置git用户
su git -c 'git config --global user.name "GitLab"'
su git -c 'git config --global user.email "gitlab@$GL_HOSTNAME"'
七.安装 Gems
## 安装
gem install charlock_holmes --version '0.6.9'
#bundle使用淘宝源,并且安装(时间长.)
sed -i '1s/https/http/g' /home/git/gitlab/Gemfile
sed -i '1s/rubygems/ruby.taobao/g' /home/git/gitlab/Gemfile
#安装bundle
su git -c "bundle install –deployment –without development test postgres"
八.初始化数据库
#初始化数据库
export force=yes
su git -c "bundle exec rake gitlab:start RAILS_ENV=production"
su git -c "bundle exec rake gitlab:setup RAILS_ENV=production"
#初始化在数据库里添加数据,最后后会出现:
#用户名:admin@local.host
#密 码:5iveL!fe
#su git -c "bundle exec rake gitlab:env:info RAILS_ENV=production"
九.启动脚本
#curl –output /etc/init.d/gitlab
#chmod +x /etc/init.d/gitlab
curl –output /etc/init.d/gitlab
chmod +x /etc/init.d/gitlab
#在17行后添加2行内容
sed -i "17 a source /etc/profile.d/rvm.shnrvm use 1.9.3-p448" /etc/init.d/gitlab
#或者复制
##cp /home/git/gitlab/lib/support/init.d/gitlab /etc/init.d/
#添加到开机启动项
chkconfig gitlab on
#启动
/etc/init.d/gitlab start
十.配置web站点
#配置nginx
#安装nginx,(编译安装和rpm都能实现)
# yum -y install nginx
#下载nginx下的gitlab.conf文件
curl –output /etc/nginx/conf.d/gitlab.conf
#修改下server标签监听端口和域名
vim /etc/nginx/conf.d/gitlab.conf
server {
listen 80;
server_name gitlab.wine.cn;
#..略..
}
更改安装目录权限
# chown -R git:git /etc/nginx
#更改nginx所属用户
#注意:
#需要nginx用户改为git,否则会出现502访问错误.
vim /etc/nginx/nginx.conf
#user nginx;
user git;
/etc/init.d/gitlab start
/etc/init.d/nginx start
#然后访问
gitlab.wine.cn
#####以下是报错环节,没怎么整理很乱###################
[root@gitlab init.d]# sh gitlab start
Could not find mysql2-0.3.11 in any of the sources
Run `bundle install` to install missing gems.
#解决
如何在centos下安装ruby
yum list |grep ruby
yum install ruby ruby-devel ruby-rdoc ruby-irb rubygems
gem install rails
centos5.5怎么安装gitlab
#gitlab基于ruby开发模仿Github的版本控制软件,因为是开源的,,但是我们确实有这样的需求,相比Gtihub来说可以减少很多成本.
#从安装ruby、git、数据库、web、和gitlab到访问,一定要有耐心.
#安装环境
##[root@localhost config]# uname -r
##2.6.32-279.el6.x86_64
##[root@localhost config]# cat /etc/redhat-release
##CentOS release 6.3 (Final)
一.安装依赖
## 安装epel-release
yum -y install
#安装ruby依赖包
## packages (from rvm install message):
yum -y install libicu-devel patch gcc-c++ readline-devel zlib-devel libffi-devel openssl-devel make autoconf automake libtool bison libxml2-devel libxslt-devel libyaml-devel mysql-devel
#安装或者更新git
yum -y remove git
yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
wget
tar -zxf git-1.8.3.4.tar.gz
cd git-1.8.3.4
make prefix=/usr all
make prefix=/usr install
cd ..
#安装前版本
[root@gitlab ~]# git –version
git version 1.7.1
#安装后版本
[root@gitlab ~]# git –version
git version 1.8.3.4
二.安装RVM
#RVM工具
curl -L get.rvm.io | bash -s stable
#出现以下信息为安装成功
# Administrator,
#
# Thank you for using RVM!
# We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal team.
#加载RVM,改名(使用淘宝源)
source /etc/profile.d/rvm.sh
cp /usr/local/rvm/config/db /usr/local/rvm/config/db.bk
sed -i 's#' /usr/local/rvm/config/db
sed -i 's#cache.ruby-lang.org/pub/ruby#ruby.taobao.org/mirrors/ruby#' /usr/local/rvm/config/db
#安装libyaml(防止后期报错,可不装)
rvm pkg install libyaml
三.安装ruby
#安装ruby
#rvm install 2.0.0-p247 –with-libyaml-dir=/usr/local/rvm/usr
#rvm –default use 2.0.0-p247
rvm install 2.0.0-p353 –with-libyaml-dir=/usr/local/rvm/usr
rvm –default use 2.0.0-p353
#引用淘宝ruby源
gem sources –remove
gem sources -a
gem sources -l
#安装bundler
gem install bundler –no-ri –no-rdoc
四.安装gitlab-shell
#创建用户git
adduser –system –create-home –comment 'GitLab' git
#复制gitlab-shell到本地
su – git -c "git clone "
su – git -c "cd gitlab-shell;git checkout v1.7.0"
##修改配置文件
su – git -c "cp gitlab-shell/config.yml.example gitlab-shell/config.yml"
##安装
su – git -c "gitlab-shell/bin/install"
五.安装Redis和mysql
#安装Redis,据说高级特性需要
yum -y install redis ;service redis start ; chkconfig redis on
#安装mysql
#安装Mysql数据库.略过,以及数据库操作
##yum install -y mysql-server mysql-devel ; chkconfig mysqld on ; service mysqld start
#编译安装宣告下变量
##export PATH="/opt/mysql/bin:$PATH"
##echo "export PATH="/opt/mysql/bin:$PATH""/etc/profile
##修改root密码
#echo "UPDATE mysql.user SET Password=PASSWORD('$MYSQL_ROOT_PW') WHERE User='root'; FLUSH PRIVILEGES;" | mysql -u root
##创建gitlab数据库
#echo "CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';" | mysql -u root
CREATE DATABASE IF NOT EXISTS gitlabhq_production DEFAULT CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci';
##创建连接数据库用户
grant all on gitlabhq_production.* to gitlab@localhost identified by '123456';
六.安装gitlab
#复制GitLab到本地
su – git -c "git clone gitlab"
## 检查
su – git -c "cd gitlab;git checkout 5-4-stable"
#以下操作在/home/git/gitlab
cd /home/git/gitlab
### 复制配置文件
su git -c "cp config/gitlab.yml.example config/gitlab.yml"
### 修改配置文件主机名(可以不做)
sed -i "s/ host: localhost/ host: gitlab.test/g" config/gitlab.yml
### 修改邮件地址
sed -i "s/from: gitlab@localhost/from: gitlab@gitlab.test/g" config/gitlab.yml
#修改puma.rb文件
su git -c "cp config/puma.rb.example config/puma.rb"
sed -i "s/0.0.0.0:9292/127.0.0.1:3000/g" /home/git/gitlab/config/puma.rb
sed -i "s/# bind/bind/g" /home/git/gitlab/config/puma.rb
#为git用户授权
su git -c "chown -R git /home/git/gitlab/log/;chmod -R u+rwx /home/git/gitlab/log/;chown -R git /home/git/gitlab/tmp/;chmod -R u+rwx /home/git/gitlab/tmp/;mkdir /home/git/gitlab-satellites;mkdir /home/git/gitlab/tmp/pids/;chmod -R u+rwx /home/git/gitlab/tmp/pids/;mkdir /home/git/gitlab/tmp/sockets/;chmod -R u+rwx /home/git/gitlab/tmp/sockets/;mkdir /home/git/gitlab/public/uploads;chmod -R u+rwX /home/git/gitlab/public/uploads"
### 复制数据配置文件
su git -c "cp config/database.yml.mysql config/database.yml"
### 设置mysql用户和密码
sed -i "s/root/gitlab/g" config/database.yml
sed -i "s/secure password/123456/g" config/database.yml
### 配置git用户
su git -c 'git config --global user.name "GitLab"'
su git -c 'git config --global user.email "gitlab@$GL_HOSTNAME"'
七.安装 Gems
## 安装
gem install charlock_holmes --version '0.6.9'
#bundle使用淘宝源,并且安装(时间长.)
sed -i '1s/https/http/g' /home/git/gitlab/Gemfile
sed -i '1s/rubygems/ruby.taobao/g' /home/git/gitlab/Gemfile
#安装bundle
su git -c "bundle install –deployment –without development test postgres"
八.初始化数据库
#初始化数据库
export force=yes
su git -c "bundle exec rake gitlab:start RAILS_ENV=production"
su git -c "bundle exec rake gitlab:setup RAILS_ENV=production"
#初始化在数据库里添加数据,最后后会出现:
#用户名:admin@local.host
#密 码:5iveL!fe
#su git -c "bundle exec rake gitlab:env:info RAILS_ENV=production"
九.启动脚本
#curl –output /etc/init.d/gitlab
#chmod +x /etc/init.d/gitlab
curl –output /etc/init.d/gitlab
chmod +x /etc/init.d/gitlab
#在17行后添加2行内容
sed -i "17 a source /etc/profile.d/rvm.shnrvm use 1.9.3-p448" /etc/init.d/gitlab
#或者复制
##cp /home/git/gitlab/lib/support/init.d/gitlab /etc/init.d/
#添加到开机启动项
chkconfig gitlab on
#启动
/etc/init.d/gitlab start
十.配置web站点
#配置nginx
#安装nginx,(编译安装和rpm都能实现)
# yum -y install nginx
#下载nginx下的gitlab.conf文件
curl –output /etc/nginx/conf.d/gitlab.conf
#修改下server标签监听端口和域名
vim /etc/nginx/conf.d/gitlab.conf
server {
listen 80;
server_name gitlab.wine.cn;
#..略..
}
更改安装目录权限
# chown -R git:git /etc/nginx
#更改nginx所属用户
#注意:
#需要nginx用户改为git,否则会出现502访问错误.
vim /etc/nginx/nginx.conf
#user nginx;
user git;
/etc/init.d/gitlab start
/etc/init.d/nginx start
#然后访问
gitlab.wine.cn
#####以下是报错环节,没怎么整理很乱###################
[root@gitlab init.d]# sh gitlab start
Could not find mysql2-0.3.11 in any of the sources
Run `bundle install` to install missing gems.
#解决
centos 怎么查找ruby安装路径
现在流行的做法是用RVM来管理Ruby的安装,搜一下ruby rvm就能找到。管理多个Ruby版本和项目时尤其好用,发行版的ruby大多都为了符合自己的策略修改了默认设置,用起来不习惯。
如何在Mac OS X上安装 Ruby运行环境
对于新入门的开发者,如何安装 Ruby和Ruby Gems 的运行环境可能会是个问题,主要介绍如何用一条靠谱的路子快速安装 Ruby 开发环境。此安装方法同样适用于产品环境!
系统需求
首先确定操作系统环境,Mac OS X
任意 Linux 发行版本(Ubuntu,CentOS, Redhat, ArchLinux ...)
建议使用 Ubuntu 省掉不必要的麻烦!
以下代码区域,带有 $ 打头的表示需要在控制台(终端)下面执行(不包括 $ 符号)
步骤0 - 安装系统需要的包
# For Mac # 先安装 [Xcode]开发工具,它将帮你安装好 Unix 环境需要的开发包
步骤1 - 安装 RVM
RVM 是干什么的这里就不解释了,后面你将会慢慢搞明白。
$ curl -L
期间可能会问你sudo管理员密码,以及自动通过homebrew安装依赖包,等待一段时间后就可以成功安装好 RVM。
然后,载入 RVM 环境(新开 Termal 就不用这么做了,会自动重新载入的)
$ source ~/.rvm/scripts/rvm
检查一下是否安装正
【centos安装ruby】的内容来源于互联网,如引用不当,请联系我们修改。
网友留言: