How to configure PHP under Apache web server in GENTOO Operating System?
Question
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.
Solution
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"
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
OTHER TIPS
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:
bash$ emerge apache
- 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.
- NOTE: this is the important one to get Apache and PHP working together:
- Then just run
bash$ emerge dev-lang/php
and restart Apache with the /etc/init.d/apache2 script. PHP should now be available.
above link dead, try this one:
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>
Try to use official GENTOO documentation:
http://www.gentoo.org/proj/en/php/php4-php5-configuration.xml