# Problems with php5 and apache

## djus

Hi all

I've problems with starting apache when mod_php is enabled. 

I get the following error:

* Apache2 has detected a syntax error in your configuration files:

Syntax error on line 5 of /etc/apache2/modules.d/70_mod_php5.conf:

Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: undefined symbol: php_ini_scanned_files

Here my configuration:

ls -al /etc/apache2/modules.d/

total 28

drwxr-xr-x 2 root root  320 Nov  2 15:34 .

drwxr-xr-x 5 root root  224 Oct 11 22:19 ..

-rw-r--r-- 1 root root    0 Oct  4 21:33 .keep

-rw-r--r-- 1 root root    0 Oct 11 22:14 .keep_net-www_apache-2

-rw-r--r-- 1 root root 2980 Oct 11 22:14 40_mod_ssl.conf

-rw-r--r-- 1 root root 8151 Oct 11 22:14 41_mod_ssl.default-vhost.conf

-rw-r--r-- 1 root root  583 Oct 11 22:14 45_mod_dav.conf

-rw-r--r-- 1 root root  892 Oct 11 22:14 46_mod_ldap.conf

-rw-r--r-- 1 root root  494 Nov  2 16:00 70_mod_php5.conf

cat /etc/apache2/modules.d/70_mod_php5.conf

<IfDefine PHP5>

        # Load the module first

        <IfModule !mod_php5.c>

                LoadModule php5_module    modules/libphp5.so

        </IfModule>

        # Set it to handle the files

        <IfModule mod_mime.c>

                AddType application/x-httpd-php .php

                AddType application/x-httpd-php .phtml

                AddType application/x-httpd-php .php3

                AddType application/x-httpd-php .php4

                AddType application/x-httpd-php .php5

                AddType application/x-httpd-php-source .phps

        </IfModule>

        AddDirectoryIndex index.php index.phtml

</IfDefine>

cat /etc/conf.d/apache2

...

APACHE2_OPTS="-D DEFAULT_VHOST -D SSL -D PHP5"

...

emerge apache -vp

[ebuild   R   ] net-www/apache-2.0.58-r2  USE="apache2 ldap ssl -debug -doc -mpm-itk -mpm-leader -mpm-peruser -mpm-prefork -mpm-threadpool -mpm-worker (-selinux) -static-modules -threads" 4,651 kB

emerge php -vp

[ebuild   R   ] dev-lang/php-5.1.6-r6  USE="apache2 bzip2 cli crypt curl ftp gd gdbm hash iconv imap ipv6 ldap mysql mysqli ncurses pcre readline sasl session spl ssl truetype unicode xml zip zlib -adabas -apache -bcmath -berkdb -birdstep -calendar -cdb -cgi -cjk -concurrentmodphp -ctype -curlwrappers -db2 -dbase -dbmaker -debug -discard-path -doc -empress -empress-bcs -esoob -exif -fastbuild -fdftk -filepro -firebird -flatfile -force-cgi-redirect -frontbase -gd-external -gmp -hardenedphp -hyperwave-api -informix -inifile -interbase -iodbc -java-external -kerberos -libedit -mcve -memlimit -mhash -ming -msql -mssql -nls -oci8 -oci8-instant-client -odbc -pcntl -pdo -pdo-external -pic -posix -postgres -qdbm -recode -reflection -sapdb -sharedext -sharedmem -simplexml -snmp -soap -sockets -solid -spell -sqlite -sybase -sybase-ct -sysvipc -threads -tidy -tokenizer -vm-goto -vm-switch -wddx -xmlreader -xmlrpc -xmlwriter -xpm -xsl -yaz"

Who can help me?

----------

## xoomix

Look at my file:

<IfDefine PHP5>

        # Load the module first

        <IfModule !mod_php5.c>

                LoadModule php5_module    modules/libphp5.so

        </IfModule>

        # Set it to handle the files

        <IfModule mod_mime.c>

                AddType application/x-httpd-php .php

                AddType application/x-httpd-php .phtml

                AddType application/x-httpd-php .php3

                AddType application/x-httpd-php .php4

                AddType application/x-httpd-php .php5

                AddType application/x-httpd-php-source .phps

        </IfModule>

        AddDirectoryIndex index.php index.phtml

</IfDefine>

Notice how the line # 5 (where yours says you have a syntax error) is indented? Try doing that and post your results.

~Cheers!

----------

## xoomix

Ok when I cut and pasted mine line 5 lost indentation as well - maybe that's what yours did? Is yours indented on the system?

----------

## djus

Yes, the indented is on the system. It looks like a copy/paste problem

----------

## keyson

Hi.

The indent is only to make it more easy to read for human's.

The problem is that php5 need on mpm in apache. as you use non threaded php you should

add 'mpm-prefork' to the apache use flag.

From another thread

 *Quote:*   

> 
> 
> For PHP5 Apache should have ONE MPM, I suggest you use prefork because it is the most stable mod for Apache with PHP.
> 
> If you do not find a package you need either edit /etc/portage/package.use or use the USE="..." emerge ... flag 
> ...

 

https://forums.gentoo.org/viewtopic-t-365742.html

----------

## djus

I have recompiled the apache whith the mpm-prefork flag

[ebuild   R   ] net-www/apache-2.0.58-r2  USE="apache2 ldap mpm-prefork ssl -debug -doc -mpm-itk -mpm-leader -mpm-peruser -mpm-threadpool -mpm-worker (-selinux) -static-modules -threads" 

The error is still the same ...

----------

## keyson

Think you have to rebuild php, as it check what mpm you have enabled.

The error you get is that it cant load the module into apache. This come from

that the module is not build right.

----------

## xoomix

Rebuilding php sounds like a great idea - still interesting that is says "Syntax error on line 5 of /etc/apache2/modules.d/70_mod_php5.conf:"

Syntax error ... but where?

----------

## keyson

The syntax error come from that it can't load the module.

If i rename the module i get.

 *Quote:*   

> 
> 
>  * Apache2 has detected a syntax error in your configuration files:
> 
> Syntax error on line 5 of /etc/apache2/modules.d/70_mod_php5.conf:
> ...

 

Now it can't find the module the error you have is that you have a  'undefined symbol: php_ini_scanned_files'.

This indicate that something is not compiled right. So try the mpm-prefork and rebuild php.

----------

## xoomix

The error specifically states a syntax error in the configuration file, and says what line the error occurs on. I do not argue that rebuilding/recompiling will fix it (since we have yet to know if he/she has tried it or not) - but a syntax error is a syntax error  :Smile: 

----------

## djus

OK, I've recompiled the apache and php with mpm-prefork enabled, but I have the same problem, the same error message   :Sad: 

----------

## keyson

OK.

You have to check the ini directory.

This error indicate thet the parsing of additional ini files is going wrong.

The php.ini should be in

/etc/php/apache2-php5/

and aditional ini files in

/etc/php/apache2-php5/ext-active/

Ther is some parse error of the ini. Check that you don't have anything

strange laying around in this directory.

Ref:

http://www.php.net/manual/en/function.php-ini-scanned-files.php

----------

## xoomix

I got the exact same error dinking around with stuff -- by chance have you re-built or upgraded something like mysql ?

Run a revdep-rebuild -av and tell us what is says (if you have any module dependency issues).

----------

