LinuxQuestions.org
Visit Jeremy's Blog.
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, 04: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, 05: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, 05: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, 07:03 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
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, 09: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, 09:30 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
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, 09: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, 11:39 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
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, 02: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, 03:50 AM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 11,516

Rep: Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501Reputation: 1501
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 11:09 AM
Migrating Apache 1.3 configuration files to Apache 2 kaplan71 Linux - Software 0 03-28-2007 12:05 PM
Apache Configuration dramous Linux - Newbie 5 09-27-2004 03:46 PM
apache configuration bluestorm Linux - General 5 09-26-2003 11:13 AM
apache configuration hardigunawan Linux - Newbie 1 06-21-2002 09:07 AM


All times are GMT -5. The time now is 04:24 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration