How to configure PHP under Apache web server in GENTOO Operating System?

25,033

Solution 1

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

Solution 2

above link dead, try this one:

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

Solution 3

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>
Share:
25,033
shahjapan
Author by

shahjapan

Passion: Computer Science, Programming, R &amp; D, Troubleshooting Programming: Python, C#, Shell scripting Frontend Technologies: Bootstrap, Javascript, JQuery, SCSS Cloud Technologies: GCP, AWS Virtualisation: Docker, Docker-Compose, k8s RDBMS: MySQL, PostgreSQL, SQLite Operating Systems: Linux, Windows, OSX Testing: Unit Tests, pytest, Jenkins, selenium Hobbies: Playing Chess, Swimming &amp; roaming -- Japan Shah

Updated on June 03, 2020

Comments

  • shahjapan
    shahjapan about 4 years

    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.

  • Mala
    Mala over 14 years
    that is only for running two php versions concurrently
  • Misguided
    Misguided over 12 years
    -1: putting single-package USE flags in /etc/make.conf is strongly discouraged, as they will be applied to the whole system (which might cause problems with dependencies and such).
  • Rene Saarsoo
    Rene Saarsoo about 12 years
    I think you meant changing /etc/conf.d/apache2 not /etc/init.d/apache2.
  • TamusJRoyce
    TamusJRoyce about 12 years
    echo "dev-lang/php apache2 my sql php pam ssl [...]" >> /etc/portage/package.use is an example how to specify per-package use flags. apache, php, and mysql will need added with specific use flags if you decide not to have them as global flags. After emerging gentoolkit, equery uses dev-lang/php will give you a description of available use flags for this package. I also find equery files [package] use-full.
  • nacitar sevaht
    nacitar sevaht over 11 years
    This answer is correct, but more than most people will probably need. The real key here is adding "-D PHP5" to APACHE2_OPTS in /etc/conf.d/apache2 then restarting via /etc/init.d/apache2 restart
  • shahjapan
    shahjapan about 11 years
    @JulianBayardoSpadafora Hey if you've rights to update the answer - kindly make those changes.