# php5 not working

## StaraDama

i install apache, php5 and mysql 4.1 but php is not working

in this new apache with php5 i aslo no httpd.conf and i don't know where i must put

```

LoadModule php5_module modules/libphp5.so

AddType applications/x-httpd-php .php 

```

that php will start working!

I have problemms with perl to, becouse also not working! 

Please help me!Last edited by StaraDama on Tue Sep 13, 2005 5:02 pm; edited 1 time in total

----------

## keyson

Hi.

Put -D PHP5 in the line APACHE2_OPTS in /etc/conf.d/apache2 and do

a /etc/init.d/apache2 restart

My line in /etc/conf.d/apache2

 *Quote:*   

> 
> 
> APACHE2_OPTS="-D DEFAULT_VHOST -D USERDIR -D PHP4"
> 
> 

 

I use php4.

----------

## StaraDama

yes but i use php5. If i still use apach2.conf i get this error after i start apache!

```

 * Found old apache2.conf in /etc/apache2/conf. Configuration locations

 have moved, please check /etc/apache2/httpd.conf to make sure it is correct,

 and remove /etc/apache2/conf/apache2.conf.

 Please see http://www.gentoo.org/doc/en/apache-upgrading.xml

 for more information.

```

So i don't know where to put now this[/quote]

```

LoadModule php5_module modules/libphp5.so

AddType applications/x-httpd-php .php 

```

----------

## keyson

You put php5 instead of php4 as you use php5.

I switch between php4 and 5 sometimes.

The ting is defined in /etc/apache2/modules.d/70_mod_php5.conf

 *Quote:*   

> 
> 
> <IfDefine PHP5>
> 
>         # Load the module first
> ...

 

So define PHP5 in the conf and it work.

EDIT: This is in /etc/conf.d/apache2 and not in the /etc/apache2 ...... You should also check that

the config is the right on as they changed the config location. ( You get a note about it during emerge as you noticed.)

----------

## StaraDama

I create a file /etc/apache2/modules.d/70_mod_php5.conf like you said and add this in it.

```

<IfDefine PHP5>

# Load the module first

<IfModule !sapi_apache2.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> 

```

but when i start apache i get this error

```

 /etc/init.d/apache2 start

 * 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: cannot open shared object file: No such file or directory

```

I also add in  nano /etc/conf.d/apache2 this

```

APACHE2_OPTS="-D USERDIR -D PHP5 -D SSL"

```

and i get this warn

```

[Tue Sep 13 20:32:22 2005] [warn] NameVirtualHost *:80 has no VirtualHosts

```

Now is completelly mess becouse is no more apache2.conf!

----------

## keyson

Strange?

You should get the 70_mod_php5 file when you emerge dev-lang/php.

And the error tell me that you dont have the module also.

Check by doing a 

```
emerge -pv dev-lang/php
```

and se if you have the apache2 flag set. If this is not set add it to your use flag.

Move or remove the file you created and remerge the php.

----------

## StaraDama

```

dev-lang/php-5.0.4  -adabas -apache +[size=18]apache2[/size] +bcmath +berkdb -bi                                             rdstep -bzip2 +calendar -cdb -cgi -cli +crypt +ctype +curl +curlwrappers -db2 +d                                             ba +dbase -dbm -dbmaker -debug -discard-path -doc -empress -empress-bcs -esoob +                                             exif -fdftk -filepro -firebird +flatfile -force-cgi-redirect -frontbase +ftp +gd                                              -gd-external +gdbm +gmp -hardenedphp -hyperwave-api +iconv +imap -informix +ini                                             file -interbase -iodbc +ipv6 -java-external +jpeg +kerberos +ldap -libedit +mcve                                              +memlimit +mhash -ming -msql +mssql +mysql -mysqli +ncurses +nls -oci8 +odbc -o                                             racle7 -ovrimos +pcntl +pcre -pdo-external -pear -pfpro +png +posix +postgres -q                                             dbm +readline -recode -sapdb +sasl +session +sharedext -sharedmem +simplexml -sn                                             mp +soap +sockets -solid +spell +spl -sqlite +ssl -sybase -sybase-ct +sysvipc +t                                             hreads +tidy +tiff +tokenizer +truetype -wddx +xml2 +xmlrpc +xpm +xsl -yaz -zip                                              +zlib 0 kB

Total size of downloads: 0 kB

```

yes the apache2 flasg is set. what can i do now. File libphp5.so is in modules file i look there.

What can i do now?

----------

## keyson

Yep.

Sorry to say, but it is the hard way i think. I can give you the info about

