一个PHP安装包含多个php.ini文件 [英] One PHP installation with multiple php.ini files

查看:525
本文介绍了一个PHP安装包含多个php.ini文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图配置php安装使用多个php.ini
这是否可行?



谢谢,


TL; DR向Apache conf文件添加 PHPIniDir ,并确保该文件夹包含适合您要求的php.ini版本。

需要一些更多的信息来确保完整的答案,但我会假设,并采取它,你正在使用LAMP服务器,并要求每个在Apache(vhost)下托管的服务器的自定义PHP.ini。
如果是这样,这是一个简单的过程,有一个(Apache)服务器主机多个vhosts和每个vhost有它自己的php.ini文件。


  1. 使用自己的文件夹(假设为/ var / www / vhostA)创建新的vhost

  2. 在/ var / www / vhostA中创建html文件夹/ html

  3. 将现有的php.ini文件(通常为/etc/php5/apache2/php.ini)复制到/var/www/vhostA/php.ini

  4. 编辑vhost配置文件并添加 PHPIniDir / var / www / vhostA
  5. 重新启动Apache

Apache vhost配置文件示例阅读这样:

 < VirtualHost 1.2.3.4:80> 
DocumentRoot / var / www / vhostA / html
< Directory/ var / www / vhostA / html>
选项-Indexes
< / Directory>
PHPINIDir / var / www / web1
ErrorLog $ {APACHE_LOG_DIR} /vmhostA-error.log
CustomLog $ {APACHE_LOG_DIR} /vmhostA-access.log combined
< / VirtualHost> ;


I am trying to configure php installation to use multiple php.ini Is this it feasible?

Thanks,

解决方案

TL;DR Add PHPIniDir to Apache conf file and ensure that folder contains a version of php.ini suited to your requirements.

A little more information would be required to ensure a full answer, but I'll make an assumption and take it that you're working with a LAMP server, and require making a custom PHP.ini for each server hosted under Apache (vhost). If so, it's a simple procedure for having one (Apache) server host multiple vhosts and each vhost having it's own php.ini file.

  1. Create your new vhost, with it's own folder (assuming /var/www/vhostA)
  2. Create the html folder (housing the document root) in /var/www/vhostA/html
  3. Copy your existing php.ini file (typically /etc/php5/apache2/php.ini) to /var/www/vhostA/php.ini
  4. Edit the php.ini (as per 3) as you require it for vhostA's purposes
  5. Edit the vhost configuration file and add PHPIniDir /var/www/vhostA
  6. Restart Apache

An example Apache vhost configuration file would (therefore) read something like this:

<VirtualHost 1.2.3.4:80>
    DocumentRoot /var/www/vhostA/html
    <Directory "/var/www/vhostA/html">
        Options -Indexes
    </Directory>
    PHPINIDir /var/www/web1
    ErrorLog ${APACHE_LOG_DIR}/vmhostA-error.log
    CustomLog ${APACHE_LOG_DIR}/vmhostA-access.log combined
</VirtualHost>

这篇关于一个PHP安装包含多个php.ini文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