Gentoo Wiki


Wikipedia has an article on:


What is PHP?

PHP is a widely-used general-purpose scripting language, originally designed for producing dynamic web pages. It is for server-side scripting, but can be used from a command line interface or in standalone graphical applications.



Before you begin, check your USE flags. Depending on what you will be doing, you can add some of the following USE flags to /etc/portage/package.use for dev-lang/php:

Look at the gentoo-portage listing for dev-lang/php5 if you want to see what other USE flags are available.

When you have set all of these up to your liking, do:

emerge --ask --verbose dev-lang/php


PHP's configuration is mainly stored in the php.ini. To find out its path, you can use

Command: Show configuration file names
# php --ini
 Configuration File (php.ini) Path: /etc/php/cli-php5
 Loaded Configuration File:         /etc/php/cli-php5/php.ini
 Scan for additional .ini files in: /etc/php/cli-php5/ext-active
 Additional .ini files parsed:      /etc/php/cli-php5/ext-active/ssh2.ini


This section deals with the following scenario: You have a Gentoo installation running on a dynamic IP and you want the /usr/sbin/sendmail command to use a SMTP-server. This can be used with, and probably any public email provider (if you have an account there), as msmtp can take care of authentication and encryption. This tutorial doesn't set your machine up as a SMTP server (port 25) that can be used by other machines. But it will let you send emails trough PHP's mail()-function or mutt. This solution - compared to setting up other email solutions - is very simple, quick (not dirty) and primitive.

What this HOWTO sets up works as follows:

  1. e.g. Apache's mod_php wants to send an email.
  2. /usr/sbin/sendmail is called by apache
  3. msmtp will send the mail to your preferred SMTP. (Taking care of authentication and/or encryption)

See Msmtp for notes on the installation of msmtp.

The .msmtprc files in your user's home directories will use /usr/sbin/sendmail. To get it working with mod_php you have to set it up in apache's home directory.

cat /etc/passwd | grep apache
apache:x:81:81:added by portage for apache:/var/www:/bin/false

shows us that /var/www is apache's home directory.

Now check that only the apache-server can read your password:

chown apache:nobody .msmtprc
chmod 600 .msmtprc

Now you have to search for your php.ini and tell it the path to your new "sendmail" command, msmtp (/usr/local/bin on my computer):

File: somewhere in php.ini
 [mail function]
 ; For Win32 only.
 ;SMTP = localhost
 ;smtp_port = 25
 ; For Win32 only.
 ;sendmail_from =
 ; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
 ; sendmail_path = "/usr/sbin/sendmail -t -i"
 sendmail_path = "/usr/bin/msmtp -t"

Any error-output by PHP's mail() command will be found /var/log/apache/error_log (even when it was triggered by SSL)

Mails send from PHP-applications like mediawiki should now be delivered as if you would have send them with your email-program.


If msmtp is complaining that it can't find the configuration files then just explicitly add the path to your php.ini file, like this.

File: somewhere in php.ini
[mail function]
;sendmail_path = "/usr/bin/msmtp -t"
sendmail_path = "/usr/bin/msmtp --file=/path/to/your/.msmtprc -t"


Currently PHP-GTK is a masked package. To unmask it, enter the following command

 echo "dev-php5/php-gtk ~x86" >> /etc/portage/package.keywords

Now you can install it using:

 emerge -av php-gtk

PHP-GTK supports the following USE parameters:

 glade     This will allow you to use Glade for designing your GUIs
 spell     Spell checking
 debug     Compile in debug mode
 doc       Include documents
 examples  Include examples
 extra     Include extra stuff
 html      GtkHTML support
 libsexy   Include libsexy
 mozembed  Use the Gecko engine in your applications
 scintilla Support for editor-like input fields with syntax highlighting

External Links


Installing PEAR (the PHP Extension and Application Repository) for use with PHP 5 is is relatively simple.

Add the USE flags PEAR requires PHP be compiled with.

File: /etc/portage/package.use
dev-lang/php cli pcre xml zlib

Re-emerge PHP, for the new USE flags to take effect

Code: emerge PHP
emerge -av dev-lang/php

With the preparation completed, all that remains is to install PEAR itself.

Code: emerge PEAR-PEAR
emerge -av dev-php/PEAR-PEAR

That's it! PEAR should now be installed, and ready for use.


External links

External Links

Retrieved from ""

Last modified: Fri, 12 Sep 2008 12:50:00 +0000 Hits: 17,311