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/zh-tw/n/128524.html

(0)
打賞 微信掃一掃 微信掃一掃 支付寶掃一掃 支付寶掃一掃
M3HEA的頭像M3HEA
上一篇 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

發表回復

登錄後才能評論