PHP5 modules not loading in Apache

Hi,

I installed Apache2, apache2-mod_php5 and php5. Apache doesn’t seem to be loading the php modules though. When I do httpd2 -M I get:

Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 actions_module (shared)
 alias_module (shared)
 auth_basic_module (shared)
 authn_file_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_default_module (shared)
 authz_user_module (shared)
 authn_dbm_module (shared)
 autoindex_module (shared)
 cgi_module (shared)
 dir_module (shared)
 env_module (shared)
 expires_module (shared)
 include_module (shared)
 log_config_module (shared)
 mime_module (shared)
 negotiation_module (shared)
 setenvif_module (shared)
 ssl_module (shared)
 suexec_module (shared)
 userdir_module (shared)

php is not in the list for some reason. httpd.conf and php5.conf in next post

My php5.conf is this:

<IfModule mod_php5.c>
        LoadModule php5_module modules/libphp5.so
        AddType application/x-httpd-php .php .htm .html
        AddType application/x-httpd-php-source .phps
        DirectoryIndex index.php index.htm index.html
        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>

and httpd.conf

#
# /etc/apache2/httpd.conf 
#
# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs-2.2/> for detailed information about
# the directives.

# Based upon the default apache configuration file that ships with apache,
# which is based upon the NCSA server configuration files originally by Rob
# McCool. This file was knocked together by Peter Poeml <poeml+apache@suse.de>.

# If possible, avoid changes to this file. It does mainly contain Include
# statements and global settings that can/should be overridden in the
# configuration of your virtual hosts.

# Quickstart guide:
# http://www.opensuse.org/Apache_Howto_Quickstart


# Overview of include files, chronologically:
#
# httpd.conf
#  | 
#  |-- uid.conf  . . . . . . . . . . . . . .  UserID/GroupID to run under
#  |-- server-tuning.conf  . . . . . . . . .  sizing of the server (how many processes to start, ...)
#  |-- sysconfig.d/loadmodule.conf . . . . .  [li] load these modules
[/li]#  |-- listen.conf . . . . . . . . . . . . .  IP adresses / ports to listen on
#  |-- mod_log_config.conf . . . . . . . . .  define logging formats
#  |-- sysconfig.d/global.conf . . . . . . .  [li] server-wide general settings
[/li]#  |-- mod_status.conf . . . . . . . . . . .  restrict access to mod_status (server monitoring)
#  |-- mod_info.conf . . . . . . . . . . . .  restrict access to mod_info
#  |-- mod_usertrack.conf  . . . . . . . . .  defaults for cookie-based user tracking
#  |-- mod_autoindex-defaults.conf . . . . .  defaults for displaying of server-generated directory listings
#  |-- mod_mime-defaults.conf  . . . . . . .  defaults for mod_mime configuration
#  |-- errors.conf . . . . . . . . . . . . .  customize error responses
#  |-- ssl-global.conf . . . . . . . . . . .  SSL conf that applies to default server _and all_ virtual hosts
#  |
#  |-- default-server.conf . . . . . . . . .  set up the default server that replies to non-virtual-host requests
#  |    |--mod_userdir.conf  . . . . . . . .  enable UserDir (if mod_userdir is loaded)
#  |    `--conf.d/apache2-manual?conf  . . .  add the docs ('?' = if installed)
#  |
#  |-- sysconfig.d/include.conf  . . . . . .  [li] your include files 
[/li]#  |                                             (for each file to be included here, put its name 
#  |                                              into APACHE_INCLUDE_* in /etc/sysconfig/apache2)
#  |
#  `-- vhosts.d/ . . . . . . . . . . . . . .  for each virtual host, place one file here
#       `-- *.conf . . . . . . . . . . . . .     (*.conf is automatically included)
#
#
# Files marked [li] are created from sysconfig upon server restart: instead of
[/li]# these files, you edit /etc/sysconfig/apache2



