Allow Apache to serve sites from /(user) directory; permiss.

Alles, was den Apache betrifft, kann hier besprochen werden.

Allow Apache to serve sites from /(user) directory; permiss.

Postby babacvita » 18. January 2015 17:23

Hi all,

please please help, I'm bangin my head against the wall here. I am on OSX Mavericks, XAMPP latest edition and am trying to change the root directory. Now, I have commented out the first line and added my desired directory in the Apache's main httpd.conf file:

Code: Select all
229  # DocumentRoot "/Applications/XAMPP/xamppfiles/htdocs"
230  DocumentRoot "/Users/edchigliak/dropbox/sites"


But, now I am getting the Access forbidden message. If I am getting everything correctly:

    - Apache is installed in the "MacHD/Applications/XAMPP/" folder and it can only serve files from within that XAMPP folder (actually htdocs subfolder) right?
    - Changing this directory to another which resides inside my "MacHD/user directory/dropbox/sites/" requires that I set up some permissions to this directory; how do I do that?

Do I need to change something in the config file OR (more likely) in the terminal via SUDO commands?

Many thanks, you will save my life!
Alex
babacvita
 
Posts: 6
Joined: 18. January 2015 17:16
Operating System: osx mavericks

Re: Allow Apache to serve sites from /(user) directory; perm

Postby Nobbie » 18. January 2015 19:19

babacvita wrote:please please help, I'm bangin my head against the wall here.


Why? Its by far better to read some documentation instead, it does not hurt and it helps you out. There are plenty of tutorials out there how to configure Apache.

babacvita wrote:But, now I am getting the Access forbidden message.


Of course, if you change the value of "DocumentRoot", you also *should* change the "<Directory ....>" configuration, which usually follows the DocumentRoot in httpd.conf

babacvita wrote:Do I need to change something in the config file ...


Yes, see above.
Nobbie
 
Posts: 8759
Joined: 09. March 2008 13:04

Re: Allow Apache to serve sites from /(user) directory; perm

Postby babacvita » 18. January 2015 19:29

Noobie, thanks for your reply!

Of course banging the head against the wall will not do much :) and reading the docs is a better option but I am a newbie and reading the highly technical documentation does not help me much.

1. I have changed the line that defines document root
2. I have also changed the path to my new document root directory in the <directory> block
3. after that I have included a couple of vhosts in the vhosts.config file and uncommented vhosts include in the main httpd.conf file

This is what my <directory> looks like (I reverted to the standard root path):

Code: Select all
<Directory "/Applications/XAMPP/xamppfiles/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/trunk/mod/core.html#options
    # for more information.
    #
    #Options Indexes FollowSymLinks
    # XAMPP
    Options Indexes FollowSymLinks ExecCGI Includes

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    #AllowOverride None
    # since XAMPP 1.4:
    AllowOverride All

    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>



Now "localhost" simply does not work, it gives back the access denied message. I understand that Apache is running in the Applications folder and that my new root is in the "(myUser)/dropbox/sites" folder. I probably need to give the Apache permissions to read from that folder but I have been googling for hours now to see how to go about this to no avail.

Any tips?

Cheers
Alex
babacvita
 
Posts: 6
Joined: 18. January 2015 17:16
Operating System: osx mavericks

Re: Allow Apache to serve sites from /(user) directory; perm

Postby Nobbie » 18. January 2015 23:01

babacvita wrote:I probably need to give the Apache permissions to read from that folder but I have been googling for hours now to see how to go about this to no avail.


Sorry, but i dont believe that. If you provide the full error message incl. the error number to Google (you did not provide either here), you wont google more than 10 seconds for really helpfull hints.
Nobbie
 
Posts: 8759
Joined: 09. March 2008 13:04

Re: Allow Apache to serve sites from /(user) directory; perm

Postby babacvita » 19. January 2015 13:52

I'm at another computer now so I can't copy error message buit here is what I did yesterday evening.

httpd.conf file
- USER, GROUP - Apache was running as the right user (user: daemon, group: daemon)
=>I tried changing this daemon to myuser and letting apache run under my user; not working
- ROOT - changed htdocs as root directory into my "sites" directory as I stated above; I also changed this path in the <directory> block just below the root line
=> not working
- I added two of those "Allow" directives, as per Linux users instructions, just under "Require all granted"
=> still not working

Terminal
- chmod to all parent folders in the path to my desired "sites" folder, changed to 777 (given all permissions)
=> not working

After that I reverted root back to "htdocs" and tested => works

httpd.conf file
- included httpd-vhosts.con file by uncommenting appropriate line

httpd-vhosts.conf file
- set up 4 of my vhosts (I modified "hosts" file too)
=> localhost not working, other hosts working

I then set up localhost as another virtual host in the vhosts file and of course, it started working again. I have left everything this way and I will develop like this and just copy all the files and folders into my dropbox folder every time I am done with my work. That way I will have cloud backup of my work and still be able to develop locally. Not a great solution because root for Apache needs to be changeable and I really wish to find out why I cannot do it successfully.
babacvita
 
