htaccess files not working after update to PHP 5

Discussion in 'Web Design and Development' started by nitz, Feb 17, 2010.

  1. nitz macrumors member

    nitz

    Joined:
    Jan 23, 2003
    Location:
    Germany
    #1
    Okay this problem has got me stumped.

    I have a new and fully updated version of 10.4.11 Server on a Dual 1.8 GHz PowerMac G5. For the new version of Typo3 I needed to use PHP 5 so I updated to php PHP/5.2.10 using this tutorial. After a few mistakes and false starts I successfully got PHP 5 up and running. The only problem I have is that not my .htaccess files are being ignored.

    At first I noticed that mod_rewrite was not working and I initialy thought that it wasn't enabled in the httpd.conf file. While trying to figure out why it wouldn't work, I determined that it was actually the .htaccess file that was being ignored.

    I checked in the Apache config file at /etc/httpd/httpd.conf and the lines used to activate htaccess are already uncommented by default.

    How is it that my new php installation somehow caused this change to Apache?

    Is there another httpd.conf file somewhere that is being used as to the one in the default location?

    Also I tried this on another machine (Also a PowerMac G5 with 10.4.11) and have the same problem, however, the php5 updater was from entropy.ch

    I've never had this problem before. Has anybody else?

    Any tips? I have the feeling I am overlooking something so obvious but I can't figure it out.
     
  2. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #2
    PHP and .htaccess files shouldn't have any effect on one another. Well, PHP shouldn't effect .htaccess files. Have you done simple tests in the .htaccess file to see if the file is completely ignored or just some commands? Do something like,
    Code:
    SetEnv TEST_VAR "test value"
    Then, from a PHP file,
    PHP:
    echo $_SERVER['TEST_VAR'];
     
  3. nitz thread starter macrumors member

    nitz

    Joined:
    Jan 23, 2003
    Location:
    Germany
    #3
    PHP and .htaccess files shouldn't have any effect on one another.

    I know, it makes no sense. That's why I'm stumped here. But it's happening on 2 machines after I updated to php5. I'm going on the assumption it is an Apache config problem because php effecting apache in this way doesn't make sense. Version is Apache/1.3.41 BTW.

    When I enter the following in Terminal...
    Code:
    apachectl configtest
    I get the following result:
    Code:
    Processing config directory: /etc/httpd/sites/*.conf
     Processing config file: /etc/httpd/sites/0000_any_80_.conf
     Processing config file: /etc/httpd/sites/virtual_host_global.conf
    Syntax OK
    The default /etc/httpd/httpd.conf file is not listed. Shouldn't it be?


    Okay, I created an .htaccess file with the line...

    Code:
    SetEnv TEST_VAR "test value"
    And I created a php file (test.php) with the following in it...
    Code:
    <?php
    echo $_SERVER['TEST_VAR'];
    ?>
    And when I call it up, I just get a blank page.

    In my httpd.conf the following lines are present or uncommented....

    Code:
    <Directory "/">
    	Options FollowSymLinks
    	AllowOverride All
    </Directory>
    I have also tried variants of AllowOverride None, All Authconfig, and Options with restarting Apache every time I changed it, but it still didn't change anything.

    Also, in case someone wants to know, the line
    Code:
    AccessFileName .htaccess
    is also not commented.
     
  4. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #4
    It looks like it's possibly using a different httpd.conf file than you're expecting. I'm not at my Mac to see which ones I have. I usually use MAMP for local testing and development and it keeps the files a little more tidy. Maybe something you should look into.

    If you're getting that blank page, then likely it doesn't know what that environment variable is that was set in the .htaccess file. You can check the PHP error log, which should tell you more.

    Here's a command that should look for any instances of the httpd.conf file on your system. Though you may want to give it a deeper path (/etc rather than /) that way it doesn't also search external volumes. I'm mostly sure about this syntax.
    Code:
    sudo find / -name "httpd.conf" -print
     
  5. nitz thread starter macrumors member

    nitz

    Joined:
    Jan 23, 2003
    Location:
    Germany
    #5
    Yeah I did that and got...
    Code:
    /opt/apache2/conf/httpd.conf
    /opt/local/var/macports/sources/rsync.macports.org/release/ports/sysutils/backuppc/files/httpd.conf
    /private/etc/httpd/httpd.conf
    I'm pretty sure that /private/etc/httpd/httpd.conf is the one being loaded. For instance, when I change things in the file, like turn php off and own, the server's behavior changes and downloads the php files instead of rendering them properly.

    Does my syntax for activating the htaccess files look alright?

    Thanks for the help by the way.
     
  6. designguy79 macrumors 6502

    Joined:
    Sep 24, 2009
    Location:
    Michigan
    #6
    Did you install suphp? Even if you didn't, I would check the permissions and file ownership... just a thought, I could be recalling an issue I had like this incorrectly. Good luck!
     
  7. angelwatt Moderator emeritus

    angelwatt

    Joined:
    Aug 16, 2005
    Location:
    USA
    #7
    Syntax looks fine for accessing .htaccess file, same as mine. It is strange that your configtest command earlier didn't show the /private/etc/httpd/httpd.conf file. As you probably have figured out,
    Code:
    [B]/private[/B]/etc/httpd/httpd.conf == /etc/httpd/httpd.conf
    The idea above about checking permissions would be a good step. Maybe even trying a repair permissions from Disk Utility may help.

    Have you run into any other issues since this update? Can you do a PHP file with phpinfo() in it and see what information it shows. There could be a clue in there.
     
  8. nitz thread starter macrumors member

    nitz

    Joined:
    Jan 23, 2003
    Location:
    Germany
    #8
    Yeah permissions were checked and repaired. Permissions for the .htaccess file and the httpd.conf file are 644. That's correct, right?

    I thought it was weird as well that the configtest didn't show the config file at /private/etc/httpd/httpd.conf

    I'm digging around some more to see if this has anything to do with it.

    The phpinfo was one of the first things I checked but it didn't show anything obvious.

    Nothing showing up in my php error_log file either.

    Hmmm, I'll have to work on this over the weekend
     
  9. designguy79 macrumors 6502

    Joined:
    Sep 24, 2009
    Location:
    Michigan
    #9
    I would definitely start by looking through these config files in more detail, and also the Apache error log.
     
  10. kylos macrumors 6502a

    kylos

    Joined:
    Nov 8, 2002
    Location:
    MI
    #10
    I don't have Server, so our configurations are somewhat different, but I would check the .conf files in the sites directory as well. Those provide custom settings for each site you're serving. Also, I'm not sure if this is only in the Apache2 installation on Mac's, but check to see if you have a php5.conf file. I have this file on 10.5 under my apache2 conf directory.
     

Share This Page