LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-22-2014, 03:45 AM   #1
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Rep: Reputation: Disabled
Apache configuration


Hi,

I am using centos6 x86 and Apache2. I configure virutal host.
Code:
<VirtualHost *:80>
    ServerAdmin root@gai.net
    DocumentRoot /public/Packages
    <Directory "/public/Packages">
        Options Indexes FollowSymLinks
    </Directory>
    ServerName packages.gai.net
    ErrorLog logs/packages.gai.net-error_log
#    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
But i can't access this directory name packages.gai.net. when i open this url, default apache page opens up.
Could you one help?
 
Old 05-22-2014, 04:37 AM   #2
hairysocks
Member
 
Registered: May 2002
Location: Thorverton, Near Exeter, Devon, England
Distribution: Ubuntu 10.04 (used to be Red Hat 7.1, then Red Hat 9, then FC 2, FC 5, FC 6, FC 9 and Ubuntu 8.04)
Posts: 105

Rep: Reputation: 16
Check if selinux is enabled. If it is then try disabling it and test again. If it works when selinux is disabled, then you need to set the web documents directory correctly for selinux to allow access.
 
Old 05-22-2014, 04:44 AM   #3
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by hairysocks View Post
Check if selinux is enabled. If it is then try disabling it and test again. If it works when selinux is disabled, then you need to set the web documents directory correctly for selinux to allow access.
No, SElinux is not enabled.
when i change from
Code:
<LocationMatch "^/+$">
    Options -Indexes
    ErrorDocument 403 /error/noindex.html
</LocationMatch>
To

Code:
<LocationMatch "^/+$">
    Options Indexes
    ErrorDocument 403 /error/noindex.html
</LocationMatch>
It works but why do i need to change this file. What is the fix for the same. How directory directive should be configure in virtual host section for this to work.
 
Old 05-22-2014, 06:03 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
when i change from
Code:

<LocationMatch "^/+$">
Options -Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>

To

Code:

<LocationMatch "^/+$">
Options Indexes
ErrorDocument 403 /error/noindex.html
</LocationMatch>

It works but why do i need to change this file. What is the fix for the same. How directory directive should be configure in virtual host section for this to work.
It means that you don't have an index page, so with the 1st setup you get a 403 error (directory index forbidden), while with the 2nd you get a directory listing.
To "fix" it you need to add in the "DirectoryIndex" option the index page you're using
 
Old 05-22-2014, 08:06 AM   #5
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bathory View Post
It means that you don't have an index page, so with the 1st setup you get a 403 error (directory index forbidden), while with the 2nd you get a directory listing.
To "fix" it you need to add in the "DirectoryIndex" option the index page you're using
Now i am getting new error. could you tell me the fix for this also plz.
Quote:
[root@GAIDL-5015 Packages]# service httpd restart
Stopping httpd: [FAILED]
Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs
[FAILED]
[root@GAIDL-5015 Packages]#
Thanks for replying,

I don't have index page in that directory but i want to show all files and folder for that directory. i got to know this can be achieved by using directory directive.

where should i add DirectoryIndex option. I am not using any index page.
 
Old 05-22-2014, 08:30 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
service httpd restart
Stopping httpd: [FAILED]
Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:80
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Most likely you are using 2 times the "Listen ..." directive:


Quote:
I don't have index page in that directory but i want to show all files and folder for that directory. i got to know this can be achieved by using directory directive.
If you want to list all files in a directory then you don't need an index page and you'll have to use the directive:
Code:
Options Indexes
 
Old 05-22-2014, 08:59 AM   #7
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bathory View Post
Most likely you are using 2 times the "Listen ..." directive:


If you want to list all files in a directory then you don't need an index page and you'll have to use the directive:
Code:
Options Indexes
Actually first problem was solved by kill httpd process which was using port number 80 and restarting service.

i have added
Code:
Options Indexes
in virtual host section but still i am not able to list all the files of that directory. i have put "hello world" index. html in that directory. instead of showing files it is showing the content of that index.html.

Code:
<VirtualHost *:80>
    <Directory /public/Packages>
        Options Indexes
    </Directory>
    ServerAdmin root@gai.net
    DocumentRoot /public/Packages
    ServerName packages.gai.net
    ErrorLog logs/packages.gai.net_error-log
#    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
 
Old 05-22-2014, 10:39 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
i have added

Options Indexes

in virtual host section but still i am not able to list all the files of that directory. i have put "hello world" index. html in that directory. instead of showing files it is showing the content of that index.html.
This is how it works. If you use an index page, you cannot have a directory listing. From apache documentation:
Quote:
Indexes
If a URL which maps to a directory is requested, and there is no DirectoryIndex (e.g., index.html) in that directory, then mod_autoindex will return a formatted listing of the directory.
 
1 members found this post helpful.
Old 05-23-2014, 01:50 AM   #9
sachin.davra
Member
 
Registered: Jul 2013
Posts: 213

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by bathory View Post
This is how it works. If you use an index page, you cannot have a directory listing. From apache documentation:
I have removed index.html but now it shows default apache page.

my virtual host directive is
Code:
<VirtualHost *:80>
    <Directory /public/Packages>
        Options Indexes FollowSymLinks
    </Directory>
    ServerAdmin root@gai.net
    DocumentRoot /public/Packages
    ServerName packages.gai.net
    ErrorLog logs/packages.gai.net_error-log
#    CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
What's wrong in it?
 
Old 05-23-2014, 02:50 AM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
I have removed index.html but now it shows default apache page.
Apache shows the default vhost, if a specific vhost is not configured.
What gives
Code:
httpd -S
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where to Add mod_evasive configuration to Apache configuration file.? Unknown3r Linux - Newbie 1 11-04-2012 10:09 AM
Migrating Apache 1.3 configuration files to Apache 2 kaplan71 Linux - Software 0 03-28-2007 11:05 AM
Apache Configuration dramous Linux - Newbie 5 09-27-2004 02:46 PM
apache configuration bluestorm Linux - General 5 09-26-2003 10:13 AM
apache configuration hardigunawan Linux - Newbie 1 06-21-2002 08:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:40 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration