Preface: Install your own git server in Ali [cloud server] (https://cloud.tencent.com/product/cvm?from=10680), and those with money can use coding.net.
yum -y update
yum -y groupinstall 'Development Tools'
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 git redis ruby sudo wget crontabs logwatch logrotate perl-Time-HiRes
Visit http://www.redis.io/download to download Redis source code.
wget http://download.redis.io/releases/redis-3.0.0.tar.gz
tar zxvf redis-3.0.0.tar.gz
cd redis-3.0.0
make
If an error occurs during the compilation process, you can execute the following command:
sudo make test
sudo make install
sudo ./utils/install_server.sh
Create /etc/init.d/redis
and use the following code as the startup script.
Add the following content:
###########################
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
REDIS_CLI=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/etc/redis/6379.conf"case"$1"in
start)if[-f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"else
echo "Starting Redis server..."
$EXEC $CONF
fi
if["$?"="0"]
then
echo "Redis is running..."
fi
;;
stop)if[!-f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
while[-x ${PIDFILE}]do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${0} stop
${0} start
;;*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}">&2
exit 1
esac
##############################
After saving, add executable permissions:
sudo chmod +x /etc/init.d/redis
Make sure that redis
can start with the system:
vi /etc/rc.d/rc.local
Add the following line at the end of the file:
service redis start
Then start the redis
service using the same command as above:
service redis start
yum -y install postfix
First delete the old version of git
in the system:
yum -y remove git
yum install zlib-devel perl-CPAN gettext curl-devel expat-devel gettext-devel openssl-devel
Download the source code from the official website:
curl --progress https://www.kernel.org/pub/software/scm/git/git-2.4.0.tar.gz | tar xz
cd git-2.4.0/./configure
make
make prefix=/usr/local install
Then use the following command to check whether the installation is valid:
which git
If the ruby version is lower than 2.0
, you need to reinstall ruby
.
cd ~
curl --progress ftp://ftp.ruby-lang.org/pub/ruby/2.2/ruby-2.2.2.tar.gz | tar xz
cd ruby-2.2.2./configure --disable-install-rdoc
make
make prefix=/usr/local install
adduser --system --shell /bin/bash --comment 'GitLab'--create-home --home-dir /home/git/ git
In order to include /usr/local/bin to the $PATH of the git user, one way is to edit the superuser file. Run as administrator:
visudo
Then search:
Defaults secure_path =/sbin:/bin:/usr/sbin:/usr/bin
Change it to:
Defaults secure_path =/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
MySQL is no longer included in the CentOS 7 source, and instead uses MariaDB. First search for the existing packages of MariaDB
:
rpm -qa | grep mariadb
Then delete all:
rpm -e --nodeps mariadb-*
Then create /etc/yum.repos.d/MariaDB.repo
:
vi /etc/yum.repos.d/MariaDB.repo
Add the following to the file:
# MariaDB 10.0 CentOS repository list - created 2015-05-0419:16 UTC
# http://mariadb.org/mariadb/repositories/[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
Then run the following command to install MariaDB 10.0
:
sudo yum install MariaDB-server MariaDB-client
Then start MariaDB service:
service mysql start
Then run mysql_secure_installation
:
mysql_secure_installation
Log in to MariaDB and create the corresponding database user and database:
mysql -uroot -p
CREATE USER 'git'@'localhost' IDENTIFIED BY '$password';
SET storage_engine=INNODB;
CREATE DATABASE IF NOT EXISTS `gitlabhq_production` DEFAULT CHARACTER SET `utf8` COLLATE `utf8_unicode_ci`;
GRANT SELECT, LOCK TABLES, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER ON `gitlabhq_production`.* TO 'git'@'localhost';
\ q
Try to connect to the database with a new user:
sudo -u git -H mysql -u git -p -D gitlabhq_production
\ q
sudo -u -git cd /home/git
sudo -u git -H git clone https://gitlab.com/gitlab-org/gitlab-ce.git -b 7-10-stable gitlab
cd /home/git/gitlab
# Copy the example GitLab config
# Copy the GitLab sample configuration file
sudo -u git -H cp config/gitlab.yml.example config/gitlab.yml
# Make sure to change "localhost" to the fully-qualified domain name of your host serving GitLab where necessary
# Make sure to modify "localhost" to the FQDN of your GitLab host
#
# If you want to use https make sure that you set`https` to `true`. See #using-https for all necessary details.
# If you want to use https make sure you set`https`for`true`. For specific and necessary details, see#using-https
#
# If you installed Git from source, change the git bin_path to /usr/local/bin/git
# If you installed Git from source code, modify the git bin_path is/usr/local/bin/git
sudo -u git -H editor config/gitlab.yml
# Make sure GitLab can write to the log/ and tmp/ directories
# Make sure GitLab can write log/And temp/table of Contents
chown -R git {log,tmp}
chmod -R u+rwX {log,tmp}
# Create directory for satellites
# For satellite(?)Create a directory
sudo -u git -H mkdir /home/git/gitlab-satellites
chmod u+rwx,g+rx,o-rwx /home/git/gitlab-satellites
# Make sure GitLab can write to the tmp/pids/ and tmp/sockets/ directories
# Ensure that GitLab can write to tmp/pids/And temp/sockets/table of Contents
chmod -R u+rwX tmp/{pids,sockets}
# Make sure GitLab can write to the public/uploads/ directory
# Make sure GitLab can write to public/uploads/table of Contents
chmod -R u+rwX public/uploads
# Copy the example Unicorn config
# Copy Unicorn's sample configuration file
sudo -u git -H cp config/unicorn.rb.example config/unicorn.rb
# Enable cluster mode if you expect to have a high load instance
# Ex. change amount of workers to 3for 2GB RAM server
# Enable cluster mode if you expect to have a high load instance
# Attachment: Modify the number of workers to 3 for a server with 2GB memory
sudo -u git -H editor config/unicorn.rb
# Copy the example Rack attack config
# Copy the sample configuration file of Rack attack
sudo -u git -H cp config/initializers/rack_attack.rb.example config/initializers/rack_attack.rb
# Configure Git global settings for git user, useful when editing via web
# Edit user.email according to what is setin config/gitlab.yml
# Configure Git global settings for git users, useful when modifying via the web
# Modify user.email according to config/gitlab.Settings in yml
sudo -u git -H git config --global user.name "GitLab"
sudo -u git -H git config --global user.email "gitlab@localhost"
sudo -u git -H git config --global core.autocrlf input
# MySQL only:
# MySQL only:
sudo -u git cp config/database.yml.mysql config/database.yml
# MySQL and remote PostgreSQL only:
# Update username/password in config/database.yml.
# You only need to adapt the production settings(first part).
# If you followed the database guide then please doas follows:
# Change 'secure password'with the value you have given to $password
# You can keep the double quotes around the password
# Only MySQL and remote PostgreSQL:
# In config/database.Update username in yml/password;
# You only need to adapt the production settings (part one);
# If you follow the database wizard, please do the following:
# modify'secure password'Use the one you just set$password;
# You can keep the double quotes around the password.
sudo -u git -H editor config/database.yml
# PostgreSQL and MySQL:
# Make config/database.yml readable to git only
# PostgreSQL and MySQL:
# Set config/database.yml is only readable by git.
sudo -u git -H chmod o-rwx config/database.yml
cd /home/git/gitlab
# For users from China mainland only
# Only for users in Mainland China
nano /home/git/gitlab/Gemfile
source "http://ruby.taobao.org"//Original source"https://rubygems.org/"
# For MySQL(note, the option says "without ... postgres")
sudo -u git -H bundle install --deployment --without development test postgres aws
GitLab Shell is a SSH access and source management software specially developed for GitLab.
# Go to the Gitlab installation folder:
# Go to the GitLab installation directory:
cd /home/git/gitlab
# For users from China mainland only
# Only for users in Mainland China
nano /home/git/gitlab/Gemfile
source "http://ruby.taobao.org"//Original source"https://rubygems.org/"
# Run the installation task for gitlab-shell(replace `REDIS_URL`if needed):
# Run gitlab-Shell installation task (replace`REDIS_URL`If you need):
sudo -u git -H bundle exec rake gitlab:shell:install[v1.9.6] REDIS_URL=redis://localhost:6379 RAILS_ENV=production
# By default, the gitlab-shell config is generated from your main gitlab config.
# By default, gitlab-The shell configuration file is generated by your gitlab main configuration file.
#
# Note: When using GitLab with HTTPS please change the following:
# - Provide paths to the certificates under `ca_file` and `ca_path options.
# - The `gitlab_url` option must point to the https endpoint of GitLab.
# - In case you are using self signed certificate set `self_signed_cert` to `true`.
# See #using-https for all necessary details.
# Tip: When using GitLab via HTTPS, please make the following changes:
# - The path to provide the certificate is in`ca_file`with`ca_path`Option
# - ` gitlab_url`The option must point to the https endpoint of GitLab;
# - If you use a self-signed certificate, set`self-signed_cert`for`true`。
# For all required specific details see#using-https
#
# You can review(and modify) it as follows:
# You can check (and modify it) through the following methods:
sudo -u git -H editor /home/git/gitlab-shell/config.yml
# Ensure the correct SELinux contexts are set
# Read http://wiki.centos.org/HowTos/Network/SecuringSSH
# Ensure that the correct SELinux context is set
# Read http://wiki.centos.org/HowTos/Network/SecuringSSH
restorecon -Rv /home/git/.ssh
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production
# Type 'yes' to create the database tables.
# When done you see 'Administrator account created:'
Tip: You can set the administrator password by providing it in the environment variable GITLAB_ROOT_PASSWORD, for example:
sudo -u git -H bundle exec rake gitlab:setup RAILS_ENV=production GITLAB_ROOT_PASSWORD=newpassword
Download the initialization script (will be placed in /etc/init.d/gitlab):
sudo cp lib/support/init.d/gitlab /etc/init.d/gitlab
chmod +x /etc/init.d/gitlab
chkconfig --add gitlab
Set GitLab to start on boot:
chkconfig gitlab on
Set log rollover
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
/etc/init.d/gitlab start
Recommended Posts