Recently I had to install and maintain several Centos servers and I had to repeat the same setup instructions multiple times.
I thought itâd be nice to have the following list of to-do steps which needed to be repeated on every server install, especially so other employees could take on this job after me.
The scenario I had to work on required the setup of a new Centos 6 server with LAMP (php 5.5 at least) and configuring Git and gitolite for git user-managing access.
So the first thing was to install a Centos 6.5 minimal distribution and then all the work was done through Putty and heavy-usage of yum.
To avoid conflicts later-on because of repository packages, one of my colleagues recommended me to use yum-plugin-priorities. (thanks, Madalin đ )
Now, although this plugin is a bit controversial, we found that during our exploitation it was really helpful in preventing our servers to become a packages-mess in no-time. So Iâm gonna go along and recommend it further. You should go however to the link and read the documentation for yum-plugin-priorities to see if it suits your needs and to learn how to proper configure it.
So hereâs the list. It’s not something new or original content, it’s more of a compilation list to have all the info in one place. I have included links to the sites from where the info was used.
- Install yum-plugin-priorities (say yes if youâre asked about a key, itâs because youâre using the repoâs for the first time
yum install yum-plugin-priorities
- install wget:
yum install wget
- cd to userâs home:
cd ~
- install remi repo:
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpmwget http://rpms.famillecollet.com/enterprise/remi-release-6.rpmsudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
You can read more about the remi repo here.
- install webtatic repo:
rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
You can read more about the webtatic repo here.
- Important! edit repo files located in /etc/yum.repos.d/ and enable the ones you want and add priority=N, according to yum-priorities plugin required settings (http://wiki.centos.org/PackageManagement/Yum/Priorities)
. - update your system
yum update
- install sort-of lamp, but don’t install php, since we need php 5.5 at least which we’ll get from the webtatic repo one step later:
Install Apache and start it:yum install httpd service httpd start
Install MySQL and start it:
yum install mysql, mysql-server service mysql start
Secure your fresh MySQL installation by running this script:
/usr/bin/mysql_secure_installation
You can read more about the default configuration for securing your mysql on this tutorial from digitalocean.com
- Install PHP 5.5 and the modules you want (we installed them all)
yum install php55w php55w-bcmath php55w-cli php55w-common php55w-dba php55w-devel php55w-embedded php55w-enchant php55w-fpm php55w-gd php55w-imap php55w-interbase php55w-intl php55w-ldap php55w-mbstring php55w-mcrypt php55w-mssql php55w-mysqlnd php55w-odbc php55w-opcache php55w-pdo php55w-pear.noarch php55w-pecl-apcu php55w-pecl-apcu-devel php55w-pecl-memcache php55w-pecl-xdebug php55w-pgsql php55w-process php55w-pspell php55w-recode php55w-snmp php55w-soap php55w-tidy  php55w-xml php55w-xmlrpc
- donât forget to add chkconfig setting so the services would start automatically
chkconfig --levels 235 httpd on chkconfig --levels 235 mysqld on
- Optionally, install nodejs, if you need it (we did)
yum install nodejs
- Install the dev-tools
yum groupinstall "Development tools"
- Install Git and create user/group
yum install git useradd git usermod -u 600 git groupmod -g 600 git passwd git
- Install gitolite on the server by loging in as git user and cloning the gitolite repo
git clone https://github.com/sitaramc/gitolite
- Since gitolite administration is based on keys and we used windows machines to connect to the linux servers, we used putty to generate keys for every user. Copy-paste the text from puttygen as USERNAME.pub and save the private key as USERNAME.ppkThe .pub key will have to be uploaded by gitolite admin to the gitolite repos which the USERNAME will have access.
We used this tutorial for our first install, what’s really important to keep in mind is that there are two machines in use: one is the server (linux server) and the other is the client (in the tutorial I’ve linked the client is also a linux box; in our scenario the clients were windows machines).
It’s important to note that for the first use of gitolite, you have to create the .pub/.ppk pair of keys for the client user which will be the gitolite admin (so you’ll create this keys on the client machine, may that be linux, windows, w/e) and copy the .pub key into the git folder from the Server machine and give it proper permissions. Let’s say it will be git-admin.pub and git-admin.ppk like in the tutorial link above.
Then, after you’ll install gitolite by logging in as user git onto the server machine, you’ll use the git-admin.pub key as argument to the initial setup of gitolite, like this:gitolite/install -ln gitolite setup -pk Git-Admin.pub
- Since we used windows machines to develop on, we installed git client on them and gitextensions also.For the git installer setup we used the following options:
– advanced context menu, associate .git
– use git bash only
– use plink
– checkout windows style, commit linux styleAnd for the gitextensions setup we used the following options:
– install kdiff only
– use putty
– (dumb observation: sometimes the kdiff installer windows pops under the main gitextensions installer window and at first sight it seems the main installer hanged; it didn’t, it just awaits for your action on the windows behind) - We also had an interesting setup where our git server would automatically deploy upon receive, on the httpd test server installed on the same machine. We used a script placed in hooks/post-receive folder with the following content:
#!/bin/sh GIT_WORK_TREE=/home/path/to/your/www export GIT_WORK_TREE umask 002 git checkout -f
The script has to have proper permissions.
Also, the www folder should be owned by apache user and have the group set to apache group and the git user should be added to the apache group.chmod +x hooks/post-receive chown apache:apache /home/path/to/your/www usermod --groups apache git
Also, you have to init a new empty repo into the www folder
cd /home/path/to/your/www mkdir newfolder cd newfolder git init
- After this, you can create new repos on the git server machine, from the client machine, by using the gitolite-admin repo.You must clone first the admin repo (git clone gitolite-admin.git) on your client machine and then use this repo as a setup tool for the repos you wanna create and manage.You can create new git repos, add users to those repos by putting their pub keys into the keys folder and setting up the gitolite.conf file.
Every time you push the changes for the gitolite-admin repo, the new keys will be uploaded to server and gitolite.conf changes taken into consideration and this will basically be your tool to manage the git repos on the (test) server machine.
A very good tutorial which we initially used when setting gitolite can be found here:Â http://sachinsharm.wordpress.com/2013/10/04/installsetup-and-configure-git-server-with-gitolite-and-gitweb-on-centosrhel-6-4/Â
External links for reference, used in this article:
remi repo:Â http://www.rackspace.com/knowledge_center/article/installing-rhel-epel-repo-on-centos-5x-or-6x
webtatic repo:Â http://webtatic.com/projects/yum-repository/
yum-priorities:Â http://wiki.centos.org/PackageManagement/Yum/Priorities
simple tutorial on lamp install:Â https://www.digitalocean.com/community/articles/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6
about gitolite:Â http://gitolite.com/gitolite/index.html
large tutorial on git and gitolite:Â http://sachinsharm.wordpress.com/2013/10/04/installsetup-and-configure-git-server-with-gitolite-and-gitweb-on-centosrhel-6-4/
git clients:Â http://git-scm.com/downloads
gitextensions for windows:Â https://code.google.com/p/gitextensions/
good info on how to auto-deploy from git server:Â http://stackoverflow.com/questions/9132144/how-can-i-automatically-deploy-my-app-after-a-git-push-github-and-node-js
if you want to install phpmyadmin via yum:Â http://tecadmin.net/how-to-install-phpmyadmin-on-centos-using-yum/
in case you get httpd dead but subsys locked error:Â http://sandzoctanium.com/upgrade-from-php-5-3-to-php-5-5-and-get-error-httpd-dead-but-subsys-locked/