rubymysql安装(ruby mysql)

本文目录一览:

ruby自带的webrick服务器怎么启动不了?

首先 rails学习建议使用 1.8.7+rails2 ,rails3目前资料过少 ,aglie webdevelopment with rails 第四版还在英文beta中

其次 , 除了1.8.6 one-click安装包外 ,其他的ruby发行版都不包含 mysql链接库和sqlite3链接库 ,需要手动下载安装

其他的1楼描述的很明确了 , rails3 很多东西都做了修改 ,比如新建项目变为 rails new projectname, webrick的启动变为 rails s 等

我个人还是认为rails最好的开发学习平台是MacosX ,其次是Linux ,windows下面先天不足

如何从本机连接vagrant里的mysql 03 社区 03 Ruby China

先确认自己的mysql服务进程mysqld在运行着,可以使用ps aux | grep mysql看看

Gemfile中加入gem ‘mysql2’

确认mysql帐号密码正确,一般安装好的都是mysql默认都是用户名root,无密码,这样是可以直接登录的

你需要先使用mysql链接mysqld(第一步开启的服务端),之后手动创建blog_db数据库,rails是不会自动创建mysql的数据库的(里面的各个表你不需要创建,这是active_record的工作)。

看你error log应该是mysqld没运行!

安装ruby环境,用mysql数据库,总是报错,调了一下午,网上方法都用了也不管事

make的时候需要调用ruby很多编译前的参数.一些信息make不知道的话会不知道如何建库.

我个人的建议是根据你安装的ruby路径和版本信息把配置选项补充全.下面是我电脑上面的配置,你可以借鉴一下.据我分析应该能解决你的问题.

Provided configuration options:

–with-opt-dir

–with-opt-include

–without-opt-include=${opt-dir}/include

–with-opt-lib

–without-opt-lib=${opt-dir}/usr/lib

–with-make-prog

–without-make-prog

–srcdir=.

–curdir

–ruby=/usr/local/ruby-2.1.2/rubies/ruby-2.1.2/bin/ruby

如何在ubuntu server 14.04下安装gitlab中文版

gitlab是基于Ruby on Rails的,安装和配置非常麻烦,不过有傻瓜安装包,,或者,。但是这两个包都是英文界面的,gitlab把界面提示写在每一个rb文件里了,所以,要用中文版的不能像redmine那样设定一下就行了。

幸好,还是有无私的大侠把gitlab给汉化了:,代码地址:。

所以本文要做的事情是,不安装傻瓜包,从源码安装gitlab。

gitlab官方有一个说明文档:,本文基本按照这个文档来的。所不同的是,本文用的是apache,不是nginx。

安装步骤有:

1. 依赖包

2. ruby

3. 用户创建

4. 数据库初始化

5. redis

6. gitlab源码

7. apache

本文可能会用到VPN连接,在命令行下创建VPN连接的方法如下:

sudo apt-get install pptp-linux

sudo pptpsetup –create VPN名称 –server 服务器地址 –username 用户名 –password 密码 [–encrypt] –start

以上命令会创建一个设备,如果没有其他的拨号设备,这个设备会是ppp0,用ifconfig可以看到,“–encrypt”选项可选,因为有的服务器不支持,会提示MPPE required but peer negotiation failed,创建时带上“–start”选项可以看到连接的情况。

pptpsetup创建的VPN连接重启后会失效,如果想在不重启的情况下删除VPN连接:

sudo pptpsetup –delete VPN名称

创建VPN连接后还需要使能,并且添加到路由列表:

sudo pon VPN名称

sudo route add default dev ppp0

禁用VPN连接的方法是:

sudo poff VPN名称

下面开始正文:

1. 依赖包

我装的是ubuntu server 14.04,安装的时候可以选是否安装LAMP(Linux+Apache+MySQL+PHP),如果没装,可以用下面的命令装:

sudo tasksel install lamp-server

安装的时候会提示输入MySQL的root密码,下面要用。

接下来是依赖关系:

sudo apt-get install flex bison ruby build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev curl openssh-server redis-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev logrotate python-docutils pkg-config cmake libkrb5-dev nodejs git-core

注意:这里面装了ruby,应该是1.9.1版本的,gitlab需要2.0以上的ruby,但是安装2.0以上的ruby需要低版本的ruby,所以我们先装上,一会儿卸掉。另外,ubuntu 14.04的软件库里有ruby 2.0,但是实测不能用,所以还是从源码装ruby吧。

2. ruby

下载,编译,安装(安装前删掉ruby 1.9.1):

curl -L –progress  | tar xz

