2

I am trying to configure Apache2 so I can use MySQL for authenticating users to access certain pages. Also authorization needs to work so different groups can reach differen pages.

Now, I have googled a lot but can't find out how to do this. At least not for the configuration I am having. There doesn't seem to be any version of mod_auth_mysql that supports my configuration.

OSX 10.6.4

Apache 2.2

Now, how do I achieve this not creating my own login-application in php but using the built in support of Apache2? I'm totally stuck on this one...

Thanks in advance!

Regards, Niklas

Andrew Flanagan
  • 4,267
  • 3
  • 25
  • 37
Nicsoft
  • 3,644
  • 9
  • 41
  • 70
  • On my quest to solve this I have bumped into several problems. I did create a new post here for one of my subproblems: http://stackoverflow.com/questions/4082067/getting-apache2-and-mysql-working-together-getting-invalid-command-dbdriver – Nicsoft Nov 02 '10 at 21:04

3 Answers3

1

You can build mod_auth_mysql from the source. Have a look at this post.

krico
  • 5,723
  • 2
  • 25
  • 28
  • I will check it out in a couple of days and return to this post. Thanks! – Nicsoft Oct 28 '10 at 10:26
  • This just uses the standard HTTP authentication mechanisms but with a mysql backend for the data. – symcbean Nov 02 '10 at 15:03
  • I think mod_auth_mysql is for old versions of Apache? I am trying to use mod_dbd but I need to recompile apache with those modules. – Nicsoft Nov 02 '10 at 18:40
  • On my quest to solve this I have bumped into several problems. I did create a new post here for one of my subproblems: http://stackoverflow.com/questions/4082067/getting-apache2-and-mysql-working-together-getting-invalid-command-dbdriver – Nicsoft Nov 02 '10 at 21:05
1

I also would like to use a taylormade login page, not pop-up

....

how do I achieve this not creating my own login-application in php but using the built in support of Apache2

Short answer is that you can't. Unless you rewrite the Apache source code or create your own module, you can't mix HTTP based authentication with non-pop-up login prompts.

However if you are using PHP then a relatively low impact solution would be to use auto-prepend to prefix every protected page with a check on the users session. Obviously this would need a bit more thought if it is to be applied to files other than PHP source files (it'll work perfectly well if you tell Apache to apply the php engine to, say .gif files, but your script will need to detect and return the appropriate mime type).

A simpler solution might be to put a tool like squid in front of the webserver as a reverse proxy, then make the session handling data available to the squid url-rewriter.

symcbean
  • 47,736
  • 6
  • 59
  • 94
  • On my quest to solve this I have bumped into several problems. I did create a new post here for one of my subproblems: http://stackoverflow.com/questions/4082067/getting-apache2-and-mysql-working-together-getting-invalid-command-dbdriver – Nicsoft Nov 02 '10 at 21:06
1

I you want your own log-in page, you cannot use Apache to do authentication.

Apache authentication uses the Authentication portion of the HTTP standard, and as a result you're reliant on the browser to handle the interaction with the user. There are plugins (like mod_auth_mysql) to use a database as the backend for this, but Apache can't ask the user for their credentials any other way.

The fastest approach might well be to set up Drupal or Joomla, which will get you user and group management as well as full content editing, in a way that will let you control who can edit what.

Judson
  • 744
  • 6
  • 12
  • Thank you for your answer. I havent' used Joomla! But as I understand it is a CMS but I need to create an application which is highly interactive, where the main purpose of the application is for the user to store data and for some administrator to create reports based on that data. Not sure if that's a good solution. – Nicsoft Nov 02 '10 at 18:49
  • On my quest to solve this I have bumped into several problems. I did create a new post here for one of my subproblems: http://stackoverflow.com/questions/4082067/getting-apache2-and-mysql-working-together-getting-invalid-command-dbdriver – Nicsoft Nov 02 '10 at 21:05
  • If you're looking to build an application, then the authentication should be part of your app. I was under the impression you were trying to build a static website or something like that. – Judson Nov 03 '10 at 23:19