No package httpd available, when installing Apache in CentOS

 

Hello guys, in this tutorial I’ll show you how to fix the issue ‘No package httpd available’, Apache is included in default centOS  repository but if your image is customized there are chances server administrators have blocked you from updating or installing httpd service. In this wiki I’ll show you how you can unblock yourself and install httpd service yourself.

Prerequisite to install httpd service

  1. root Access
  2. Text editor of your choice (nano or vi/vim)
  3. Linux VM

 

Error with httpd installation

login to your VM with root or su/sudo yourself to install apache/httpd service with following command :

yum install httpd

and the error will look similar to :

Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
* EA4: 91.197.228.252
* cpanel-plugins: 91.197.228.252
* base: centos.mirror.triple-it.nl
* extras: nl.mirrors.clouvider.net
* updates: nl.mirrors.clouvider.net
No package httpd available.
Error: Nothing to do
[[email protected] etc]#

 

Video tutorial to fix httpd issue

 

Possible solutions to fix ‘No package httpd available’

Solution 1 :

Check centOS base repo for missing or broken links, sometimes this repo file has missing mirror list. Following is the command to print centOS base repo config file

cat /etc/yum.repos.d/CentOS-Base.repo

and the result is

[[email protected] home]# cat /etc/yum.repos.d/CentOS-Base.repo
# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client. You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever – Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os&infra=$inf
ra
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever – Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra
=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever – Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras&infra=
$infra
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever – Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus&infra=$infra
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

 

seems all the links are okay and this can’t be the possible solution in our case.

 

Solution 2 :

check yum conifg itself to see, if system administrator has blocked httpd service, following is the command

cat /etc/yum.conf

 

[main]
exclude=bind-chroot courier* dovecot* exim* filesystem httpd* mod_ssl* mydns* nsd* p0f php* pr
oftpd* pure-ftpd* spamassassin*
tolerant=1
errorlevel=1
cachedir=/var/cache/yum/$basearch/$releasever
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
installonly_limit=5
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org
/bug_report_page.php?category=yum
distroverpkg=centos-release

# This is the default, if you make this bigger yum won’t see if the metadata
# is newer on the remote and so you’ll “gain” the bandwidth of not having to
# download the new metadata and “pay” for it by yum not having correct
# information.
# It is esp. important, to have correct metadata, for distributions like
# Fedora which don’t keep old packages around. If you don’t like this checking
# interupting your command line usage, it’s much better to have something
# manually check the metadata once an hour (yum-updatesd will do this).
# metadata_expire=90m

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

 

there we go, httpd* is included in exclude list of main repo files, you need to remove from exclude list using your favorite text editor and save file

vim /etc/yum.conf
#Remove httpd* from the exclude list

in my case, my exclude should look similar to
[main]
exclude=bind-chroot courier* dovecot* exim* filesystem mod_ssl* mydns* nsd* p0f php* proftpd* pure-ftpd* spamassassin*

now, when you try to install httpd, centOS should find files from the repo


[[email protected] home]# yum install httpd
Loaded plugins: fastestmirror, universal-hooks
Loading mirror speeds from cached hostfile
* EA4: 91.197.228.252
* cpanel-plugins: 91.197.228.252
* base: mirror.1000mbps.com
* extras: mirror.1000mbps.com
* updates: centos.mirror.triple-it.nl
EA4 | 2.9 kB 00:00:00
cpanel-plugins | 2.9 kB 00:00:00
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
mysql-connectors-community | 2.6 kB 00:00:00
mysql-tools-community | 2.6 kB 00:00:00
mysql57-community | 2.6 kB 00:00:00
updates | 2.9 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-97.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-97.el7.centos for package: httpd-2.4.6-97.el7.c
entos.x86_64
--> Running transaction check
---> Package httpd-tools.x86_64 0:2.4.6-97.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved
==============================================================================================
Package Arch Version Repository Size
==============================================================================================
Installing:
httpd x86_64 2.4.6-97.el7.centos updates 2.7 M
Installing for dependencies:
httpd-tools x86_64 2.4.6-97.el7.centos updates 93 k
Transaction Summary
==============================================================================================
Install 1 Package (+1 Dependent package)
Total download size: 2.8 M
Installed size: 9.5 M
Is this ok [y/d/N]: y

This should address the httpd issue, hope you guys like the tutorial 🙂

Cheers

Leave a comment