Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: trouble with Apache File Permissions Script

  1. #1

    trouble with Apache File Permissions Script

    Hi, I purchased Peter Harrison's wonderful book Linux Home Networking II to get my personal Web site on my Linux box working. First, some background and I'll try to make it brief: my computer running Red Hat Linux 9 with Apache 2.0 is one of a bunch of computers that are behind a firewalled Linksys router connected to a cable modem. My cable ISP gives me a static IP address as the outside address for my whole network, and I have purchased a fully-qualified domain name from another company that I have linked to my IP address. I also use port forwarding to direct any requests to my Web server to port 80 on my Linux computer.

    My Web pages are located in my Linux machine's /var/www/html directory, and after setting everything up following the instructions in Peter's book I have had no trouble in accessing my main site from outside the network. Specifically, my domain name is McCorduck.ws and pointing a browser to http://McCorduck.ws always brings up the index.html file in the above directory. (I thought I also set it up so that my site ought to accept inquiries to http://www.McCorduck.ws; that doesn't work yet, but that's not something I'm too worried about now.) This index.html file redirects to another page which has sound and graphics, and again there are never any problems calling up this page or any of its elements.

    Under the /var/www/html directory I have a subdirectory named "football" with its own index.html file, intending this to be something like a separate site. When I try to access this "site," however (specifically, when I point a browser to http://McCorduck.ws/football), I can never connect. If I give the address as http://McCorduck.ws/football/index.html or if try to access any of the other pages of this site, though, it does work.

    Interestingly, on the page that my main index.html pages redirects to, I have a link to this other "site" which I give as "http://McCorduck.ws/football". But when I click on it, I get a "cannot find server" error message, or, tellingly, if I'm using the Opera browser I get an error window reading "Could not locate remote server" and titled "http://localhost.localdomain/football/". Now my Linux machine originally had the default hostname "localhost" and domain name "localdomain," but I had since changed them using the "localhost -v" and "domainname -v" commands and put the new names in my zone files as directed in the Home Networking book. Also interestingly, though, when my Linux computer goes through its initial bootup process, I see it still gives the name and domain of the computer as "localhost.localdomain" but when it gets to the Red Hat login screen, it always says "Welcome to edsgate.mccorduck.ws", i.e. with the name of both the computer (edsgate) and my domain (mccorduck.ws) that I had changed it to.

    In trying to resolve this problem, I came upon the section "File Permissions and Apache" on p. 97 of Linux Home Networking II. It seemed to be addressing my problem, so I tried the script on p. 158 that Peter refers to. I wasn't sure where to save the script, but from the indications I put it in the /tmp directory. When I ran it, however, I got the error message "bash: ./fix-www-perms.sh: Permission denied". I created the file as root and I got this message both when I tried to run it as root and also as my regular user name, my reasoning being that some of the Web pages I have in /var/www/html were created by this user (indeed, I'm not sure, but I may have originally created the whole "football" directory as this user, but I've since changed its ownership back to root). I also tried substituting what look to me like grave accents around "find $1" in the first line of the script with single quotation marks, but that made no difference.

    Any help or advice for this problem would be appreciated. Peter, especially, if you monitor these forums, please let me know what you think. Thanks in advance.


    Ed McCorduck
    Department of English
    State University of New York College at Cortland
    http://mccorduck.cortland.edu
    ICQ: http://mccorduck.cortland.edu/pager
    AIM: EdMcCorduck

  2. #2
    Administrator Moderator
    Member
    starfish's Avatar
    Join Date
    Apr 2004
    Posts
    141
    Ed,

    It's probably not a permissions problem, but a missing DirectoryIndex statement in your /etc/httpd/conf/httpd.conf file. Make sure you have it external to any <Directory> directives so that it becomes a "global" parameter for all directories, not just for the particular directory.

    #
    # DirectoryIndex: sets the file that Apache will serve if a directory
    # is requested.
    #
    # The index.html.var file (a type-map) is used to deliver content-
    # negotiated documents. The MultiViews Option can be used for the
    # same purpose, but it is much slower.
    #
    DirectoryIndex index.html index.html.var

    Hope this works.

  3. #3

    Re: trouble with Apache File Permissions Script

    Thanks, starfish. I found the section you mentioned in my httpd.conf file. The last uncommented line read just "DirectoryIndex" so I added the string of text you had after that. I then stopped and restarted httpd, but it still doesn't work; when I try to connect to http://McCorduck.ws/football, in most browsers I try it in I get an error message that goes something like "localhost.localdomain not found."

  4. #4
    Administrator Moderator
    Member
    starfish's Avatar
    Join Date
    Apr 2004
    Posts
    141
    Ed,

    Could you show a copy of the VirtualHost and ServerName sections of your httpd.conf file?

    What is the content of your /etc/hosts file and the /etc/sysconfig/network file?

    I have a feeling the problem lies somewhere in there. The "localhost -v" and "domainname -v" commands are only temporary and are lost on the next reboot. The correct way to configure your /etc/hosts file can be found here:

    http://www.linuxhomenetworking.com/l...work-linux.htm

    You should also have a "HOSTNAME=" entry in your /etc/sysconfig/network file that matches the host name of your server.

  5. #5
    Quote Originally Posted by starfish
    Ed,

    Could you show a copy of the VirtualHost and ServerName sections of your httpd.conf file?
    Sure, I think I located what you asked for (please bear in my mind that I'm still pretty much a stinkin' newbie when it comes to networking and Linux). Here's the Virtual Host section (I probably took a huger chunk out of it than you need):

    ### Section 3: Virtual Hosts
    #
    # VirtualHost: If you want to maintain multiple domains/hostnames on your
    # machine you can setup VirtualHost containers for them. Most configurations
    # use only name-based virtual hosts so the server doesn't need to worry about
    # IP addresses. This is indicated by the asterisks in the directives below.
    #
    # Please see the documentation at
    # <URL:http://httpd.apache.org/docs-2.0/vhosts/>
    # for further details before you try to setup virtual hosts.
    #
    # You may use the command line option '-S' to verify your virtual host
    # configuration.
    #
    # Use name-based virtual hosting.
    #

    # Where do we put the lock and pif files?
    LockFile "/var/lock/httpd.lock"
    CoreDumpDirectory "/etc/httpd"

    # Defaults for virtual hosts


    # Logs


    #
    # Virtual Hosts
    #
    # Virtual host Default Virtual Host
    <VirtualHost *>


    ServerSignature email
    DirectoryIndex index.php index.html index.htm index.shtml


    LogLevel warn
    HostNameLookups off


    </VirtualHost>


    And here's the ServerName section:

    #
    # ServerName gives the name and port that the server uses to identify itself.
    # This can often be determined automatically, but we recommend you specify
    # it explicitly to prevent problems during startup.
    #
    # If this is not set to valid DNS name for your host, server-generated
    # redirections will not work. See also the UseCanonicalName directive.
    #
    # If your host doesn't have a registered DNS name, enter its IP address here.
    # You will have to access it by its address anyway, and this will make
    # redirections work in a sensible way.
    #
    ServerName localhost.localdomain


    #
    # UseCanonicalName: Determines how Apache constructs self-referencing
    # URLs and the SERVER_NAME and SERVER_PORT variables.
    # When set "Off", Apache will use the Hostname and Port supplied
    # by the client. When set "On", Apache will use the value of the
    # ServerName directive.
    #
    UseCanonicalName on




    Quote Originally Posted by starfish
    What is the content of your /etc/hosts file and the /etc/sysconfig/network file?
    Here's my /etc/hosts:

    # Do not remove the following line, or various programs
    # that require network functionality will fail.
    127.0.0.1 localhost.localdomain localhost
    192.168.1.101 edsgate.mccorduck.ws edsgate mail www

    (Just a note: I leave my Linux box on all the time, so it never loses the .101 suffix, the address to which through port forwarding I have all port 80 WWW inquiries to my site go.) And here's my /etc/sysconfig/network:

    NETWORKING=yes
    HOSTNAME=localhost.localdomain



    Quote Originally Posted by starfish
    I have a feeling the problem lies somewhere in there. The "localhost -v" and "domainname -v" commands are only temporary and are lost on the next reboot. The correct way to configure your /etc/hosts file can be found here:

    http://www.linuxhomenetworking.com/l...work-linux.htm

    You should also have a "HOSTNAME=" entry in your /etc/sysconfig/network file that matches the host name of your server.

    I guess you're right. My newbie intuition is telling me I should then change "ServerName localhost.localdomain" in the ServerName section and "HOSTNAME=localhost.localdomain" in /etc/sysconfig/network. I gather I need to replace "localhost.localdomain" in those places, but to what exactly: "edsgate.mccorduck.ws" or just "mccorduck.ws"? Again, "edsgate" is my Linux computer's name and "mccorduck.ws" is of course the domain name I bought.


    Ed McCorduck
    Department of English
    State University of New York College at Cortland
    http://mccorduck.cortland.edu
    ICQ: http://mccorduck.cortland.edu/pager
    AIM: EdMcCorduck

  6. #6
    Administrator Moderator
    Member
    starfish's Avatar
    Join Date
    Apr 2004
    Posts
    141
    Ed,

    #/etc/sysconfig/network

    HOSTNAME=edsgate

    #/etc/hosts

    127.0.0.1 edsgate.mccorduck.ws edsgate mail www localhost.localdomain localhost


    # /etc/httpd/conf/httpd.conf

    UseCanonicalName Off
    ServerName localhost
    DirectoryIndex index.php index.html index.htm index.shtml


    <VirtualHost *>
    • ServerSignature email
      LogLevel warn
      DocumentRoot /directory/where/files/are

    </VirtualHost>


    The Default DocumentRoot is "/var/www/html", add the line only if it is different.
    I think you need to put the DirectoryIndex outside of the <VirtualHost> section.
    Try to keep the /etc/httpd/conf/httpd.conf file as close to the default version as possible and then tweak it till it breaks! Tweaking first usualy adds another gray hair.
    I took the above out of my own server's files, so it should work.

    Life will also be easier if you made your Linux server have a permanent IP address. Running apache on a home network server that uses DHCP is adding another troubleshooting problem in future. For example, if you add a second DHCP PC on the network, it could grab the 192.168.1.101 IP address for itself when the DHCP lease expires.

    Use the link below to set it permanently to 192.168.1.X where X is a value outside of the DHCP range and set port forwarding to this new IP address.

    http://www.linuxhomenetworking.com/l...work-linux.htm

    The /etc/sysconfig/network and IP address changes probably won't take effect until you reboot or issue the "/etc/init.d/network restart" command.

    Let me know if this helps. You need to do all the changes in concert with one another.

    I hope this helps.

  7. #7
    Thank you so much for your help, starfish. I did some of the things you suggested, but I had questions about some other things:


    Quote Originally Posted by starfish
    Ed,

    #/etc/sysconfig/network

    HOSTNAME=edsgate

    #/etc/hosts

    127.0.0.1 edsgate.mccorduck.ws edsgate mail www localhost.localdomain localhost


    # /etc/httpd/conf/httpd.conf

    UseCanonicalName Off
    ServerName localhost
    I did all of these.

    Quote Originally Posted by starfish
    DirectoryIndex index.php index.html index.htm index.shtml
    This was identical to what's in my http.conf file, so I didn't touch it.


    Quote Originally Posted by starfish
    <VirtualHost *>
    • ServerSignature email
      LogLevel warn
      DocumentRoot /directory/where/files/are

    </VirtualHost>
    In my http.conf, "ServerSignature email" is on a line above "DirectoryIndex index.php index.html index.htm index.shtml", and on the following line is "LogLevel warn". I think I understand from what you write below why you don't have the DocumentIndex line here.


    Quote Originally Posted by starfish
    The Default DocumentRoot is "/var/www/html", add the line only if it is different.
    That's how my default DocumentRoot reads, so I didn't touch it.

    Quote Originally Posted by starfish
    I think you need to put the DirectoryIndex outside of the <VirtualHost> section.
    O.K., so do you mean I could put it on a line right before <VirtualHost *>?

    Quote Originally Posted by starfish
    Try to keep the /etc/httpd/conf/httpd.conf file as close to the default version as possible and then tweak it till it breaks! Tweaking first usualy adds another gray hair.
    I took the above out of my own server's files, so it should work.

    Life will also be easier if you made your Linux server have a permanent IP address. Running apache on a home network server that uses DHCP is adding another troubleshooting problem in future. For example, if you add a second DHCP PC on the network, it could grab the 192.168.1.101 IP address for itself when the DHCP lease expires.

    Use the link below to set it permanently to 192.168.1.X where X is a value outside of the DHCP range and set port forwarding to this new IP address.

    http://www.linuxhomenetworking.com/l...work-linux.htm

    The /etc/sysconfig/network and IP address changes probably won't take effect until you reboot or issue the "/etc/init.d/network restart" command.

    Let me know if this helps. You need to do all the changes in concert with one another.

    I hope this helps.
    Thanks, I'll work on giving my Linux machine a unique and permanent IP address as you suggest as soon as I get the other issues above resolved. I really appreciate all your help.


    Ed McCorduck
    Department of English
    State University of New York College at Cortland
    http://mccorduck.cortland.edu
    ICQ: http://mccorduck.cortland.edu/pager
    AIM: EdMcCorduck

  8. #8
    Administrator Moderator
    Member
    starfish's Avatar
    Join Date
    Apr 2004
    Posts
    141
    Ed,

    O.K., so do you mean I could put it on a line right before <VirtualHost *>?
    Yes, you should place it above the <VirtualHost>.

  9. #9
    O.K., I did so and rebooted my system so that all the aforementioned changes you suggested to me should have taken hold. After the reboot, I tried to access (through a remote computer) my home page of my football subdirectory through the address http://McCorduck.ws/football, specifically by clicking on the link for this on my home page http://McCorduck.ws, but the following error box popped up again (I was using Netscape Navigator 7.1 on a Windows machine):


    Alert!

    localhost.localdomain could not be found. Please check the name and try again.


    I typed in the complete URL for the football home page, namely http://McCorduck.ws/football/index.html and this did work, and again I could access any page in this directory.

    So I guess I'm still at a loss as to why the address http://McCorduck.ws/football won't bring up the home page of my football "site." Any further advice you could offer would be appreciated just as much. Thank you in advance.


    Ed McCorduck
    Department of English
    State University of New York College at Cortland
    http://mccorduck.cortland.edu
    ICQ: http://mccorduck.cortland.edu/pager
    AIM: EdMcCorduck

  10. #10
    Administrator Moderator
    Member
    starfish's Avatar
    Join Date
    Apr 2004
    Posts
    141
    Ed,

    I just tried it from my home PC and it works fine using Microsoft Internet Exploder.

    Ask a friend to to give it a try.

Similar Threads

  1. Ubuntu default file permissions
    By RickDev in forum Ubuntu / Debian
    Replies: 1
    Last Post: 01-02-2007, 06:59 PM
  2. file permissions
    By sentme_mail in forum Linux - General Topics
    Replies: 8
    Last Post: 11-20-2004, 04:39 AM
  3. File permissions upon creating the file
    By cloverm in forum Linux - Software, Applications & Programming
    Replies: 2
    Last Post: 05-17-2004, 07:48 PM
  4. Help with file permissions
    By boblucci in forum Linux - General Topics
    Replies: 3
    Last Post: 04-21-2003, 02:28 PM
  5. file permissions reset to 755
    By gomez alert in forum Mandriva
    Replies: 7
    Last Post: 05-15-2002, 10:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •