Enabling Directory browsing is not recommended because of security purposes. However, sometimes, you still need this option to show something like files, folders, and pictures or something else. Today, I will show you in my case that I created my CentOS Local repo based baseurl http. This example is tested in my VMware test CentOS 7 machine and its working very fine. Note that the default server application is Apache.
Please follow the bellow steps :
1. Remove the Welcome Page
2. Add the Virtual host.
3. Add content.
Remove Welcome Page
if you have no “index.html” files on the folder the apache will stay showing the welcome page. This why we have to remove it.
rm -rf /etc/httpd/conf.d/welcome.conf
Add the Virtual Host
I dedicated this vhost to CentOS packages. For this reason, I created the example vhsost – centos.osradar.com. In your case, please replace the vhost bellow with your own vshost and dont forget to add the vhost to “/etc/hosts” file or “C:\Windows\system32\drivers\etc\hosts”
<VirtualHost centos.osradar.com:80> ServerAdmin [email protected] ServerName centos.osradar.com DocumentRoot /var/www/centos <Directory “/var/www/centos“> Options All Indexes FollowSymLinks Require all granted </Directory> ErrorLog logs/centos.osradar.com-error_log CustomLog logs/centos.osradar.com-access_log combined </VirtualHost>
In my case, I want to see all my CentOS 7 ISO packages and files
Mount the DVD ROM.
mount /dev/cdrom /var/www/centos
Restart the Apache server.
Test it by visiting the URL.
Disable or enable the firewall
firewall-cmd --permanent --add-service=http firewall-cmd --reload
Now check the links bellow
http://your.ip.add.ress or http://hostname
Now you could see the directories and files
yon can use this url as yum repo url
[[email protected] yum.repos.d]# cat /etc/yum.repos.d/rhel.repo [centos-repo] name = centos repo server baseurl=http://centos.example.com enabled=1 gpgcheck=0 [[email protected] yum.repos.d]#
Is it Working? Check it out:
[[email protected] yum.repos.d]# yum repolist Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile repo id repo name status centos-repo centos repo server 3,894 repolist: 3,894 [[email protected] yum.repos.d]#
Yes, it’s working! Enjoy!