#  Filesystem layout:
#
# /etc/apache2/
#  |-- charset.conv  . . . . . . . . . . . .  for mod_auth_ldap
#  |-- conf.d/
#  |   |-- apache2-manual.conf . . . . . . .  conf that comes with apache2-doc
#  |   |-- mod_php4.conf . . . . . . . . . .  (example) conf that comes with apache2-mod_php4
#  |   `-- ... . . . . . . . . . . . . . . .  other configuration added by packages
#  |-- default-server.conf
#  |-- errors.conf
#  |-- httpd.conf  . . . . . . . . . . . . .  top level configuration file
#  |-- listen.conf
#  |-- magic
#  |-- mime.types -> ../mime.types
#  |-- mod_autoindex-defaults.conf
#  |-- mod_info.conf
#  |-- mod_log_config.conf
#  |-- mod_mime-defaults.conf
#  |-- mod_perl-startup.pl
#  |-- mod_status.conf
#  |-- mod_userdir.conf
#  |-- mod_usertrack.conf
#  |-- server-tuning.conf
#  |-- ssl-global.conf
#  |-- ssl.crl/  . . . . . . . . . . . . . .  PEM-encoded X.509 Certificate Revocation Lists (CRL)
#  |-- ssl.crt/  . . . . . . . . . . . . . .  PEM-encoded X.509 Certificates
#  |-- ssl.csr/  . . . . . . . . . . . . . .  PEM-encoded X.509 Certificate Signing Requests
#  |-- ssl.key/  . . . . . . . . . . . . . .  PEM-encoded RSA Private Keys
#  |-- ssl.prm/  . . . . . . . . . . . . . .  public DSA Parameter Files
#  |-- sysconfig.d/  . . . . . . . . . . . .  files that are created from /etc/sysconfig/apache2
#  |   |-- global.conf
#  |   |-- include.conf
#  |   `-- loadmodule.conf
#  |-- uid.conf
#  `-- vhosts.d/ . . . . . . . . . . . . . .  put your virtual host configuration (*.conf) here
#      |-- vhost-ssl.template
#      `-- vhost.template



### Global Environment ######################################################
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests.
Include /etc/apache2/conf.d/php5.conf

# run under this user/group id
Include /etc/apache2/uid.conf

# - how many server processes to start (server pool regulation)
# - usage of KeepAlive
Include /etc/apache2/server-tuning.conf

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a &lt;VirtualHost&gt;
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a &lt;VirtualHost&gt;
# container, that host's errors will be logged there and not here.
ErrorLog /var/log/apache2/error_log

# generated from APACHE_MODULES in /etc/sysconfig/apache2
Include /etc/apache2/sysconfig.d/loadmodule.conf

# IP addresses / ports to listen on
Include /etc/apache2/listen.conf

# predefined logging formats
Include /etc/apache2/mod_log_config.conf

# generated from global settings in /etc/sysconfig/apache2
Include /etc/apache2/sysconfig.d/global.conf

# optional mod_status, mod_info
Include /etc/apache2/mod_status.conf
Include /etc/apache2/mod_info.conf

# optional cookie-based user tracking
# read the documentation before using it!!
Include /etc/apache2/mod_usertrack.conf

# configuration of server-generated directory listings
Include /etc/apache2/mod_autoindex-defaults.conf

# associate MIME types with filename extensions
TypesConfig /etc/apache2/mime.types
DefaultType text/plain
Include /etc/apache2/mod_mime-defaults.conf

# set up (customizable) error responses
Include /etc/apache2/errors.conf

# global (server-wide) SSL configuration, that is not specific to 
# any virtual host
Include /etc/apache2/ssl-global.conf

# forbid access to the entire filesystem by default
&lt;Directory /&gt;
    Options None
    AllowOverride None
    Order deny,allow
    Deny from all
&lt;/Directory&gt;

# user directives

# List of resources to look for when the client requests a directory
DirectoryIndex index.html index.html.var index.php

AddType text/html php

# end user directives 

# use .htaccess files for overriding,
#AccessFileName .htaccess
# and never show them
#&lt;Files ~ "^\.ht"&gt;
#    Order allow,deny
#    Deny from all
#&lt;/Files&gt;

### 'Main' server configuration #############################################
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# &lt;VirtualHost&gt; definition.  These values also provide defaults for
# any &lt;VirtualHost&gt; containers you may define later in the file.
#
# All of these directives may appear inside &lt;VirtualHost&gt; containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#
Include /etc/apache2/default-server.conf


# Another way to include your own files
#
# The file below is generated from /etc/sysconfig/apache2,
# include arbitrary files as named in APACHE_CONF_INCLUDE_FILES and
# APACHE_CONF_INCLUDE_DIRS
Include /etc/apache2/sysconfig.d/include.conf


