如何在 GENTOO 操作系统的 Apache web 服务器下配置 PHP?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1218651/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 01:35:26  来源:igfitidea点击:

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

phpapachegentoomod-php

提问by shahjapan

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

有没有人知道如何在apache下安装/配置php?

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

我已经出现了 php apache 。我想在 GENTOO 操作系统中为 apache 使用 mod_php。

php temp.php

php temp.php

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

命令行运行良好,但http://localhost/temp.php没有在 Web 服务器上执行,而是显示了 php 代码的内容。

回答by shahjapan

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:

我将这些行放在 /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:

如果您还想安装 phpmyadmin,那么您还应该添加 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:

然后我更改了文件/etc/init.d/apache2,以便为用户启用public_html文件夹(对应~目录),设置-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:

在启动 mysql 之前,您必须(一劳永逸)创建 mysql 主数据库,这可以通过运行简单地完成:

/usr/bin/mysql_install_db

回答by shahjapan

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:

似乎有很多方法可以实现这一点,但许多方法似乎有点过时或过于复杂。截至 2010 年 2 月 1 日,为了让 PHP 和 Apache2 在 Gentoo 上工作,我所做的只是像这样安装 Apache 和 PHP:

  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/phpand restart Apache with the /etc/init.d/apache2 script. PHP should now be available.
  1. bash$ emerge apache
  2. 按照我在 Gentoo 站点的这个列表中想要的特定扩展的说明进行操作
    • 注意:这是让 Apache 和 PHP 协同工作的重要一步:
      • bash$ echo "dev-lang/php apache2" >> /etc/portage/package.use
    • 另一个常见的 PHP 扩展:
      • bash$ echo "dev-lang/php mysql" >> /etc/portage/package.use
    • 等等。
  3. 然后只需bash$ emerge dev-lang/php使用 /etc/init.d/apache2 脚本运行并重新启动 Apache。PHP 现在应该可用了。

回答by jms

above link dead, try this one:

上面的链接死了,试试这个:

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

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

回答by Pascal MARTIN

You may find some informations in Apache 2.0 on Unix systems

您可能会在 Unix 系统上的 Apache 2.0 中找到一些信息

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 :

我在 Apache 的配置(Apache 2、PHP 5.2、Ubuntu)中的相应行是:

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>

回答by Sergey Olontsev