We need to install EPEL repository for our CentOS. This will be first step to setup our working Web Server. EPEL is additional repository for yum, with tons of useful packages which we won't find in default base repository. We will use it in the future so let's start using it now;)
In this post we will also setup local vagrant box. We will be using it for future operations like installing Apache or Varnish.[sc:lamp_series]
The best idea without messing everything out is to use Vagrant.
If You don't have Vagrant installed please download and install it first. After installation You should be ready to use Vagrant. Create directory in place where You want to keep Your vagrant file.
mkdir vms cd vms
Next thing what we need to do is to download CentOS box. We need the box to replace default one that comes with Vagrant. We will use chef/centos-6.6 from Vagrant boxes directory. You can search more boxes here if You want, for instance You can use 6.5 instead of 6.6. Decision is Yours:)
vagrant box add chef/centos-6.6
Vagrant will download the image of OS You selected. It might take a while, depending on Your network performance.
Next we need to init Vagrant instance.
vagrant init chef/centos-6.6
It will create Vagrantfile in Your directory. You can check out this file in any editor. This file has basic Vagrant configuration, you can adjust the options like forwarded ports, synced folders etc. For now, let's leave this configuration file and let's bring our machine to life!
It will init the machine. After that You can login via SSH and start playing around:)
mkdir vms cd vms vagrant init chef/centos-6.6 vagrant up vagrant ssh
How to install EPEL
Installing EPEL on CentOS is really easy. First of all You need to get the URL for EPEL repo. If You are just following the instructions in this tutorial You can execute the command. But for instance if You have 32bit version instead of 64bit You need to replace x86_64 to i386
yum install http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
Depending on Your vagrant / server setup You might need to execute this command as root or at least as sudo user. If You are just following the steps in this tutorial You are probably Vagrant user. If You execute this command You will see permission denied error. Start this command with sudo (sudo yum install http://....) and everything should be OK:)
Next thing that we need to do is to import GPG key for this repo:
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
And basically that's it! You are now able to use EPEL packages with yum!
To validate the installation You can execute yum repolist command and You should see epel Extra Packages for Enterprise Linux 6 - x86_64
It means that everything is OK. Now, if You want to install any packages with the EPEL repository You need to use
yum --enablerepo=epel install PACKAGE_NAME
yum install http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rp -y rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6
Using Ansible to install EPEL
If You are using Ansible for server provisioning as I do, You can find ansible-webserver project on GitHub
It has EPEL role, that will help You install EPEL via Ansible