cd ruby-2.1.5

./configure –prefix=/usr –disable-install-rdoc

make

sudo apt-get autoremove ruby

sudo make install

然后安装bundler:

sudo gem install bundler –no-ri –no-rdoc

3. 用户创建

为gitlab创建一个git用户:

sudo adduser –disabled-login –gecos ‘GitLab’ git

4. 数据库初始化

官方指南用的是PostgreSQL,不过官方也有MySQL的说明:

sudo apt-get install -y mysql-server mysql-client libmysqlclient-dev

mysql -u root -p

输入MySQL的root密码登陆,然后:

mysql CREATE USER ‘git’@’localhost’ IDENTIFIED BY ‘$password’;

记得把上面这句的”$password”换成实际的密码,然后:

mysql SET storage_engine=INNODB;

mysql CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;

mysql GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, LOCK TABLES ON `gitlabhq_production`.* TO ‘git’@’localhost’;

mysql \q

5. Redis

Redis貌似是用来存key的数据库吧,不知道,反正按步骤安装:

sudo apt-get install redis-server

sudo cp /etc/redis/redis.conf /etc/redis/redis.conf.orig

sed ‘s/^port .*/port 0/’ /etc/redis/redis.conf.orig | sudo tee /etc/redis/redis.conf

echo ‘unixsocket /var/run/redis/redis.sock’ | sudo tee -a /etc/redis/redis.conf

echo ‘unixsocketperm 770’ | sudo tee -a /etc/redis/redis.conf

sudo service redis-server restart

sudo usermod -aG redis git

6. gitlab源码

gitlab源码默认是安装在/home/git/gitlab,如果要更改,请参照官方手册。获取中文版源码的过程如下:

cd /home/git

sudo -u git -H git clone 

不知道是因为GFW还是什么,git clone这个版本库可慢可慢了,我用了VPN,速度会快点。

git clone完以后可以checkout你想要的版本,在本文编写的时间(2015年4月22日),可以:

sudo -u git -H git checkout 7-7-zh

然后配置源码

cd /home/git/gitlab

sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml

sudo chown -R git log/

sudo chown -R git tmp/

sudo chmod -R u+rwX,go-w log/

sudo chmod -R u+rwX tmp/

sudo -u git -H mkdir /home/git/gitlab-satellites

sudo chmod u+rwx,g=rx,o-rwx /home/git/gitlab-satellites

sudo chmod -R u+rwX tmp/pids/

sudo chmod -R u+rwX tmp/sockets/

sudo chmod -R u+rwX  public/uploads

sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb

sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb

sudo -u git -H git config –global user.name “GitLab”

sudo -u git -H git config –global user.email “example@example.com”

sudo -u git -H git config –global core.autocrlf input

sudo -u git -H cp config/resque.yml.example config/resque.yml

当然,你可以把example@example.com改成你的email;上面的那些yml文件里面的配置基本都不用更改;然后,配置数据库用户名和密码:

sudo -u git cp config/database.yml.mysql config/database.yml

sudo -u git -H editor config/database.yml

sudo -u git -H chmod o-rwx config/database.yml

然后,安装gems:

sudo -u git -H bundle install –deployment –without development test postgres aws

这一步必须使用VPN,因为万恶的GFW屏蔽了rubygems.org,所以会提示connection reset by peer之类的,这部时间也会比较久,如果你的机器是多核的,也可以加上和make相同-jN参数,N等于核数。

(2015年5月2日追加)

发现淘宝做了个rubygrems.org的国内镜像,,可以参照上面的内容设置,加快gems安装速度。

再接下来安装gitlab shell:

sudo -u git -H bundle exec rake gitlab:shell:install[v2.6.0] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production

sudo -u git -H editor /home/git/gitlab-shell/config.yml

把gitlab的url改成或者你的域名。

在接下来初始化数据库:

sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production

加入启动项:

sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab

sudo update-rc.d gitlab defaults 21

初始化日志:

sudo cp lib/support/logrotate/gitlab /etc/logrotate.d/gitlab

检查应用状态:

sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production

编译附件:

sudo -u git -H bundle exec rake assets:precompile RAILS_ENV=production

启动gitlab服务:

sudo service gitlab start

7. apache

下载apache的配置文件:

将其中的“ProxyPassReverse

”改成“ProxyPassReverse

”或者你的域名,将其中的“/var/log/httpd/logs/”改为“/var/log/apache2/”。

用命令来说:

wget 

mv gitlab-apache2.4.conf 001-gitlab.conf

editor 001-gitlab.conf (进行上述修改)