Posts: 6
Joined: 18. January 2015 17:16
Operating System: osx mavericks

Re: Allow Apache to serve sites from /(user) directory; perm

Postby Nobbie » 19. January 2015 16:21

You should read the error_log, which gives you more information about the errors and still you need to specify the error message (incl. error number) precisely.
Nobbie
 
Posts: 8759
Joined: 09. March 2008 13:04

Re: Allow Apache to serve sites from /(user) directory; perm

Postby babacvita » 19. January 2015 20:30

Here is the eror from the log

Code: Select all
::1 - - [19/Jan/2015:20:22:38 +0100] "GET /xampp/ HTTP/1.1" 404 1030


Any ideas what this might be? Thanks!
babacvita
 
Posts: 6
Joined: 18. January 2015 17:16
Operating System: osx mavericks

Re: Allow Apache to serve sites from /(user) directory; perm

Postby Nobbie » 19. January 2015 23:35

babacvita wrote:Any ideas what this might be? Thanks!


Of course, lots of. As you can see, there is a GET command and a folder called /xampp/ and we have a 404 error code. So what did you learn about error code 404, what does it mean?
Nobbie
 
Posts: 8759
Joined: 09. March 2008 13:04

Re: Allow Apache to serve sites from /(user) directory; perm

Postby babacvita » 20. January 2015 13:05

404 means access forbidden, no? Apache can't/doesn't have permission to serve files from that directory.

BUT, more importantly - I have been able to solve the problem. In Apaches main config file httpd.conf, in the <directory> block just beneath the line where the root directory is defined, there are three lines

#AllowOverride all
#from version 1.4:
AllowOverride all

This third line that is uncommented SHOULD be commented! It seems that it conflicts with the directive "Require all granted" which can be found a few lines below.

I changed the directories as I initially wanted, saved all files, restarted apache and voila! It all works now.

My biggest gripe with all this is that I love learning I really do. But this seems like highly inefficient way to learn new stuff... It totally threw me off of my php development and I have lost two days on Apache setup (and a bit of linux) and I still dont feel confident I could solve it next time :(.

Why is there not a simple tutorial on the concepts and directives? Apache docs are cool but for someone who already has a lot of knowledge.

Anyway, thanks for your efforts, much appreciated!
babacvita
 
Posts: 6
Joined: 18. January 2015 17:16
Operating System: osx mavericks

Re: Allow Apache to serve sites from /(user) directory; perm

Postby Nobbie » 20. January 2015 14:26

babacvita wrote:My biggest gripe with all this is that I love learning I really do. But this seems like highly inefficient way to learn new stuff... It totally threw me off of my php development and I have lost two days on Apache setup (and a bit of linux) and I still dont feel confident I could solve it next time :(.

Why is there not a simple tutorial on the concepts and directives? Apache docs are cool but for someone who already has a lot of knowledge.


I dont think it is "inefficient", it is the way it is. When i started to learn about Apache and how to configure Apache, understanding Apache, i found a small note in a documentation which clearly said: "Never forget - configuring Apache is a sophisticated task. Apache is a powerfull tool, it know lots of configurations options and it is always difficult to learn and understand these."

And that is quite true. You are saying, you "lost" two days. But it is not true, you did not lost two days, you spent two days for learning Apache basics. What do you think, how long it took me to become an expert on Apache? Honestly: Years! And i still dont know everything (I know a lot, but are still features, i have never seen and never used until now).

Same thing is for Linux. Fortunately i have been a professinal IT Consultant and Developer for many years and when i started my career as a programmer, i started to learn UNIX first. This was 30 years ago. So I have great knowledge about UNIX and when Linux came up (Linux was unknown in the 80s of the last century), of course it was very easy for me to work with Linux. But i still had to learn about HTML, about Perl, PHP, MySQL and all the related stuff. That was a long period, but i liked it very much. And "two days" means nothing when you have to learn a new, very complex software environment.

Meanwhile, there are plenty of tutorials about Apache etc. in the WWW, i dont know which ones are good or not, you have to find out that for yourselve. But there ary many many tutorials about Apache and about the concept. Take your time and work on it. There is no other way of learning.
Nobbie
 
Posts: 8759
Joined: 09. March 2008 13:04

Re: Allow Apache to serve sites from /(user) directory; perm

Postby babacvita » 20. January 2015 16:00

Noobie, I agree with you. I am a bit frustrated just because I wish to get going with the "core" which is PHP/SQL/web technologies. I understand though, that in order to work with these one must also understand the supporting infrastructure like web server environment, DNS, internet infrastructure etc. And it's good that it is that way and yes, I HAVE learned an amazing lot in these two days.

The only, as I said "problem" that I have, is not the time or that there is a lot to learn, I love challenges. It is the fact that one small update and all hell breaks loose. Like this deprecated directive and nowhere in the documentation was I able to find this.

I believe that if you woke me up in the middle of the night I would know my way around main conf file and where is what. :)
babacvita
 
Posts: 6
Joined: 18. January 2015 17:16
Operating System: osx mavericks


Return to Apache

Who is online

Users browsing this forum: No registered users and 7 guests