1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Starting, running and testing Apache on home linux computer

Discussion in 'Apache' started by mrukjames, Sep 27, 2008.

  1. #1
    Hi,

    I have a simple website and run linux on my computer.

    I'm going to start writing some simple PHP scripts for my website such as feedback/email forms etc. I want to run apache on my computer to test these programs before uploading them to my website.

    I have installed Apache using YAST. I have tried using commands like
    /etc/init.d/httpd start
    Code (markup):
    but nothing happens. How can I get Apache running? There doesn't seem to be much out there for beginners.

    Your help will be greatly appreciated.
    Thanks for your response.
     
    mrukjames, Sep 27, 2008 IP
  2. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #2
    The flavor of Linux you're using might help. Not all distributions are created equal.

    On my Ubuntu Linux (Debian derivitive) I use the following to start/restart/reload the server.
    /etc/init.d/apache2 start|restart|reload
    Code (markup):
     
    joebert, Sep 27, 2008 IP
  3. mrukjames

    mrukjames Peon

    Messages:
    66
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi,
    Thanks for that. It worked! I thought I tried that, but your right- it works!

    Now when I type localhost into my browser it comes up with a 403 Error- Access forbidden! I think it's the default to just block access to everything. How can I overcome this error and get it to point to a single html page on my computer? I've tried messing around with the httpd.conf under the "directory" section but I can't work it out. What should I do next?

    I really appreciate your help :)
     
    mrukjames, Sep 27, 2008 IP
  4. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #4
    First thing to check is the UNIX file permissions.
     
    joebert, Sep 27, 2008 IP
  5. justinlorder

    justinlorder Peon

    Messages:
    4,160
    Likes Received:
    61
    Best Answers:
    0
    Trophy Points:
    0
    #5
    error 403 is not enough permission. check the file permission.

    Good luck to you , guy.
    I have been runnig and learning the linux now.
    All of the command make me mad. I have to run the linux on the vmware.
     
    justinlorder, Sep 27, 2008 IP
  6. joebert

    joebert Well-Known Member

    Messages:
    2,150
    Likes Received:
    88
    Best Answers:
    0
    Trophy Points:
    145
    #6
    I just realized how vague my last reply was.

    When I say check the UNIX file permissions, what I mean that that you need to make sure the files, and the directory the files reside in, grant Read permissions to the user or group Apache is running as.

    If you run the following command in the terminal

    top -b -n 1 | cat
    Code (markup):
    you'll get a block of info about 5 lines long, followed by something similar to this where you can determine the name. That is, if you don't remember the user you put into the apache configuration. (or didn't)

      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                  
    15666 joebert   20   0 34292 2492  844 S  0.0  1.0   0:00.00 apache2 
    Code (markup):
    In some situations, for instance for FTP directory listings to work, and mod_autoindex to work, the user also needs to have Execute permission for the directory.
     
    joebert, Sep 28, 2008 IP
  7. mrukjames

    mrukjames Peon

    Messages:
    66
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi Guys, I really appreciate your help and comments,

    I've checked the file permissions of Apache and my sites directory and they all have write and execute permissions such as:
    
    drwxr-xr-x 10 root root 4096 2008-09-28 13:56 apache2
    Code (markup):
    This includes the files in the directory.
    But when I do that top command it shows:

    7491 root         15   0 91608 3188 1676 S    0  0.3   0:00.10 httpd2-worker
     7492 wwwrun    25   0 91340 1996  484 S    0  0.2   0:00.00 httpd2-worker
     7493 wwwrun    25   0  307m 2680  936 S    0  0.3   0:00.00 httpd2-worker
     7495 wwwrun    25   0  307m 2684  940 S    0  0.3   0:00.00 httpd2-worker
     7498 wwwrun    25   0  307m 3344 1432 S    0  0.3   0:00.00 httpd2-worker
    Code (markup):
    So, I am thinking that maybe there is something wrong with the httpd.conf file.
    I have just made the following ammendments but it still doesn't work:

    # forbid access to the entire filesystem by default
    <Directory /home/james/AMW>
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    Code (markup):
    Thanks for your help. I am sure I will get there soon :)
     
    mrukjames, Sep 28, 2008 IP
  8. mrukjames

    mrukjames Peon

    Messages:
    66
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi I am closer to solving this problem. The apache error logs (I never thought of looking there) now show-

    [Tue Sep 30 20:08:06 2008] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /srv/www/htdocs/
    [Tue Sep 30 20:08:08 2008] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /srv/www/htdocs/
    Code (markup):
    Do you know what this means?? All permissions in directories are read and executable, and the only .html doc is the index.html.

    Is there anything wrong with this configuration?

    # forbid access to the entire filesystem by default
    <Directory /home/james/AMW>
        Options None
        AllowOverride None
        Order allow,deny
        Allow from all
    </Directory>
    
    # use .htaccess files for overriding,
    AccessFileName .htaccess
    # and never show them
    <Files ~ "^\.ht">
        Order allow,deny
        Allow from all
    </Files>
    
    # List of resources to look for when the client requests a directory
    DirectoryIndex index.html index.html.var feedback.html
    
    Code (markup):
    Please let me know your ideas as to what the problem is, thanks.
     
    mrukjames, Sep 30, 2008 IP
  9. cancer10

    cancer10 Guest

    Messages:
    364
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    If you are not sure about the apache installation path, you can try runnning this command instead

    service httpd restart
     
    cancer10, Oct 10, 2008 IP
  10. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #10
    There is probably another <Directory> directive somewhere in the file that has a Deny command.

    The other error message says:
    Directory index forbidden by Options directive:
    Code (markup):
    which means that there is no index.html in that directory and you have specified "Options None". If you want indexes, you need "Options Indexes". If not, try putting an index.html file in that directory.

    Lastly, some day I'm sure you'll be ready to run PHP files. When that happens you will want to add index.php to this line:
    DirectoryIndex index.php index.html index.html.var feedback.html
    Code (markup):
    or do something else like telling apache that PHP files end in .html or using mod_rewrite to rewrite any URLs that end in .html to PHP files.
     
    Ladadadada, Oct 14, 2008 IP
  11. genius24k

    genius24k Active Member

    Messages:
    114
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    58
    #11
    Try putting this on your Directory Option
    --------------
    Options Indexes
    --------------
    Then restart or stop start apache.
     
    genius24k, Oct 16, 2008 IP