Page 1 of 3 123 LastLast
Results 1 to 10 of 25

Thread: apache2 not processing php files

  1. #1

    Default apache2 not processing php files

    Hi,
    I'm running apache2 and I installed php5 with yast. httpd2 -M states that php5 is loaded. /etc/apache2/conf.d/php5.conf is being included in httpd.conf and it contains:

    Code:
    <IfModule mod_php5.c>
            AddHandler application/x-php .php
            AddHandler application/x-httpd-php .php4
            AddHandler application/x-httpd-php .php5
            AddHandler application/x-httpd-php .php
            AddHandler application/x-httpd-php-source .php4s
            AddHandler application/x-httpd-php-source .php5s
            AddHandler application/x-httpd-php-source .phps
            DirectoryIndex index.php4
            DirectoryIndex index.php5
            DirectoryIndex index.php
    </IfModule>
    The first line was added by me since that's what mime.types actually contains.

    php.ini is in /etc/php5/apache2 and since I was not sure apache/php was finding it I added a PHPIniDir "directive" into httpd.conf. I have not changed it.

    Test file is the typical /srv/www/htdocs/info.php with <?php infophp(); ?>

    Normal index.htm is working fine. php -a is working fine.

    I spent a long afternoon around this configuration and I looked in plenty of pages for solutions. I only do occasional system administration so I might have easily overlooked something trivial, but I run out of ideas.

    There is a thread in this web site with a similar problem but no solution:

    Php5 not recognized in SUSE 10.2 Apache2

    What could be missing/wrong if php5 is loaded and the addhandler is defined? How can I further test?

    TIA
    Fernando

  2. #2
    Join Date
    Aug 2008
    Location
    Behind the 8 ball
    Posts
    116

    Default Re: apache2 not processing php files

    What's the output of your info.php page?

    I've never seen a function called infophp(), is it supposed to be phpinfo();?

    Hiatt

  3. #3
    Join Date
    Mar 2009
    Location
    sri mayapur, west bengal, india
    Posts
    958

    Default Re: apache2 not processing php files

    On Sat, 07 May 2011 02:36:02 +0530, jthiatt08
    <jthiatt08@no-mx.forums.opensuse.org> wrote:

    >
    > What's the output of your info.php page?
    >
    > I've never seen a function called infophp(), is it supposed to be
    > phpinfo();?



    if his server doesn't process php files, he won't see output from an
    info.php page.

    apart from php5.conf being included in httpd.conf, php has to be set in
    /etc/sysconfig/apache2. not sure if it's supposed to happen automatically,
    but i remember setting it manually a few times.

    there's a lot of stuff in that file, mostly comments. there's one
    uncommented parameter for APACHE_MODULES, which has to include php5.


    --
    phani.

  4. #4
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: apache2 not processing php files

    Quote Originally Posted by jthiatt08 View Post
    What's the output of your info.php page?

    I've never seen a function called infophp(), is it supposed to be phpinfo();?

    Hiatt
    Yeah, what's the output of that page? A blank page, a 500 error, or what? It should be a 500 error, since the function is called phpinfo().

    Also if you look in /var/log/apache2/error_log you will see more clues.

    If httpd -M says the module is loaded, then he has included php5 in APACHE_MODULES.

  5. #5
    Join Date
    Mar 2009
    Location
    sri mayapur, west bengal, india
    Posts
    958

    Default Re: apache2 not processing php files

    On Sat, 07 May 2011 05:06:05 +0530, ken yap
    <ken_yap@no-mx.forums.opensuse.org> wrote:

    > If httpd -M says the module is loaded, then he has included php5 in
    > APACHE_MODULES.



    that only says that it's included for the CLI configuration. i don't know
    exactly how this enabling via /etc/sysconfig/apache2 works, if that
    influences CLI & apache interfaces equally. i'd definitely look if it's
    enabled or not in that file; i've had apache not working because of that
    several times. never tried phpinfo() via CLI at those times though.

    --
    phani.

  6. #6
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: apache2 not processing php files

    Then perhaps you should explore how the configuration works before you comment. I'll give you an outline: the SysV init script uses the values in /etc/sysconfig/apache2 to write a config file in /etc/apache2 which directs apache2 to load the required modules.

    httpd2 -M reports on that the config that exists in /etc/apache2. So it will see the same thing, provided /etc/init.d/apache2 has been run once.

  7. #7
    Join Date
    Mar 2009
    Location
    sri mayapur, west bengal, india
    Posts
    958

    Default Re: apache2 not processing php files

    On Sat, 07 May 2011 06:06:05 +0530, ken yap
    <ken_yap@no-mx.forums.opensuse.org> wrote:

    >
    > Then perhaps you should explore how the configuration works before you
    > comment. I'll give you an outline: the SysV init script uses the values
    > in /etc/sysconfig/apache2 to write a config file in /etc/apache2 which
    > directs apache2 to load the required modules.
    >
    > httpd2 -M reports on that the config that exists in /etc/apache2. So it
    > will see the same thing, provided /etc/init.d/apache2 has been run once.
    >


    thank you; but i don't see any harm in my comment. i wrote i didn't know
    exactly, and am glad to get it explained. what i suggested wouldn't have
    led to other mistakes, perhaps to a wasted 1.5 min. didn't know you could
    only comment when you were completely sure how something works.


    --
    phani.

  8. #8
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: apache2 not processing php files

    It saves 1.5 minutes of your time.

  9. #9

    Default Re: apache2 not processing php files

    Hi

    Thanks for the replies.

    I have indeed added php5 to /etc/sysconfig/apache2. The function is phpinfo(). I was typing from the top of my head. The issue is that the browser just asks to save/open the file (which then comes with the source).

    I don't see errors in /var/log/apache2/error_log and loglevel is info. I tried debug, no change. Something else, I tried telnet with HEAD / HTTP/1.0 and I got:

    Code:
    HTTP/1.1 403 Forbidden
    Date: Fri, 06 May 2011 16:04:04 GMT
    Server: Apache/2.2.10 (Linux/SUSE)
    Vary: accept-language,accept-charset
    Accept-Ranges: bytes
    Connection: close
    Content-Type: text/html; charset=iso-8859-1
    Content-Language: en
    Expires: Fri, 06 May 2011 16:04:04 GMT
    I notice that Server: does not report PHP5. Maybe this depends on how apache was originally compiled??

    Also, it is missing the header X-Powered-By:, which I believe should point to PHP5 (based on Apache 2 and PHP 5 (mod_php) on Linux)

  10. #10
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,683
    Blog Entries
    4

    Default Re: apache2 not processing php files

    Apache will not report PHP because it's a dynamically loaded module that may or may not be loaded at runtime.

    What exactly do you mean when you say you installed php5. For PHP to work in Apache, you must have both of these packages:

    php5
    apache2-mod_php5

    Just one is not sufficient.

    Also do you have any existing .htaccess in that directory that may interfere? Any other .conf files from other webapps in /etc/apache2 that may interfere? And take out that PHPIniDir directive you put in. It's not needed and may in fact cause a problem.

    You could have installed all the prerequisites by installing the pattern lamp_server, although you get mysql thrown in which you may or may not need later.

Page 1 of 3 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •