walle & gitlab 部署小记

walle & gitlab 部署小记
总结:遇到很多坑。分析日志查错,配置要根据实际路径修改,多看官方手册(如git/python版本要求) 安装lnmp或者lamp,创建walle的数据库及帐号 # mysql > create database walle; # mysql > grant all privileges onwalle.* to walle@”127.0.0.1″ identified by “passwd”; #mysql > flush privileges;   安装walle # cd /usr/local/src # git clonegit@github.com:meolu/walle-web.git 报错,用下面方法下载 # git clonehttps://github.com/meolu/walle-web.git   下载composer.phar并重命名: # curl -sShttps://getcomposer.org/installer | php # mv composer.phar /usr/sbin/composer   # cd walle-web # composer install –prefer-dist –no-dev–optimize-autoloader -vvvv 会下载很多模块,比较慢 初始化数据: # ./yii run/setup   报错,需要修改以下文件: 编辑config/local.php 以及config/web.php ‘db’ => [ ‘class’     =>’yii\db\Connection’, ‘dsn’       =>’mysql:host=127.0.0.1;dbname=walle’,   # 新建数据库walle //与上面授权一致,用127.0.0.1(如果上面授权是localhost,这里就写localhost) ‘username’  => ‘walle’,                             # 连接的用户名 ‘password’  => ‘passwd’,                            # 连接的密码 ‘charset’   => ‘utf8’, ],     # mkdir -p /data/www/walle-web &&cd /data/www/walle-web # cp -rf walle-web/* /data/www/walle-web 创建dist目录,否则登录walle时提示没这个目录: # mkdir -p/data/www/walle-web/vendor/bower/jquery/dist # chown -R www.www /data/www/walle-web/ // 注意这里的www用户是nginx和php-fpm使用的用户   编译nginx或者apache配置文件 # cat /usr/local/nginx/conf/conf.d/walle.conf server { listen 80; server_name walle.xxx.com; root /data/www/walle-web/web; index index.php; #       allow 192.168.184.123/32; #       deny all;   location / { try_files $uri $uri/ /index.php$is_args$args; }   location ~ \.php$ { try_files $uri = 404; fastcgi_pass   127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name; include        fastcgi_params; }   }   重启服务: # service nginx restart 登录:( 默认用户名密码为admin ) http://walle.xxx.com/   ——————————– Girtab安装: python原有yum安装的2.6即可,无需升级到2.7 创建git用户: # adduser –system –shell /bin/bash–comment ‘GitLab’ –create-home –home-dir /home/git/ git 安装依赖包: # yum install vim-enhanced readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-develcurl-devel expat-devel db4-devel byacc sqlite-devel gcc-c++ libyamllibyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devellibicu libicu-devel system-config-firewall-tui python-devel  sudo wget crontabs logwatch logrotateperl-Time-HiRes     如果yum安装的git,git版本低了(1.7.1) https://www.kernel.org/pub/software/scm/git/ 先卸载yum remove git 安装1.8以上版本的 # wget https://www.kernel.org/pub/software/scm/git/git-1.8.4.1.tar.gz # make prefix=/usr/local all # make prefix=/usr/local install # ln -fs /usr/local/bin/git* /usr/bin/   或者不创建软链接,visudo 把/usr/local/bin 加入进去 Defaults   secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin     如果编译安装报错: make[1]: *** [perl.mak] Error 2 make: *** [perl/perl.mak] Error 2   # yum install perl-ExtUtils-MakeMaker package # yum install gettext   安装redis(略)   安装ruby # wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p353.tar.gz | tar zxvf # cd ruby-2.0.0-p353/ # ./configure –prefix=/usr/local/ # make && make install # ln -sf /usr/local/bin/ruby /usr/bin # ln -sf /usr/local/bin/gem /usr/bin   # gem source -l # gem source -r https://rubygems.org/ # gem source -a https://ruby.taobao.org/   建议安装指定版本的: # gem install bundler -v ‘1.10.6’  –no-ri –no-rdoc // gem install bundler –no-ri –no-rdoc不指定版本安装的版本会高一些,可能有问题 # gem install charlock_holmes -v ‘0.6.9.4’ # gem list –local # ln -sf /usr/local/bin/bundle /usr/bin/   添加gitlab数据库帐号等:   mysql> CREATE USER ‘gitlab’@’localhost’IDENTIFIED BY ‘passwd’; mysql> CREATE DATABASE IF NOT EXISTS`gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; mysql> GRANT SELECT, LOCK TABLES,INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.*TO ‘gitlab’@’localhost’;   安装gitlab-shell: # su – git git@localhost gitlab]$ git clonehttps://github.com/gitlabhq/gitlab-shell.git   ############## 报错: Cloning into ‘gitlab-shell’… fatal: Unable to find remote helper for’https’ 如果我们编译安装git时指定了安装目录为/usr/local/git/ http://my.oschina.net/hevakelcj/blog/409155 解决办法:   git@localhost gitlab]$ PATH=$PATH:/usr/libexec/git-core ##############   git@localhost gitlab]$ git clonehttps://github.com/gitlabhq/gitlab-shell.git git@localhost gitlab]$ cd gitlab-shell git@localhost gitlab]$ git checkout v1.8.0 git@localhost gitlab]$ cp config.yml.example config.yml git@localhost gitlab]$ vim config.yml   #修改gitlab_url为http://gitlab.xxxx.com,该值将与gitlab配置中的对应 //根据实际路径修改redis-cli位置   git@localhost gitlab]$ ./bin/install   安装gitlab: git@localhost gitlab]$ git clonehttps://github.com/gitlabhq/gitlabhq.git gitlab git@localhost gitlab]$ cd gitlab git@localhost gitlab]$ git checkout6-4-stable git@localhost gitlab]$ cp config/gitlab.yml.example config/gitlab.yml git@localhost gitlab]$ vim config/gitlab.yml host: gitlab.xxx.com port: 80 https: false   git: bin_path: /usr/local/bin/git //与上面的config.yml一致,git路径根据实际情况配置   git@localhost gitlab]$ mkdir /home/git/gitlab-satellites git@localhost gitlab]$ mkdir tmp/pids/ git@localhost gitlab]$ mkdir tmp/sockets/ git@localhost gitlab]$ mkdir public/uploads git@localhost gitlab]$ chown -R git log/ git@localhost gitlab]$ chown -R git tmp/ git@localhost gitlab]$ chmod -R u+rwX  log/ git@localhost gitlab]$ chmod -R u+rwX  tmp/ git@localhost gitlab]$ chmod -R u+rwX  tmp/pids/ git@localhost gitlab]$ chmod -R u+rwX  tmp/sockets/ git@localhost gitlab]$ chmod -R u+rwX  public/uploads git@localhost gitlab]$ cp config/unicorn.rb.example config/unicorn.rb 注意这里的unicorn.rb 里面的配置文件可以不做修改(如果8080端口没被占用的话) // nginx的配置是做unicorn的代理转发,实际上gitlab是由unicorn容器驱动,而在配置里默认绑定的是8080端口   git@localhost gitlab]$ git config –globaluser.name “GitLab” git@localhost gitlab]$ git config –globaluser.email “gitlab@localhost” git@localhost gitlab]$ git config –globalcore.autocrlf input git@localhost gitlab]$ git config –list   git@localhost gitlab]$ cp config/database.yml.mysqlconfig/database.yml git@localhost gitlab]$ vim config/database.yml username: gitlab password: “passwd” host: localhost # chmod o-rwx config/database.yml # cp config/resque.yml.exampleconfig/resque.yml # vi config/resque.yml production: redis://127.0.0.1:6379 //这里根据自己配置redis的来修改   安装GEMS git@localhost gitlab]$ cd /home/git/gitlab/ #更换Gemfile中的ruby源,加快包的安装速度 git@localhost gitlab]$ vim Gemfile source “http://ruby.taobao.org”     git@localhost gitlab]$ bundle install–deployment –without development test postgres puma aws   报错可参考: https://github.com/gitlabhq/gitlabhq/blob/5-0-stable/doc/install/installation.md https://ruby.taobao.org/   Could not find modernizr-2.6.2 in any ofthe sources 解决办法: git@localhost gitlab]$ sed -i -e’s/modernizr/modernizr-rails/g’ /home/git/gitlab/Gemfile git@localhost gitlab]$ sed -i -e’s/2.6.2/2.7.1/g’ /home/git/gitlab/Gemfile   git@localhost gitlab]$ sed -i -e’s/modernizr/modernizr-rails/g’ /home/git/gitlab/Gemfile.lock git@localhost gitlab]$ sed -i -e’s/2.6.2/2.7.1/g’ /home/git/gitlab/Gemfile.lock   # gem install rugged -v ‘0.23.3’   ##### 如果仍然报错: An error occurred while installing mysql2(0.3.11), and Bundler cannot continue. Make sure that `gem install mysql2 -v’0.3.11’` succeeds before bundling. 解决办法: # yum install ruby-mysql # yum install mysql++-devel   git@localhost gitlab]$ bundle exec rake gitlab:check RAILS_ENV=production   Git version >= 1.7.10 ? … no Tryfixing it: Update your git to a version >= 1.7.10 from 1.7.1 Please fix the error above and rerun the checks.   Checking GitLab … Finished 说明git版本低了 ###########   git@localhost gitlab]$ bundle exec rake gitlab:check RAILS_ENV=production没有问题后执行初始化: git@localhost gitlab]$ bundle exec rake gitlab:setup RAILS_ENV=production   ############ 如果报错: 以下是解决办法: /home/git/gitlab/lib/tasks/gitlab/setup.rake:18:in`setup_db’ /home/git/gitlab/lib/tasks/gitlab/setup.rake:4:in`block (2 levels) in <top (required)>’ Tasks: TOP => db:seed_fu (See full trace by running task with–trace)   redis.conf 改为bind localhost   config/resque.yml 改为production: redis://localhost:6379 ###########   初始化成功后会产出用户名/密码,类似如: == Seed from/home/git/gitlab/db/fixtures/production/001_admin.rb 2015-12-14T07:39:30Z 31086 TID-ovu4rhuawINFO: Sidekiq client with redis options{:url=>”redis://localhost:6379″,:namespace=>”resque:gitlab”}   Administrator account created:   login………admin@local.host password……5iveL!fe   # cp /home/git/gitlab/lib/support/init.d/gitlab/etc/init.d/gitlab # chmod +x /etc/init.d/gitlab # chkconfig –add gitlab # chkconfig gitlab –level 235 on 启动gitlab服务 # /etc/init.d/gitlab start   ########## 如果报错: sudo: ldap_sasl_bind_s(): Can’t contactLDAP server Starting both the GitLab Unicorn andSidekiq/usr/bin/env: ruby: No such file or directory …………………………Waited 30sfor the processes to write their pids, something probably went wrong. 解决办法: # ln -s /usr/local/bin/bundle /usr/bin/ # ln -s /usr/local/bin/ruby /usr/bin/ ##########   # /etc/init.d/gitlab start sudo: ldap_sasl_bind_s(): Can’t contactLDAP server Starting both the GitLab Unicorn andSidekiq.. The GitLab Unicorn web server with pid 1281is running. The GitLab Sidekiq job dispatcher with pid1291 is running. GitLab and all its components are up andrunning.   正常启动后再次检查 git@localhost gitlab]$ # bundle exec rakegitlab:check RAILS_ENV=production ########## 如果报错如下: gitlab-shell self-check failed Tryfixing it: Make sure GitLab is running; Check the gitlab-shell configuration file: sudo -u git -H editor /home/git/gitlab-shell/config.yml Please fix the error above and rerun the checks.     redis: 改为  bin:/usr/local/bin/redis-cli     /home/git/gitlab/vendor/bundle/ruby/2.0.0/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in`connect’: Can’t connect to local MySQL server through socket’/var/lib/mysql/mysql.sock’ (2) (Mysql2::Error) mysql没启动 ##########     ******** 登录报错502: usermod -a -G git www chmod g+rx /home/git/   git@localhost gitlab]$ bundle exec rakeassets:precompile RAILS_ENV=production 会加载很多内容,如图片 **********   出现问题要分析日志: tail /home/git/gitlab/log/unicorn.stderr.log

tail /use/local/nginx/log/xxx.error.log
Print Friendly

发表评论

电子邮件地址不会被公开。 必填项已用*标注