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.

Apache Configuration Questions

Discussion in 'Apache' started by dclarke, Feb 9, 2016.

  1. #1
    Hey,

    So here is my problem. I am currently trying to install and configure LAMPP on Ubuntu Server 14.04 LTS for the purpose of installing Joomla using this tutorial:

    https://docs.joomla.org/Configuring_a_LAMPP_server_for_PHP_development/Linux_desktop

    I am able to successfully get to "Creating the New Site" section, specifically where is wants to test the new site by placing a today.php script in the folder then test it by using the web browser. When I try going to localhost/today.php I get the following error:

    Forbidden
    You don't have permission to access /today.php on this server.
    Apache/2.4.7 (Ubuntu) Server at 192.168.200.17 Port 80

    I went ahead and followed the rest of the tutorial and thought I would troubleshoot after I was done, so here I am. Can someone help with this issue?

    I am also planning on hosting multiple sites/domains from this one Virtual Server so any help on that would be appreciated as well.

    Thanks in advance.
     
    dclarke, Feb 9, 2016 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    PoPSiCLe, Feb 9, 2016 IP
  3. th.sigit

    th.sigit Well-Known Member

    Messages:
    178
    Likes Received:
    32
    Best Answers:
    1
    Trophy Points:
    135
    #3
    Where did you put your file? Provided that you are following the tutorial thoroughly, I am going to assume that you created the following directories:

    ~/youruser/lamp/
    ~/youruser/lamp/public_html/
    ~/youruser/lamp/logs/

    Your today.php file should be within ~/youruser/lamp/public_html/

    If that is correct, you should check who is the owner of today.php, is it root? e.g. you create or move that file using 'sudo' command --I did a lot of this mistake. Your 'today.php' should be owned by you:you or by www-data:www-data.

    If you plan to host multiple sites on that VPS, you can consult the examples here http://httpd.apache.org/docs/2.4/vhosts/examples.html
     
    th.sigit, Feb 9, 2016 IP
  4. dclarke

    dclarke Greenhorn

    Messages:
    6
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    13
    #4
    Hi, thanks for your response. I did create the following directories:

    ~/youruser/lamp/
    ~/youruser/lamp/public_html/
    ~/youruser/lamp/logs/

    My today.php file is located here:

    ~/youruser/lamp/public_html/today.php

    The owner of the folder: public_html is www-data

    The owner of the file today.php is www-data
    The group of the file today.php www-data

    I went ahead and installed the GUI for Ubuntu to help me get a better undertsanding of what was going on, currently the public_html folder is showing a lock on the folder? I'll attach a screenshot:

    http://imgur.com/iIZC0KE

    Thanks for any additional help resolving this. If you need to see my Apache config file I can upload that as well.

    Thanks

    -Daniel
     
    Last edited: Feb 10, 2016
    dclarke, Feb 10, 2016 IP
  5. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #5
    What's the permissions on the actual public_html-folder?
     
    PoPSiCLe, Feb 10, 2016 IP
  6. dclarke

    dclarke Greenhorn

    Messages:
    6
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    13
    #6
    The current permission for the folder "public_html" is:

    Owner: www-data
    Group: www-data
    Others:

    I have also linked a image of the directory permissions.

    http://imgur.com/YjnDTWI

    Thanks

    -Daniel
     
    dclarke, Feb 10, 2016 IP
  7. th.sigit

    th.sigit Well-Known Member

    Messages:
    178
    Likes Received:
    32
    Best Answers:
    1
    Trophy Points:
    135
    #7
    Hi there.
    http://imgur.com/iIZC0KE did not provide much info, unless you configure nautilus to view the directory content in details, not as thumbnails (it is one of the buttons on the upper right). However, looking at http://imgur.com/YjnDTWI, it seems that the directory permission is wrong --Owner need to be able to read & write, Group is able to read only, and Others is able to read only the public_html directory.

    (can't send you my screenshot, because my /var/www directory in my current machine is on a ntfs partition and I didn't set my /etc/fstab properly so all files/directory permissions are writable --after all, it is a local development server)

    Next time you would want to show your files/directory permissions from terminal, using a command e.g (type in terminal):
    Also if you plan to host multiple sites/domain and further managing your server (like for example on a remote VPS somewhere), it will be much easier and quicker (and less resources consumed) if you would manage them GUI-less, that is: from terminal.

    For now, you can probably try this command and see if it works:

    Additional note regarding permissions:

    • in a web directory, all sub-directories are usually set with permissions 755
    • all files are set with permissions 644, except for files with extra security permission you would probably need to set them 444 or 600.

    Look for "symbolic notation" and "numeric notation" here: https://en.wikipedia.org/wiki/File_system_permissions
     
    th.sigit, Feb 10, 2016 IP
  8. th.sigit

    th.sigit Well-Known Member

    Messages:
    178
    Likes Received:
    32
    Best Answers:
    1
    Trophy Points:
    135
    #8
    Edit: should be

    (capital 'R')

    Additionally you need to add youruser to www-data, and allow members of www-data group to read/write the directory. Basically it consists of 3 steps:

    this one adds existing user to www-data group
    this one allows members of www-data group to read/write/execute ~/youruser/lamp/public_html/.

    Consult
    (type in terminal) for what do
    mean, or http://www.computerhope.com/unix/uchmod.htm for the easier to read.
     
    th.sigit, Feb 10, 2016 IP
  9. dclarke

    dclarke Greenhorn

    Messages:
    6
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    13
    #9
    Hi, thanks again for your responses and working with me on this issue. I apologize I am new to linux and am having some issue with the following:

    Consult:
    man chmod

    (type in terminal) for what do:

    [ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+

    Could you please explain what I am suppose to do in more detail?

    Thanks
     
    Last edited: Feb 11, 2016
    dclarke, Feb 11, 2016 IP
  10. th.sigit

    th.sigit Well-Known Member

    Messages:
    178
    Likes Received:
    32
    Best Answers:
    1
    Trophy Points:
    135
    #10
    Hmm, sorry I may have confused you with the formatting.

    Try these 3 steps:

    chmod -Rf 755 ~/youruser/lamp/public_html/
    Code (markup):
    This will change all your files and directories under ~/youruser/lamp/public_html/ (which is correct for the directories, but not for files) to 755

    sudo usermod -aG www-data youruser
    Code (markup):
    This one will add youruser to www-data group (or more accurately, this one adds an existing user to a group)

    sudo chmod -R g+rwX ~/youruser/lamp/public_html/
    Code (markup):
    This one will allow youruser to read/write/eXecute ~/youruser/lamp/public_html/ (more accurately, this one allow members of www-data to +rwX ~/youruser/lamp/public_html/)

    An extra step, e.g. you already have files under ~/youruser/lamp/public_html/, you need to change their permissions back to 644 with this command:
    sudo find ~/youruser/lamp/public_html/ -type f -print0 | sudo xargs -0 chmod 0644
    Code (markup):
    This one will look for all files under ~/youruser/lamp/public_html/, and change their permissions to 0644. Note that you may have some files that should have more restricted permissions (usually there are not many, only one or two), you need to change them manually.

    Regarding permissions, I suggest you to read the manuals by typing in your console: man chmod. It is all in there.

    ugoa: user, group, others, all
    rwxXst: read, write, execute (if no execute permissions applied already), eXecute (if there is execute permissions already applied), etc ...
     
    th.sigit, Feb 11, 2016 IP
  11. dclarke

    dclarke Greenhorn

    Messages:
    6
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    13
    #11
    Thank you, I did not have time to do this today but will try to get it competed over the weekend. Thanks again for the help.
     
    dclarke, Feb 12, 2016 IP
    th.sigit likes this.