Koozali.org: home of the SME Server

enabling htaccess causing site to go down

Offline bldgfac

  • *
  • 25
  • +0/-0
enabling htaccess causing site to go down
« on: September 27, 2008, 03:25:50 PM »
Hi,

I'm trying to set up a pw protected dir on my site. This is the guide i'm using: http://wiki.contribs.org/Htaccess#Procedure_-_authentication_against_specified_sme_users

My configuration:

Fragment:
Code: [Select]
/etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/50AddSecureMCUpload
Fragment contents:
Code: [Select]
<Directory /home/e-smith/files/ibays/mc/html/upload>
AuthName "MC Only"
AuthType Basic
AuthExternal pwauth
<Limit GET>
order deny,allow
require user admin
</Limit>
</Directory>

Copied from putty after completing the final steps....
Code: [Select]
[root@server httpd.conf]# expand-template /etc/httpd/conf/httpd.conf         
[root@server httpd.conf]# sv t /service/httpd-e-smith
[root@server httpd.conf]# sv s /service/httpd-e-smith
down: /service/httpd-e-smith: 1s, want up

After following this guide, my site no longer works. I'm assuming because httpd-esmith is 'down'. Does anybody know what's causing this? This is a newly installed server and i've had no problems with this on previous SME installations.

Any help would be appreciated. Thanks!
« Last Edit: September 27, 2008, 03:28:51 PM by bldgfac »

Offline mmccarn

  • *
  • 2,627
  • +10/-0
Re: enabling htaccess causing site to go down
« Reply #1 on: September 27, 2008, 04:23:15 PM »
Every time you run sv restart httpd-e-smith you should get some informative lines in /var/log/httpd/error_log that tell you why the service is failing to start.


Offline bldgfac

  • *
  • 25
  • +0/-0
Re: enabling htaccess causing site to go down
« Reply #2 on: September 27, 2008, 07:14:42 PM »
I'm not seeing any changes in that log file when I restart the service.

The last thing in the log is this:

Code: [Select]
[Sat Sep 27 13:01:06 2008] [notice] caught SIGTERM, shutting down
Which doesn't make sense to me....



Offline mmccarn

  • *
  • 2,627
  • +10/-0
Re: enabling htaccess causing site to go down
« Reply #3 on: September 27, 2008, 08:37:43 PM »
Hmmm...

I applied your changes, changing only the name of the ibay, on my own system with no problems - I was correctly prompted to authenticate to "MC Only", and logged in as "admin" using the admin password for my server.

After intentionally breaking your template-fragment (by changing 'require user admin' to 'require-user admin'), I verified that I don't get anything useful in /var/log/httpd/error_log as I proposed above (sorry to waste your time).

I *do* get useful output, however, if I do:
Code: [Select]
/etc/rc.d/init.d/httpd stop
/etc/rc.d/init.d/httpd start

The specific output I get is:
Code: [Select]
Starting httpd: Syntax error on line 298 of /etc/httpd/conf/httpd.conf:
Invalid command 'require-user', perhaps mis-spelled or defined by a module not included in the server configuration
                                                           [FAILED]
  which would hopefully be enough to point you in the right direction.



 

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: enabling htaccess causing site to go down
« Reply #4 on: September 28, 2008, 04:27:28 AM »
I'm assuming because httpd-esmith is 'down'.

More correctly, it's because httpd-e-smith is not coming up. Do this and you will see why it isn't:

Code: [Select]
cd /service/httpd-e-smith
sv d .
./run

There will be an error message. Fix that problem, and when you run:

Code: [Select]
expand-template /etc/httpd/conf/httpd.conf
./run

then apache will keep running without producing error messages. Once it does that, you can terminate it with ^C, then do:

Code: [Select]
sv u /service/httpd-e-smith


Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: enabling htaccess causing site to go down
« Reply #5 on: September 28, 2008, 04:28:46 AM »
I *do* get useful output, however, if I do:
Code: [Select]
/etc/rc.d/init.d/httpd stop
/etc/rc.d/init.d/httpd start

Perhaps so, but OP should not run those commands.

Offline bldgfac

  • *
  • 25
  • +0/-0
Re: enabling htaccess causing site to go down
« Reply #6 on: September 28, 2008, 04:24:32 PM »
Thanks for the help guys.... much appreciated.

After doing as suggested...
Code: [Select]
[root@server ~]# cd /service/httpd-e-smith
[root@server httpd-e-smith]# sv d.
usage: sv [-v] [-w sec] command service ...

[root@server httpd-e-smith]# ./run
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443
no listening sockets available, shutting down
Unable to open logs

