0

I want to use a custom folder for my apache web server in XAMPP and set it in the httpd.conf-file

DocumentRoot "/path/to/directory"
  <Directory "/path/to/directory">

I also ensured that the user permission was set for XAMPP to access my custom folder

# OLD ENTRY: User daemon
User Ljonja

But I still get the error 403 on localhost (access forbidden). How do I solve this? I even reinstalled it and did many times of restarting the webserver, or clearing browser cache or trying other browsers ...

Technical Infos:

  • Device: MacBook Air M1
  • System: macOS Monterney 12.2.1 (21D62)
  • XAMPP-version: XAMPP 8.1.2-0
Ljonja
  • 197
  • 9
  • I am confused here... Are you really sure that the actual xampp daemon processes are executed by the account `Ljonja`? I doubt that ... So: what effect user is actually the owner of the httpd process after it has been started? – arkascha Feb 14 '22 at 11:37
  • Oh, and by the way... What is the actual configuration you implemented for that `` section of your configuration? You only pasted the opening tag, why? Please post the full information. – arkascha Feb 14 '22 at 12:25
  • Which account should it be other than my own account? The entry "daemon" did not work and other question-threads suggest doing the thing that I did (changing it to my username). Do you want me to post the entire httpd.conf? It is a standardized file; I only changed the two things: documentroot and user-enty. And I posted both in my question. Es ist zum Mäuse melken :( – Ljonja Feb 14 '22 at 12:32
  • I asked for the implementation of the configuration for that `` section, so up the the closing `` tag. And about the account on which the httpd process is executed: just check that in your process table, I'd say. I would expect that to be a system account, not a user account, since it has to bind to a priviledged port. – arkascha Feb 14 '22 at 13:12
  • The syntax was already in the httpd.conf. I just changed the default-path, not any syntax (if you suppose it's a syntax problem). Besides it probably seems to be a permission-problem. And https://stackoverflow.com/questions/60052142/macos-xampp-access-forbidden-error-403-you-dont-have-permission-to-access-the also states that changing the user to the own name works. Actually also worked on my old macbook. Not shure why it didn't work with my new one. – Ljonja Feb 14 '22 at 13:36
  • Here is the documentation of the ` ... ` directive for the apache http server's core: https://httpd.apache.org/docs/2.4/mod/core.html#directory I have the impression that you just added the opening tag, not the valid section. – arkascha Feb 14 '22 at 13:39
  • If XAMPP executes a system service under your personal account under a MAC system then OK. Highly questionable, but apparently the typical approach then. I just wonder what happens if multiple users do that on a system ... – arkascha Feb 14 '22 at 13:40
  • There is a closing tag in the file, my fault for beeing unclarified. So the syntax is RIGHT - just need it to work. Guess I'll try the terminal version then. – Ljonja Feb 14 '22 at 13:43
  • My idea was that you might have to grant access for that directory inside that `` section. – arkascha Feb 14 '22 at 13:44
  • Yes, it seems that XAMPP does not have access – Ljonja Feb 14 '22 at 13:54
  • Now I got another approach: Just using apachectl. Seems to be a native apache-client. Got it to run, now I only have to know how to change the path – Ljonja Feb 14 '22 at 13:54
  • `apachectl` is a control utility to manage the apache httpd daemon. It is not a "client", it manages the process. Just what XAMPP does, too. You will have to decide: do you want to use XAMPP or "just" the apache http server. – arkascha Feb 14 '22 at 14:29
  • Honestly, right now I "just" need an apache-server. Just want to open localhost and open my project directory; nothing fancy – Ljonja Feb 14 '22 at 14:46
  • Then maybe using "just" an apache http server installation instead of XAMPP might make more sense for you. @AndreC23 already suggest that in his answer below. You also might want to check whether it really has to be an apache server (which is a heavy weight) or whether you can use something more leightweight. Whatever you decide: you have to solve the issue of directory access for the daemon process though. – arkascha Feb 14 '22 at 15:00

2 Answers2

2

I set up the Apache server via brew ( https://tecadmin.net/install-apache-macos-homebrew/ ), big thanks to @AndreC23 for quickly mentioning this idea at the end of your post.

NB: if you are using MacOS i suggest you to install Apache and MariaDB as modules using brew. See: Install & configure apache brew

In the linked tutorial, both User and Group had to be changed in the httpd.conf:

User ljonja
Group staff

Maybe this is also working out at XAMPP, but will be using the brew-variant.

Ljonja
  • 197
  • 9
  • thanks @Ljonja, let me review it on my end and update if mine works okay – Geoffrey Githaiga Mar 17 '22 at 13:06
  • I have seen your suggestion. Tried it but still receive this error: 403 Forbidden You don't have permission to access this resource.Server unable to read htaccess file, denying access to be safe – Geoffrey Githaiga Mar 18 '22 at 08:24
  • I have seen your suggestion. Tried it but still receive this error: 403 Forbidden You don't have permission to access this resource.Server unable to read htaccess file, denying access to be safe – Geoffrey Githaiga Mar 18 '22 at 08:24
  • @GeoffreyGithaiga Did you install it over brew or did you just changed the two things in the htptd.conf with having XAMPP installed? – Ljonja Mar 30 '22 at 14:40
  • Thanks it worked finally. I owe you a big thank you – Geoffrey Githaiga Mar 30 '22 at 18:11
0

Maybe is not an owning problem but a permission problem.

Try first with: sudo chown -R <user>:<group> ./folder_path Then: sudo chmod -R 777 ./folder_path

This should solve most permission problems.

NB: if you are using MacOS i suggest you to install Apache and MariaDB as modules using brew. See: Install & configure apache brew See: Install & configure mariaDB brew

AndreC23
  • 158
  • 1
  • 14
  • Pasted this into the terminal: `sudo chown -R Ljonja /path/to/directory sudo chmod -R 777 /path/to/directory` did not work:( I did not add the -Parameter, since I'm not shure which group I am – Ljonja Feb 14 '22 at 11:36
  • This is not really an answer to the question. It is more some general statements having to do with the topic of the question. The OP clearly stated that he did change file system permissions for that folder. And he apparently wants to use XAMPP and _not_ apache and mysql. So the question is what is wrong with that described setup and not what could generally be done. – arkascha Feb 14 '22 at 11:37
  • My mission now is just to get the apache web server running. I don't mind which tool I'm using (XAMPP/brew). But the brew seems to work similar with the httpd.conf file so I doubt that the brew version also has access. Just want to solve this access problem :/ – Ljonja Feb 14 '22 at 11:42
  • @arkascha Nowhere does it say that he wants to use XAMPP, from what I understand he needs to start the webserver. Since the configuration posted at syntax level seems to be correct it is more likely that it was a folder permissions issue. Generic things are the first things you try :) – AndreC23 Feb 14 '22 at 11:49
  • @Ljonja as far as MacOS is concerned, it's always preferable to use Apache & MyQL/MariaDB installed as modules, they give much less trouble and are more performant. Not necessarily that using them will cause the same problem. It could be that the owner of the directory must be the process running XAMPP or Apache. Check the default directory that was there as document root what permissions and what owner it had and assign them to your custom directory. – AndreC23 Feb 14 '22 at 11:50
  • The original path (that worked) had one differene in permissions: "admin - Read & WRITE". Added that to my folder Did not work either :/ – Ljonja Feb 14 '22 at 12:12
  • @AndreC23 I fail to understand your "nowhere does it say". "I want to use a custom folder for my apache web server in XAMPP" pretty much says exactly what the OP wants. In my experience it always makes sense to _first_ find out what the actual situation is, then what actually causes problems so that those can be fixes. You approach of _guessing_ may succeed, but computer science is not a lottery one wants to win in my eyes. ;-) And now I am out, take care all. – arkascha Feb 14 '22 at 12:27
  • @Ljonja I have the same issue as you but reading through the comments, I still don't find an answer. What am trying to achieve is simple. Instead of using the default directory as pre-defined by httpd, I am using a vhost and want to use my custom folder outside the Library main folder. I have tried setting and resetting the permissions as most suggest but still get the 403. I have tried the different directory roles (Deny,allow, grant and so) nothing works. Using the default directory results me to sudo each save change to my files which as a programmer is nagging – Geoffrey Githaiga Mar 04 '22 at 10:20
  • @Ljonja incase you got a solution please share – Geoffrey Githaiga Mar 04 '22 at 11:25
  • @GeoffreyGithaiga I just found the solution by using the brew method (see my answer-post). – Ljonja Mar 17 '22 at 13:03
  • 1
    @AndreC23 thanks for the tip with using brew :) – Ljonja Mar 17 '22 at 13:04