一个PHP安装包含多个php.ini文件 [英] One PHP installation with multiple php.ini files
问题描述
我试图配置php安装使用多个php.ini
这是否可行?
谢谢,
TL; DR向Apache conf文件添加 PHPIniDir ,并确保该文件夹包含适合您要求的php.ini版本。/ p>
需要一些更多的信息来确保完整的答案,但我会假设,并采取它,你正在使用LAMP服务器,并要求每个在Apache(vhost)下托管的服务器的自定义PHP.ini。
如果是这样,这是一个简单的过程,有一个(Apache)服务器主机多个vhosts和每个vhost有它自己的php.ini文件。
- 使用自己的文件夹(假设为/ var / www / vhostA)创建新的vhost
- 在/ var / www / vhostA中创建html文件夹/ html
- 将现有的php.ini文件(通常为/etc/php5/apache2/php.ini)复制到/var/www/vhostA/php.ini
- 编辑vhost配置文件并添加 PHPIniDir / var / www / vhostA 重新启动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.
- Create your new vhost, with it's own folder (assuming /var/www/vhostA)
- Create the html folder (housing the document root) in /var/www/vhostA/html
- Copy your existing php.ini file (typically /etc/php5/apache2/php.ini) to /var/www/vhostA/php.ini
- Edit the php.ini (as per 3) as you require it for vhostA's purposes
- Edit the vhost configuration file and add PHPIniDir /var/www/vhostA
- 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屋!