sudo cp 001-gitlab.conf /etc/apache2/sites-available

cd /etc/apache2/sites-enabled

sudo rm 000-default.conf

sudo ln -s ../sites-available/001-gitlab.conf 001-gitlab.conf

另外,还需要使能代理模块以实现反向代理功能,不然会提示“ProxyPassReverse”无效之类的。

cd /etc/apache2/mods-enabled

sudo ln -s ../mods-available/proxy.conf proxy.conf

sudo ln -s ../mods-available/proxy.load proxy.load

sudo ln -s ../mods-available/proxy_connect.load proxy_connect.load

sudo ln -s ../mods-available/proxy_http.load proxy_http.load

sudo ln -s ../mods-available/rewrite.load rewrite.load

重启apache:

sudo service apache2 restart

然后,检查下配置是否正确:

sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production

如果都是绿色的结果,那就可以访问了。登陆用户名:root,初始密码:5iveL!fe

最后配置一下邮件,修改/home/git/gitlab/config/gitlab.yml,里面的“email_from:”为一个有效的email地址;修改/home/git/gitlab/config/environments/production.rb,里面的 “config.action_mailer.delivery_method=”为“:smtp”;最后:

cd /home/git/gitlab/config/initializers

sudo -u git -H cp smtp_settings.rb.sample smtp_settings.rb

然后把文件的里的内容修改正确了,再重启一下gitlab服务就行了:

sudo service gitlab restart

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 上安装 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.

#解决

原创文章,作者:M3HEA,如若转载,请注明出处:https://www.506064.com/n/128524.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
M3HEAM3HEA
上一篇 2024-10-03 23:25
下一篇 2024-10-03 23:25

相关推荐

  • 如何修改mysql的端口号

    本文将介绍如何修改mysql的端口号,方便开发者根据实际需求配置对应端口号。 一、为什么需要修改mysql端口号 默认情况下,mysql使用的端口号是3306。在某些情况下,我们需…

    编程 2025-04-29
  • Python操作MySQL

    本文将从以下几个方面对Python操作MySQL进行详细阐述: 一、连接MySQL数据库 在使用Python操作MySQL之前,我们需要先连接MySQL数据库。在Python中,我…

    编程 2025-04-29
  • MySQL递归函数的用法

    本文将从多个方面对MySQL递归函数的用法做详细的阐述,包括函数的定义、使用方法、示例及注意事项。 一、递归函数的定义 递归函数是指在函数内部调用自身的函数。MySQL提供了CRE…

    编程 2025-04-29
  • MySQL bigint与long的区别

    本文将从数据类型定义、存储空间、数据范围、计算效率、应用场景五个方面详细阐述MySQL bigint与long的区别。 一、数据类型定义 bigint在MySQL中是一种有符号的整…

    编程 2025-04-28
  • MySQL左连接索引不生效问题解决

    在MySQL数据库中,经常会使用左连接查询操作,但是左连接查询中索引不生效的情况也比较常见。本文将从多个方面探讨MySQL左连接索引不生效问题,并给出相应的解决方法。 一、索引的作…

    编程 2025-04-28
  • CentOS 7在线安装MySQL 8

    在本文中,我们将介绍如何在CentOS 7操作系统中在线安装MySQL 8。我们会从安装环境的准备开始,到安装MySQL 8的过程进行详细的阐述。 一、环境准备 在进行MySQL …

    编程 2025-04-27
  • 如何使用MySQL字段去重

    本文将从多个方面为您详细介绍如何使用MySQL字段去重并给出相应的代码示例。 一、SELECT DISTINCT语句去重 MySQL提供了SELECT DISTINCT语句,通过在…

    编程 2025-04-27
  • MySQL正则表达式替换

    MySQL正则表达式替换是指通过正则表达式对MySQL中的字符串进行替换。在文本处理方面,正则表达式是一种强大的工具,可以方便快捷地进行字符串处理和匹配。在MySQL中,可以使用正…

    编程 2025-04-27
  • Apache2.4和MySQL的全能编程开发工程师指南

    本文将从多个方面对Apache2.4和MySQL进行详细的阐述,为全能编程开发工程师提供有用的参考和指导。首先,我们来解答这个标题所涵盖的主题: 本文将提供Apache2.4和My…

    编程 2025-04-27
  • 如何在Mac上安装Ruby

    一、Mac安装更新 在安装过程之前,确保你的Mac系统已更新到最新版本。这可以通过在菜单栏中选择“” → “关于本机” → “软件更新”来完成。 一旦软件更新完毕,你就可以开始安…

    编程 2025-04-25

发表回复

登录后才能评论