PHP and Apache

I have set up an apache web server and am trying to get php to work. however, when i go to the url of the php document in my browser it just comes up asking me where i want to download the file to. please help :smiley: thanx

Naturally the first thing to ask is - have you installed php5 and php apache module, mainly the apache2-mod_php5 package.

And the next thing to ask is if you have added php5 to the list in APACHE_MODULES in /etc/sysconfig/apache2.

I assume that the Apache and PHP packages are from OpenSUSE. Things get more complex if you try to install your own from upstream packages.

what does

rpm -qa | grep apache && rpm -qa | grep php

give back?

yes they’re both installed :S and rpm -qa | grep apache && rpm -qa | grep php returns…

apache2-mod_perl-2.0.3-54
apache2-example-pages-2.2.4-70.4
ant-apache-bsf-1.7.0-37
apache2-2.2.4-70.4
apache2-mod_php5-5.2.5-8.1
ant-apache-log4j-1.7.0-37
apache2-mod_mono-1.2.5-22
apache2-devel-2.2.4-70.4
ant-apache-regexp-1.7.0-37
ant-apache-bcel-1.7.0-37
apache2-prefork-2.2.4-70.4
apache2-doc-2.2.4-70.4
ant-apache-resolver-1.7.0-37
ant-apache-oro-1.7.0-37
apache2-utils-2.2.4-70.4
apache2-mod_python-3.3.1-53
php5-pdo-5.2.5-8.1
php5-hash-5.2.5-8.1
php5-xmlreader-5.2.5-8.1
php5-dom-5.2.5-8.1
apache2-mod_php5-5.2.5-8.1
php5-tokenizer-5.2.5-8.1
php5-iconv-5.2.5-8.1
php5-sqlite-5.2.5-8.1
php5-ctype-5.2.5-8.1
php5-xmlwriter-5.2.5-8.1
php5-json-5.2.5-8.1
php5-mysql-5.2.5-8.1
php5-5.2.5-8.1

What does

/usr/sbin/httpd2 -M | grep php5

output?

/usr/sbin/httpd2 -M | grep php5 gives:

[Sat Jun 14 17:15:37 2008] [crit] Failed to remove dashboard file ā€˜/tmp/mod_mono_dashboard_XXGLOBAL_1’, further actions impossible. Operation not permitted
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)
perl_module (shared)
python_module (shared)
authz_default_module (shared)
mono_module (shared)
Syntax OK

php5 module isn’t being loaded.

Edit /etc/sysconfig/apache2, find a line called APACHE_MODULES=ā€œblah blahā€ and add php5 to the end of it, inside the quotes - make sure you don’t edit the line with # in front of it.

After that issue rcapache2 restart


$ a2enmod php5
$ rcapache2 restart

I’ve tried everything that has been suggested so far and it still isn’t working :frowning: has anyone got any other suggestions please? :slight_smile:

What kind of php app or page are you trying to get to?

Can you do:

grep ā€˜<?’ phpfile.php

Why? Because by default suse has short tags turned off. If you are trying to do a phpinfo or something that is:

<?
phpinfo();
?>

It will not work. Although then I think you just get a blank page.

Does

/usr/sbin/httpd2 -M 2>&1 | grep php5

return anything now?

I’m having the same problems

/usr/sbin/httpd2 -M 2>&1 | grep php5

returns nothing

I’ve checked php5 is in the list of modules in /etc/sysconfig/apache2 and restarted apache2

The php module is not showing up in /etc/apache2/sysconfig.d/loadmodule.conf at this point should it? It tells me not to edit that file but to edit the /etc/sysconfig/apache2

my index.php file consists of

<?php
phpinfo();
?>

I’ve even tried adding AddType application/x-httpd-php .php into the virtual host (I couldn’t work out where those were specified - I’m used to RedHat systems with everything in the httpd.conf file), but when I go to the server root it just asks me were I want to save index.php

sebcrump wrote:
> I’m having the same problems
>
>> /usr/sbin/httpd2 -M 2>&1 | grep php5
>
> returns nothing
>
> I’ve checked php5 is in the list of modules in /etc/sysconfig/apache2
> and restarted apache2

Ah - try rcapache2 restart

It re-reads the sysconfig stuff - a normal restart does not

BTDTGTTS

–
Clive

I tried restarting it every way I knew including that one from a post above.

OK - UPDATE -

I have now downgraded PHP to 5.1.2 by re-installing from the original novell online repository and it all works!

I think the problem may have related to the rpm of php5.2.6 (origin unknown) run by my colleague setting up the server

However, I’m not particularly happy running this old version that I think has a few security problems with it. So how do I upgrade it to 5.2.6? or should I start a new thread for that :slight_smile:

Index of /repositories/server:/php/openSUSE_10.3

Contains 5.2.6 - with the assumption that you’re running 10.3.

Yeah that would mess things up. Non-SUSE packages would not benefit from the sysconfig settings in /etc/sysconfig/apache2; you would have to edit the Apache config files yourself. You don’t really want to go there, installing non-SUSE packages. You should be able to get the latest version from an OpenSUSE repository.

Sometimes Novell back patches the source but doesn’t bump the minor version number so as not to break package dependencies. But the bug is nevertheless fixed.