my config files and directory (Btw the apache2.conf is gone. It's now httpd.conf.)

but i think the best way is to remove apache2 and the config files in /etc

Then emerge it and you have a fresh install with the right config structure. 

Then emerge php. 

To me it looks like you emerged php then emerged a new apache2 that have a

new config structure and maybe broke the module handling.

EDIT: Bed time her. Hopfully someone can take over if you are in a hurry to get it to work.

----------

## StaraDama

yes this sound the best idea to unmerge and emerge apache and php again. But here is a problem.

When i emerge dev-kang/php i get this error

```

 * Determining SAPI(s) to build

 *   Enabled  SAPI: cli

 *   Enabled  SAPI: cgi

 *   Disabled SAPI: apache

 *   Enabled  SAPI: apache2

 *

 * If this package fails with a fatal error about Apache2 not having

 * been compiled with a compatible MPM, this is normally because you

 * need to toggle the 'threads' USE flag.

 *

 * If 'threads' is off, try switching it on.

 * If 'threads' is on, try switching it off.

 *

 * The module you are trying to install (php)

 * will only work with one of the following MPMs:

 *    event leader metuxmpm perchild threadpool worker

 * You do not currently have any of these MPMs installed.

 * Please re-install apache with the correct mpm-* USE flag set.

!!! ERROR: dev-lang/php-5.0.4 failed.

!!! Function apache2_pkg_setup, Line 248, Exitcode 0

!!! No safe MPM installed.

!!! If you need support, post the topmost build error, NOT this status message.

```

mpm is used in USE flags here in amke.conf

```

USE="-gnome gtk gtk2 qt kde dvd alsa cups pam python xml xml2 acl X java mpeg cdr bcmath berkdb bzlib calendar

cpdflib crypt ctype curl curlwrappers dba dbase dbx dio exif fam flatfile ftp gd gdbm gmp iconv imap inifile jpeg kerberos l$

ncurses nls odbc pcntl pcre png posix postgres readline sasl session sharedext simplexml soap sockets spell spl ssl

sysvipc tidy tiff tokenizer truetype xml2 xmlrpc xpm xsl zlib apache2 ssl threads oav readline oggvorbis perl png spell true$

quicktime opengl artsmakesuid flac alsawrappersuid network nas mmx mmx2 mmxext samba live fbcon dvdread divx4linux

tga sse sse2 ggi rtc libcaca bigger-fonts screenshot bash-completion mozsvg cscope ncurses win32codecs xanim xvmc

cap maildir pcre commercial pcmcia server svg mng mono gd dba libgd pic server aac aalib custom-cflags berkdb innodb

readline tcpd [size=18]mpm-prefork[/size]"

```

what is wrong here that i can't emerge php

----------

## keyson

Hi.

I think i was using mpm-threadpool. Beqause it was doing some strange things.

Not at my computer now. But search the forum for mpm-threadpool.

----------

## senzacionale

here http://svn.gnqs.org/projects/gentoo-php-overlay/wiki/CommonQuestions is everything you need with error problem!

.

```

Common Compilation Errors And Their Causes

Error About Apache2 MPMs

If you get an error like this one:

!!! ERROR: dev-lang/php-5.1.0_rc1 failed.

!!! Function apache2_pkg_setup, Line 248, Exitcode 0

!!! No safe MPM installed.

!!! If you need support, post the topmost build error, NOT this status message.

it normally means that you compiled Apache2 with a threaded MPM - and forgot to compile PHP with the threads USE flag, or you compiled Apache2 with a non-threaded MPM, and forgot to switch off the threads USE flag before compiling PHP.

If you compile Apache2 with any of the following MPMs:

mpm-peruser mpm-prefork

then make sure you compile PHP without the threads USE flag:

echo "dev-lang/php -threads" >> /etc/portage/package.use

If you compile Apache2 with any of the following MPMs:

mpm-event mpm-leader metuxmpm mpm-perchild mpm-threadpool mpm-worker

then make sure you compile PHP with the threads USE flag:

echo "dev-lang/php threads" >> /etc/portage/package.use

```

----------

## StaraDama

thnx senzacionale!

keyson  now i have file 70_mod_php5.conf from the beginning and it is the same as you write here but PHP still not working!

i also add this in /etc/conf.d/apache2

```

APACHE2_OPTS="-D USERDIR -D PHP5 -D SSL"

```

but when i start apache2 i get this warnings but PHP not working. I try to run phpinfo.php but not working. I get you have choosen to open...

```

/etc/init.d/apache2 restart

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

 * Stopping apache2 ...

[Wed Sep 14 12:28:11 2005] [warn] NameVirtualHost *:80 has no VirtualHosts                                             [ ok ]

 * Starting apache2 ...

[Wed Sep 14 12:28:12 2005] [warn] NameVirtualHost *:80 has no VirtualHosts                                             [ ok ]

chdir: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

```

Why? perl also not working!  :Crying or Very sad: 

----------

## StaraDama

How to configure that will php5 and perl works or just PHP5?

Please help me with this i can't solve it myself!

----------

## keyson

About the flag. You was right, it is mpm-prefork that i hade in the use flag for apache2.

About php5. It should work as you have set the -D PHP5 in the /etc/conf.d/apache2.

If you place a file test.php in /var/www/localhost/htdocs/ and in that file enter

```
<?phpinfo()?>
```

It should return something. (Maybe that is what you mean by running phpinfo.php)

First we try php then we can start up perl.

EDIT: Found a howtohttps://forums.gentoo.org/viewtopic-t-365742.html

You can check it for reference.

----------

## StaraDama

yes like i sad i try with file phpinfo.php which has exact code in it like you write here

```

<?phpinfo()?>

```

and i also add -D PHP5 in /etc/conf.d/apache2 but not working. It said open with like it can't recognize that this is a php?

Sometimes said file doesn't exist but exist!

What i am doing wrong?

----------

## StaraDama

anyone please i need php5!

----------

## StaraDama

No one has that kind of problem yest?

----------

## sparc

I have this problem since 10 minutes ago, and I 'm going crazy.

I only did a mysql restart, nothing related to apache or php and now I have the exact same error about php5_module!!!!!

If anyone finds an answer plz post quicly... a lot of angry board members (my board, the one that is no longer active  :Shocked: ) are becoming very anxious and unpatient about this.

thnx

----------

## shelly

I'm having the exact same problem trying to configure PHP on a new machine. Any help would be appreciated.  I'm using PHP4

----------