I've tried rebooting many times. Any ideas on how I can fix this?

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: enabling htaccess causing site to go down
« Reply #7 on: September 28, 2008, 04:59:06 PM »
After doing as suggested...
Code: [Select]
[root@server ~]# cd /service/httpd-e-smith
[root@server httpd-e-smith]# sv d.
usage: sv [-v] [-w sec] command service ...

[root@server httpd-e-smith]# ./run
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443
no listening sockets available, shutting down
Unable to open logs

I've tried rebooting many times. Any ideas on how I can fix this?

To fix it, you first need to diagnose what the problem is. I gave you instructions on how to do that. Unfortunately, there is no shortcut.

You made a mistake when you tried to follow my instructions. You typed "sv d." when you needed to type "sv d ."  i.e. you need a space between the 'd' and the period.

Be sure to check carefully exactly what you have put in your custom template. Every character needs to be "just so".
« Last Edit: September 28, 2008, 05:01:16 PM by CharlieBrady »

Offline bldgfac

  • *
  • 25
  • +0/-0
Re: enabling htaccess causing site to go down
« Reply #8 on: September 28, 2008, 07:39:42 PM »
Yea, I noticed I didn't provide a space there. I tried it again and it just kinda hanged there for about 10 minutes until my internet connection died.

Anyway, I went ahead and did what mmccarn had suggested:
Code: [Select]
[root@server ~]# expand-template /etc/httpd/conf/httpd.conf
[root@server ~]# sv t /service/httpd-e-smith
[root@server ~]# sv s /service/httpd-e-smith
down: /service/httpd-e-smith: 10255s
[root@server ~]# /etc/rc.d/init.d/httpd stop
Stopping httpd:                                            [  OK  ]
[root@server ~]# /etc/rc.d/init.d/httpd start
Starting httpd: Syntax error on line 297 of /etc/httpd/conf/httpd.conf:
</Directory>#> directive missing closing '>'
                                                           [FAILED]

So I opened up /etc/httpd/conf/httpd.conf and looked at line 297:
Code: [Select]
line 289 <Directory /home/e-smith/files/ibays/mc/html/upload>
line 290 AuthName "Miss Clifford Only"
line 291 AuthType Basic
line 292 AuthExternal pwauth
line 293 <Limit GET>
line 294 order deny,allow
line 295 require user admin
line 296 </Limit>
line 297 </Directory># blah blah blah (I didn't copy what this actually said)

So I deleted # blah blah blah and retried:
Code: [Select]
[root@server ~]# /etc/rc.d/init.d/httpd start
Starting httpd:                                            [  OK  ]

Now everything works as it should. I don't know if it was the correct way of solving the issue because I didn't really pay attention to the text I removed, but oh well.

Thanks again to the both of you for your help.


Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: enabling htaccess causing site to go down
« Reply #9 on: September 28, 2008, 08:02:47 PM »
So I opened up /etc/httpd/conf/httpd.conf and looked at line 297:
Code: [Select]
line 289 <Directory /home/e-smith/files/ibays/mc/html/upload>
line 290 AuthName "Miss Clifford Only"
line 291 AuthType Basic
line 292 AuthExternal pwauth
line 293 <Limit GET>
line 294 order deny,allow
line 295 require user admin
line 296 </Limit>
line 297 </Directory># blah blah blah (I didn't copy what this actually said)

So I deleted # blah blah blah and retried:

Your custom template probably doesn't have a newline on the last line. Make sure that it ends with a blank line.

If you edited /etc/httpd/conf/httpd.conf, then it is only temporary, until the template is expanded again. You need to fix the custom template.

Offline bldgfac

  • *
  • 25
  • +0/-0
Re: enabling htaccess causing site to go down
« Reply #10 on: September 28, 2008, 09:12:42 PM »
You're correct - I did not have an empty line at the bottom.

I added the line and then expanded the template. It still says 'down', however the site is working fine.

*edit* After rebooting it now says up. Looks like everything is back to normal...
« Last Edit: September 28, 2008, 09:58:56 PM by bldgfac »

Offline CharlieBrady

  • *
  • 6,918
  • +3/-0
Re: enabling htaccess causing site to go down
« Reply #11 on: September 29, 2008, 09:42:34 PM »
Perhaps so, but OP should not run those commands.

Because if he *does* run those commands, he might get a service which shows "down", but nevertheless appears to work - until he reboots. :-)

Offline bldgfac

  • *
  • 25
  • +0/-0
Re: enabling htaccess causing site to go down
« Reply #12 on: September 30, 2008, 02:00:03 AM »
Got it  8-)