### Virtual server configuration ############################################
#
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# &lt;URL:http://httpd.apache.org/docs-2.2/vhosts/&gt;
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
Include /etc/apache2/vhosts.d/*.conf


# Note: instead of adding your own configuration here, consider 
#       adding it in your own file (/etc/apache2/httpd.conf.local)
#       putting its name into APACHE_CONF_INCLUDE_FILES in 
#       /etc/sysconfig/apache2 -- this will make system updates 
#       easier :) 

If I put the

 LoadModule php5_module modules/libphp5.so

into the httpd.conf I get:

rcapache2 start
Starting httpd2 (prefork) httpd2-prefork: Syntax error on line 102 of /etc/apache2/httpd.conf: Cannot load /srv/www/modules/libphp5.so into server: /srv/www/modules/libphp5.so: cannot open shared object file: No such file or directory

The command line was:
/usr/sbin/httpd2-prefork -f /etc/apache2/httpd.conf
                                                                   failed

Any help greatly appreciated…

I found the answer… one little command:

a2enmod php5

I saw a link to the only user guide in the world I hadn’t looked at when I pasted in the httpd.conf
Apache Quickstart HOWTO - openSUSE

Or edit /etc/sysconfig/apache2 and add it to the list of modules to be loaded.

Hi,

Thanks for your reply. Yes, I saw that in one of the help files and didn’t pursue it for some reason… Instead, I thought if I refreshed info.php enough it might work eventually :slight_smile: It seems to have stayed loaded now so I don’t need to do it again. If it turns out at some point that it needs to be loaded again I will put it in there.

Thanks again,
/jlar

Yes, if you keep rebooting, maybe the computer will come good. :wink:

That file is read in by Apache every time it starts up so unless you disturb it, it should load that module each time.

Similar problem. I have tried all the following:

  1. Install (or “Upgrad”) apache2-mod_php5 using yast2 successfully.

  2. Input the command “a2enmod apache2-mod_php5” and the system tells me that it’s arleady present.

  3. apache2-mod_php5 is included in /etc/sysconfig/apache2 file in APACHE_MODULES.

  4. The response to “httpd2 -M” is as the following (it seems that the module is there)


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)
authz_default_module (shared)
php5_module (shared)
Syntax OK

However, when I start or restart apache2 with “rcapache2 start/restart” command, the system always complains:

Module “apache2-mod_php5” is not installed, ignoring.
Check the APACHE_MODULES setting in /etc/sysconfig/apache2.

How do I solve the problem? Thanks in advance.

It’s just

a2enmod php5

no need for the long prefix.

/usr/sbin/httpd2 -M

just shows which modules are present, not which ones are enabled in the config file.

OK, tried “a2enmod php5” and got the message “php5 already present”. The system still shows “Module apache2-mod_php5 not installed, ignoring” when I restart with “rcapache2 restart”. Any ideas?

What happens if you try to view a PHP file anyway? Like this one:

<?php
  phpinfo();
?>

Also which MPM implementation are you using? PHP requires prefork, worker will not do. Look in /var/log/apache2/error_log to see which one is in use. Or do:

rpm -qa 'apache2*'

If apache2-worker is there but not apache2-prefork, that’s a problem.

Output of phpinfo():


Loaded modules:
core prefork http_core mod_so mod_authz_host mod_actions mod_alias mod_auth_basic mod_authz_groupfile mod_authn_file mod_authz_user mod_autoindex mod_cgi mod_dir mod_include mod_log_config mod_mime mod_negotiation mod_setenvif mod_status mod_userdir mod_asis mod_imagemap mod_authz_default mod_php5

Is the last item, “mod_php5,” indicate that apache2-mod_php5 module is corrected loaded? If so, why the following message

Module “apache2-mod_php5” is not installed, ignoring.

keeps showing up whenever I start/restart apache2?

Response of rpm -qa ‘apache2*’


apache2-devel-2.2.8-28.1
apache2-mod_php5-5.2.6-0.4
apache2-example-pages-2.2.8-28.1
apache2-prefork-2.2.8-28.1
apache2-doc-2.2.8-28.1
apache2-utils-2.2.8-28.1
apache2-mod_perl-2.0.3.99-46.1
apache2-2.2.8-28.1
apache2-mod_python-3.3.1-123.1

There is apache2-prefork, but not apache2-worker. Is this OK?
Thanks.

Yes, PHP should be working, and of course, that page you just ran is PHP.

If so, why the following message

Module “apache2-mod_php5” is not installed, ignoring.

keeps showing up whenever I start/restart apache2?

My guess is that you somehow managed to insert the long name “apache2-mod_php5” into the list of modules to load and of course there is no such long name so you get this warning. You’ll have to look inside the files generated by the apache2 init script in /etc/apache2/sysconfig.d/ to see how this extra name got in there. Or put up with this warning.

ken_yap:
Thanks a lot. The APACHE_MODULES in /etc/sysconfig/apache2 are as follows:

APACHE_MODULES=“authz_host actions alias auth_basic authz_groupfile authn_file authz_user autoindex cgi dir include log_config mime negotiation setenvif status userdir asis imagemap authz_default apache2-mod_php5 php5”

Yes, there is the item “apache2-mod_php5”!! I must have erroneously added it. So, all I have to do is just to remove it? (By the way, my php actually works fine.)

Yes, just edit out the wrong name.

Thanks a million, ken_yap.

Obviously the “apache2-mod_php5” is ‘loaded’ because a configuration file tells apache to do so. Try the following:

cd /etc/apache2/
grep -i "apache2-mod_php5" *.conf

It should tell you which configuration file contains the line that loads it. Edit the file and delete that line.

I suspect (but I do not know for sure) that you may try to do the following:

a2dismod apache2-mod_php5

I am having similar issue.

I have 2 version of Linux running in my data center. One is a test box with ORacle Linux (xampp from apachefriend) and the server have more PHP module compared to this new box (SUSE/LAMPP). The problem is the PHP script to upload a document is not working in the new SUSE box. Upon investigation I found that many of the PHP modules that are installed in xampp(oracle linux) is not installed in Suse.

Both are running PHP 5.3. Here is a comparative list of modules. XX means the module is not present in SUSE linux. Can anyone help how to install the PHP Modules that are absent in SUSE??

Thanks in advance

[HR][/HR]not present mod_autoindex

core xx
prefork xx
http_core xx
mod_so xx
mod_authn_file xx
mod_authn_dbm
mod_authn_anon
mod_authn_dbd
mod_authn_default
mod_authz_host xx
mod_authz_groupfile xx
mod_authz_user xx
mod_authz_dbm
mod_authz_owner
mod_authnz_ldap
mod_authz_default xx
mod_auth_basic xx
mod_auth_digest
mod_file_cache
mod_cache
mod_disk_cache
mod_mem_cache
mod_bucketeer
mod_dumpio
mod_echo
mod_case_filter
mod_case_filter_in
mod_ext_filter
mod_include xx
mod_filter
mod_charset_lite
mod_deflate util_ldap
mod_log_config xx
mod_logio
mod_env
mod_mime_magic
mod_cern_meta
mod_expires
mod_headers
mod_ident
mod_usertrack
mod_unique_id
mod_setenvif xx
mod_proxy
mod_proxy_connect
mod_proxy_ftp
mod_proxy_http
mod_proxy_ajp
mod_proxy_balancer
mod_mime xx
mod_dav
mod_status xx
mod_autoindex
mod_asis xx
mod_info
mod_suexec
mod_cgi xx
mod_cgid
mod_dav_fs
mod_vhost_alias
mod_negotiation xx
mod_dir xx
mod_imagemap xx
mod_actions xx
mod_speling
mod_userdir xx
mod_alias xx
mod_rewrite xx
mod_apreq2
mod_ssl xx
mod_php5 xx
mod_perl

===================

websoul67 wrote:
> I am having similar issue.
>
> I have 2 version of Linux running in my data center. One is a test box
> with ORacle Linux (xampp from apachefriend) and the server have more PHP
> module compared to this new box (SUSE/LAMPP). The problem is the PHP
> script to upload a document is not working in the new SUSE box. Upon
> investigation I found that many of the PHP modules that are installed in
> xampp(oracle linux) is not installed in Suse.
>
> Both are running PHP 5.3. Here is a comparative list of modules. XX
> means the module is not present in SUSE linux. Can anyone help how to
> install the PHP Modules that are absent in SUSE??
>
> Thanks in advance
>
> not present mod_autoindex
>
> core xx
> prefork xx
> http_core xx
> mod_so xx
> mod_authn_file xx
> mod_authn_dbm
> mod_authn_anon
> mod_authn_dbd
> mod_authn_default
> mod_authz_host xx
> mod_authz_groupfile xx
> mod_authz_user xx
> mod_authz_dbm
> mod_authz_owner
> mod_authnz_ldap
> mod_authz_default xx
> mod_auth_basic xx
> mod_auth_digest
> mod_file_cache
> mod_cache
> mod_disk_cache
> mod_mem_cache
> mod_bucketeer
> mod_dumpio
> mod_echo
> mod_case_filter
> mod_case_filter_in
> mod_ext_filter
> mod_include xx
> mod_filter
> mod_charset_lite
> mod_deflate util_ldap
> mod_log_config xx
> mod_logio
> mod_env
> mod_mime_magic
> mod_cern_meta
> mod_expires
> mod_headers
> mod_ident
> mod_usertrack
> mod_unique_id
> mod_setenvif xx
> mod_proxy
> mod_proxy_connect
> mod_proxy_ftp
> mod_proxy_http
> mod_proxy_ajp
> mod_proxy_balancer
> mod_mime xx
> mod_dav
> mod_status xx
> mod_autoindex
> mod_asis xx
> mod_info
> mod_suexec
> mod_cgi xx
> mod_cgid
> mod_dav_fs
> mod_vhost_alias
> mod_negotiation xx
> mod_dir xx
> mod_imagemap xx
> mod_actions xx
> mod_speling
> mod_userdir xx
> mod_alias xx
> mod_rewrite xx
> mod_apreq2
> mod_ssl xx
> mod_php5 xx
> mod_perl
>
> ===================
>
>

That looks like a list of Apache modules, not PHP modules. Please tell
us more about what you have installed and how, and what command you used
to produce that list. Have you read the opensuse manual? And/or googled
for install/configuration how-to?