一、环境
系统:CentOS6.4最小化安装
IP:192.168.3.44
二、增加yum源
增加epel源
[[email protected] ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm Retrieving http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm warning: /var/tmp/rpm-tmp.YSifux: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Preparing... ########################################### [100%] 1:epel-release ########################################### [100%] [[email protected] ~]# sed -i ‘[email protected]#[email protected]@g‘ /etc/yum.repos.d/epel.repo [[email protected] ~]# sed -i ‘[email protected]@#[email protected]‘ /etc/yum.repos.d/epel.repo
安装淘宝源
[[email protected] ~]# wget -O CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
三、安装更新包
[[email protected] ~]# yum -y update [[email protected] ~]# yum -y groupinstall ‘Development Tools‘ [[email protected] ~]# yum -y install readline readline-devel ncurses-devel gdbm-devel glibc-devel tcl-devel openssl-devel curl-devel expat-devel db4-devel byacc sqlite-devel libyaml libyaml-devel libffi libffi-devel libxml2 libxml2-devel libxslt libxslt-devel libicu libicu-devel system-config-firewall-tui redis sudo wget crontabs logwatch logrotate perl-Time-HiRes cmake libcom_err-devel.i686 libcom_err-devel.x86_64 perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
四、安装git
删除系统默认的git,使用源码安装git
[[email protected] ~]# git --version git version 1.7.1 [[email protected] ~]# yum remove git -y #下载源码安装包 [[email protected] ~]# wget [[email protected] ~]# tar xf git-2.1.3.tar.gz [[email protected] ~]# cd git-2.1.3 [[email protected] git-2.1.3]# ./configure [[email protected] git-2.1.3]# make && make prefix=/usr/local install [[email protected] git-2.1.3]# ln -s /usr/local/bin/git /usr/bin/ [[email protected] git-2.1.3]# git --version git version 2.1.3
五、安装ruby环境
删除系统自带的ruby环境
[[email protected] ~]# yum remove ruby -y #下载ruby安装包,最少2.0以上 [[email protected] ~]# wget [[email protected] ~]# tar xf ruby-2.1.2.tar.gz [[email protected] ~]# cd ruby-2.1.2 [[email protected] ruby-2.1.2]# ./configure --disable-install-rdoc [[email protected] ruby-2.1.2]# make && make prefix=/usr/local install
安装bundler
[[email protected] ruby-2.1.2]# gem install bundler --no-doc #查看安装后的结果 [[email protected] ruby-2.1.2]# which ruby /usr/local/bin/ruby [[email protected] ruby-2.1.2]# ruby -v ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
六、创建git用户
[[email protected] ~]# useradd git
添加sudo权限
[[email protected] ~]# vim /etc/sudoers git ALL=(ALL) NOPASSWD: ALL
七、安装mysql,这里选择源码安装mysql-5.5-37,使用安装脚本进行安装
脚本内容如下
#!/bin/bash DATADIR=‘/data/mysql/data‘ VERSION=‘mysql-5.5.37‘ export LANG=zh_CN.UTF-8 #Source function library. . /etc/init.d/functions #camke install mysql5.5.X install_mysql(){ read -p "please input a password for root: " PASSWD if [ ! -d $DATADIR ];then mkdir -p $DATADIR fi yum install cmake make gcc-c++ bison-devel ncurses-devel -y id mysql &>/dev/null if [ $? -ne 0 ];then useradd mysql -s /sbin/nologin -M fi #useradd mysql -s /sbin/nologin -M #change datadir owner to mysql chown -R mysql.mysql $DATADIR cd #wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.38.tar.gz tar xf $VERSION.tar.gz cd $VERSION cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/$VERSION -DMYSQL_DATADIR=$DATADIR -DMYSQL_UNIX_ADDR=$DATADIR/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=ON -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 -DWITHOUT_PARTITION_STORAGE_ENGINE=1 make && make install if [ $? -ne 0 ];then action "install mysql is failed!" /bin/false exit $? fi sleep 2 #link ln -s /usr/local/$VERSION/ /usr/local/mysql ln -s /usr/local/mysql/bin/* /usr/bin/ #copy config and start file /bin/cp /usr/local/mysql/support-files/my-small.cnf /etc/my.cnf cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld chmod 700 /etc/init.d/mysqld #init mysql /usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=$DATADIR --user=mysql if [ $? -ne 0 ];then action "install mysql is failed!" /bin/false exit $? fi #check mysql /etc/init.d/mysqld start if [ $? -ne 0 ];then action "mysql start is failed!" /bin/false exit $? fi chkconfig --add mysqld chkconfig mysqld on /usr/local/mysql/bin/mysql -e "update mysql.user set password=password(‘$PASSWD‘) where host=‘localhost‘ and user=‘root‘;" /usr/local/mysql/bin/mysql -e "update mysql.user set password=password(‘$PASSWD‘) where host=‘127.0.0.1‘ and user=‘root‘;" /usr/local/mysql/bin/mysql -e "delete from mysql.user where password=‘‘;" /usr/local/mysql/bin/mysql -e "flush privileges;" #/usr/local/mysql/bin/mysql -e "select version();" >/dev/null 2>&1 if [ $? -eq 0 ];then echo "+---------------------------+" echo "+------mysql安装完成--------+" echo "+---------------------------+" fi #/etc/init.d/mysqld stop } install_mysql
查看mysql安装结果
[[email protected] ~]# mysql --version mysql Ver 14.14 Distrib 5.5.37, for Linux (x86_64) using EditLine wrapper
创建数据库并授权
[[email protected] ~]# mysql -u root -p -h 127.0.0.1 Enter password: #这里的密码是我的安装脚本中提供的密码 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.5.37 Source distribution Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`; Query OK, 1 row affected (0.00 sec) mysql> GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO ‘git‘@‘localhost‘ IDENTIFIED BY ‘gitpwd‘; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) mysql> select user,host,password from mysql.user; +------+-----------+-------------------------------------------+ | user | host | password | +------+-----------+-------------------------------------------+ | root | localhost | *B181A5BCA7C882221F5B8F6F9657AE71FF67EDDB | | root | 127.0.0.1 | *B181A5BCA7C882221F5B8F6F9657AE71FF67EDDB | | git | localhost | *6EA0EDE421A05E610ADBFC5D47B93B6E06C6216F | +------+-----------+-------------------------------------------+ 3 rows in set (0.00 sec)
测试新建的用户能否登陆mysql
[[email protected] ~]# mysql -u git -p -h localhost Enter password: #这里的密码是上文中给定的gitpwd Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 5.5.37 Source distribution Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show databases; +---------------------+ | Database | +---------------------+ | information_schema | | gitlabhq_production | | test | +---------------------+ 3 rows in set (0.00 sec)
八、配置redis
[[email protected] ~]# chkconfig redis on [[email protected] ~]# /etc/init.d/redis start Starting redis-server: [ OK ] [[email protected] ~]# netstat -anpt |grep redis tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 8755/redis-server
九、安装gitlab
[[email protected] ~]# cd /home/git/ [[email protected] git]# sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-4-stable gitlab
时间: 2024-11-10 11:59:52