echo "dev-lang/php apache2">>/etc/portage/package.use
2.安装php
emerge php
3.配置php
查看/etc/apache2/modules.d/70_mod_php5.conf,内容如下
<IfDefine PHP5>
# Load the module first
<IfModule !mod_php5.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
# Set it to handle the files
<FilesMatch "\.ph(p5?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
DirectoryIndex index.php index.phtml
</IfDefine>
# Load the module first
<IfModule !mod_php5.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
# Set it to handle the files
<FilesMatch "\.ph(p5?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
DirectoryIndex index.php index.phtml
</IfDefine>
从上可以知道需要打开PHP5启动项
因此编辑文件/etc/conf.d/apache2
添加 '-D PHP5' 到APACHE2_OPTS
APACHE2_OPTS="-D DEFAULT_VHOST -D INFO -D LANGUAGE -D SSL -D SSL_DEFAULT_VHOST -D PHP5"
4.测试php是否安装成功创建php文件test.php到/var/www/localhost/htdocs/
<?php
echo phpinfo();
?>
echo phpinfo();
?>
启动apache服务
/etc/init.d/apache2 start
下面用浏览器访问http://localhost/test.php来测试php是否安装成功,可以看到当前php的信息,于是大功告成