PHP with Apache

hi to all,
I install LAMP from Repo. But when i tried to run php files, it just give me save or open dialog box, mean not parsing php files. I check all conf files, all are OK. restart apache. did not work.
Then i tried to reinstall the things. but same thing.Again i tried to install it and again same thing.
Its really annoying. B4 everything was OK.but suddenly it start this behavior.
Any ideas?
Thanks
Arif

Did you enable the php5 module in the Apache config? If you look in the file /etc/sysconfig/apache2 and the setting APACHE_MODULES doesn’t have php5 in the list, you have not enabled PHP.

Hello,
I have a similar PHP problem.
I have installed openSuSE 11.0 with LAMP. I changed the web directory and enabled PHP in the HTTP server configuration in Yast and changed

<Directory />
    Options None
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>

to

<Directory />
    Options None
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>

in the httpd.conf - to get access the filesystem.

The http pages work all-right, but when I try to view a php generated page, I get an error:

An error occurred when loading http://localhost/a.php:

inner server error
localhost

It’s not a script error, “a.php” is a very simple script:

<?php echo "working?"; ?>

and no other script work either.

The PHP module should be properly installed and working:

tadeas:~ # httpd2 -M
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 authz_host_module (shared)
 actions_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authz_groupfile_module (shared)
 authn_file_module (shared)
 authz_user_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 dir_module (shared)
 include_module (shared)
 log_config_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 setenvif_module (shared)
 status_module (shared)
 userdir_module (shared)
 asis_module (shared)
 imagemap_module (shared)
 php5_module (shared)
 authz_default_module (shared)
Syntax OK

and there is “php5” in APACHE_MODULES in /etc/sysconfig/apache2.

In mime.types, there is the line

application/x-php php php3 php4 php5

so it should recognize a php script.

What could be wrong? If only the Apache wrote WHAT server error occurred, it would be much easier. On openSuSE 10.3 there wasn’t any problem like this, everything worked. I didn’t upgrade the system from 10.3 to 11.0, I made a new installation, so there shouldn’t be any version-related problems.

Mate,i would prefer fresh installation.
however the stuffs you mentioned in your above post, i did apply all of that. But with no luck.
For you: did you restarted your PC after doing modification, OR your server.

About the problem i face that time: i did a fresh install again and install everything from repos. Then start the server, and it worked.
So now not sure what was the problem.
But i think in my case there was some mixup file problems.

Thanks for your reply.
Maybe I didn’t express myself correctly. I mean I did a fresh installation on a formated disc and installed everything from repos.
Of course I tried restarting Apache and PC after any change, but it didn’t help.

However I have a new idea about where the problem could be, I’ll take a look on my keyboard settings and coding. A friend of mine used to have similar problems (C++ application not working due to not known reason) and found out that the problem was in quotes - in my mothertongue we use the first quotes at the bottom of the line. That was what the compiler didn’t understand…

Apache writes errors into /var/log/apache2/error_log You should look there first.

Hi,

The simillar problem is here. I had a fresh LAMP installation on openSuse 11.1. I have chosen LAMP pattern from yast2 software management. I enabled the php5 module after installation. I checked the module is loaded with the command “apache2ctl -M”.

My index.html file opens nicely. But I have problem in opening the .php file in the same folder.

I checked the error logs :
error_log

[Sun Aug 23 01:29:05 2009] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Aug 23 01:29:05 2009] [notice] Apache/2.2.10 (Linux/SUSE) mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.6 with Suhosin-Patch configured – resumingnormal operations
[Sun Aug 23 01:57:07 2009] [notice] caught SIGTERM, shutting down
[Sun Aug 23 01:57:07 2009] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Aug 23 01:57:08 2009] [notice] Apache/2.2.10 (Linux/SUSE) mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.6 with Suhosin-Patch configured – resumingnormal operations
[Sun Aug 23 02:21:01 2009] [notice] caught SIGTERM, shutting down
[Sun Aug 23 02:21:02 2009] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Aug 23 02:21:02 2009] [notice] Apache/2.2.10 (Linux/SUSE) mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.6 with Suhosin-Patch configured – resumingnormal operations
[Sun Aug 23 02:37:31 2009] [notice] caught SIGTERM, shutting down
[Sun Aug 23 02:37:32 2009] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Aug 23 02:37:32 2009] [notice] Apache/2.2.10 (Linux/SUSE) mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.6 with Suhosin-Patch configured – resumingnormal operations
[Sun Aug 23 03:55:54 2009] [notice] caught SIGTERM, shutting down
[Sun Aug 23 03:55:58 2009] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Aug 23 03:55:58 2009] [notice] Apache/2.2.10 (Linux/SUSE) mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.6 with Suhosin-Patch configured – resumingnormal operations
[Sun Aug 23 04:04:48 2009] [notice] caught SIGTERM, shutting down
[Sun Aug 23 04:04:48 2009] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sun Aug 23 04:04:49 2009] [notice] Apache/2.2.10 (Linux/SUSE) mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.6 with Suhosin-Patch configured – resumingnormal operations
~
~
access_log

::1 - - [23/Aug/2009:04:05:21 +0530] “GET / HTTP/1.1” 200 44 “-” “Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008103100 SUSE/3.0.4-4.6 Firefox/3.0.4”
::1 - - [23/Aug/2009:04:05:21 +0530] “GET /favicon.ico HTTP/1.1” 200 302 “-” “Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008103100 SUSE/3.0.4-4.6 Firefox/3.0.4”

