views:

2516

answers:

6

Hi,

is there anyone who knows how to install / configure php under apache?

I have emerge php apache both. I wanted to use mod_php for apache in GENTOO OS.

php temp.php

command line runs fine, but http://localhost/temp.php is not executing on web server instead it shows the content of the php code.

A: 

Hi,

You may find some informations in Apache 2.0 on Unix systems

Especially, the

LoadModule php5_module modules/libphp5.so

and

SetHandler application/x-httpd-php

Lines should help :-)

The corresponding lines I have in my Apache's configuration (Apache 2, PHP 5.2, Ubuntu) are :

LoadModule php5_module /usr/lib/apache2/modules/libphp-5.2.9.so
<IfModule mod_php5.c>
  AddType application/x-httpd-php .php .phtml
  AddType application/x-httpd-php-source .phps
</IfModule>
Pascal MARTIN
A: 

After emerging apache and php edit /etc/conf.d/apache2 and set

APACHE2_OPTS="-D PHP5"

There's a tool to switch/enable the options, but I have forgotten its name :(

VolkerK
A: 

Try to use official GENTOO documentation:

http://www.gentoo.org/proj/en/php/php4-php5-configuration.xml

Sergey Olontsev
that I have tried but it doesn't helped me much.
Tumbleweed
that is only for running two php versions concurrently
Mala
+2  A: 

I found a blog and I followed his instruction and it works ! I'm sharing the solution Referenced Blog

I put these lines in /etc/make.conf:

USE="apache2 mysql php pam ssl xml xml2 berkdb innodb jpeg png"

If you want to install also phpmyadmin, then you should also add pcre session unicode:

USE="apache2 mysql php pam ssl xml xml2 berkdb innodb jpeg png pcre session unicode"

If you want to install also phpmyadmin, then you should also add pcre session unicode:

USE="apache2 mysql php pam ssl xml xml2 berkdb innodb jpeg png pcre session unicode"

I then changed the file /etc/init.d/apache2, in order to enable public_html folders for users (corresponding to the ~ directory), setting -D USERDIR:

APACHE2_OPTS="-D DEFAULT_VHOST -D PHP5 -D USERDIR

Before starting mysql, you must create (once and for all) the mysql main database, and this can be done simply by running:

/usr/bin/mysql_install_db
Tumbleweed
+1  A: 

There appear to be a number of ways to achieve this but many seem a bit out of date or overly complicated. As of Feb 1 2010 all I did to get PHP and Apache2 working on Gentoo was to install Apache and PHP like this:

  1. bash$ emerge apache
  2. Followed the instructions for the particular extensions I wanted at this list at the Gentoo site
    • NOTE: this is the important one to get Apache and PHP working together:
      • bash$ echo "dev-lang/php apache2" >> /etc/portage/package.use
    • Another common PHP extension:
      • bash$ echo "dev-lang/php mysql" >> /etc/portage/package.use
    • And so on.
  3. Then just run bash$ emerge dev-lang/php and restart Apache with the /etc/init.d/apache2 script. PHP should now be available.
Matt Larson
+1  A: 

above link dead, try this one:

http://overlays.gentoo.org/proj/php/

jms