rcapache2.out

Syntax OK

Thats all. I m stuck very badly. Can anybody give me any break through?

There’s no evidence in access_log that you accessed your PHP script or even index.html through the web browser.

When you say you “opened” index.html and your PHP script, what did you mean? Did you use something like dolphin, which is a file browser? You have to access PHP scripts through the web server with something like:

http://localhost/~myself/test.php

to see the results it produces. In a file browser you just see the source code.

In this case the file test.php should be placed in ~/public_html/test.php.

surjya wrote:

>
> Hi,
>
> The simillar problem is here. I had a fresh LAMP installation on
> openSuse 11.1. I have chosen LAMP pattern from yast2 software
> management. I enabled the php5 module after installation. I checked the
> module is loaded with the command “apache2ctl -M”.
>
> My index.html file opens nicely. But I have problem in opening the .php
> file in the same folder.
>
> I checked the error logs :
> error_log
> ----------
> [Sun Aug 23 01:29:05 2009] [warn] Init: Session Cache is not configured
> [hint: SSLSessionCache]
> [Sun Aug 23 01:29:05 2009] [notice] Apache/2.2.10 (Linux/SUSE)
> mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.6 with Suhosin-Patch configured –
> resumingnormal operations
> [Sun Aug 23 01:57:07 2009] [notice] caught SIGTERM, shutting down
> [Sun Aug 23 01:57:07 2009] [warn] Init: Session Cache is not configured
> [hint: SSLSessionCache]
> [Sun Aug 23 01:57:08 2009] [notice] Apache/2.2.10 (Linux/SUSE)
> mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.6 with Suhosin-Patch configured –
> resumingnormal operations
> [Sun Aug 23 02:21:01 2009] [notice] caught SIGTERM, shutting down
> [Sun Aug 23 02:21:02 2009] [warn] Init: Session Cache is not configured
> [hint: SSLSessionCache]
> [Sun Aug 23 02:21:02 2009] [notice] Apache/2.2.10 (Linux/SUSE)
> mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.6 with Suhosin-Patch configured –
> resumingnormal operations
> [Sun Aug 23 02:37:31 2009] [notice] caught SIGTERM, shutting down
> [Sun Aug 23 02:37:32 2009] [warn] Init: Session Cache is not configured
> [hint: SSLSessionCache]
> [Sun Aug 23 02:37:32 2009] [notice] Apache/2.2.10 (Linux/SUSE)
> mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.6 with Suhosin-Patch configured –
> resumingnormal operations
> [Sun Aug 23 03:55:54 2009] [notice] caught SIGTERM, shutting down
> [Sun Aug 23 03:55:58 2009] [warn] Init: Session Cache is not configured
> [hint: SSLSessionCache]
> [Sun Aug 23 03:55:58 2009] [notice] Apache/2.2.10 (Linux/SUSE)
> mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.6 with Suhosin-Patch configured –
> resumingnormal operations
> [Sun Aug 23 04:04:48 2009] [notice] caught SIGTERM, shutting down
> [Sun Aug 23 04:04:48 2009] [warn] Init: Session Cache is not configured
> [hint: SSLSessionCache]
> [Sun Aug 23 04:04:49 2009] [notice] Apache/2.2.10 (Linux/SUSE)
> mod_ssl/2.2.10 OpenSSL/0.9.8h PHP/5.2.6 with Suhosin-Patch configured –
> resumingnormal operations
> ~
> ~
> access_log
> ----------
> ::1 - - [23/Aug/2009:04:05:21 +0530] “GET / HTTP/1.1” 200 44 “-”
> “Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4) Gecko/2008103100
> SUSE/3.0.4-4.6 Firefox/3.0.4”
> ::1 - - [23/Aug/2009:04:05:21 +0530] “GET /favicon.ico HTTP/1.1” 200
> 302 “-” “Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.4)
> Gecko/2008103100 SUSE/3.0.4-4.6 Firefox/3.0.4”
>
> rcapache2.out
> -------------
> Syntax OK
>
> Thats all. I m stuck very badly. Can anybody give me any break through?
>
>
I once got caught trying to view a php script that I’d put in a file called
test.html then wondering why the heck I wasn’t seeing the result I was
expecting. Turned out that php was set to only interpret files with
the .php extension so my test.html wasn’t getting run through the
interpreter at all. :slight_smile:


kev.

I used to have the same problem. Fresh installation as described here, but apache couldn’t find php.

So, the problem was resolved by adding the line into default-server.conf:

Include /etc/apache2/conf.d/php5.conf

and to restart apache.

The correct way to do it in openSUSE is to edit /etc/sysconfig/apache2 and add php5 to APACHE_MODULES. Or

a2enmod php5

which does the same thing.

I have done everything mentioned above. I am running virtual servers with Virtualmin. I can see some php pages but it doesn’t even run the script below:

<?
echo “test”;
phpinfo();
?>

My pages are on /srv/www/domainname.com/public_html/ instead of /srv/www/htdocs/ Does it work like this? And also somebody told me that the scripts won’t be parsed by default, I need to enable the parser but I don’t know how? How can I make sure that php is working correctly? Log files doesn’t say anything, everything seems normal.

Thanks.

Don’t use short tags, they are deprecated. Try this:

<?php
echo "test";
phpinfo();
?>

thanks, it worked :slight_smile: