好吧,去稍微疯狂试图弄清楚这一点。 (我看过数以百计的问题/答案,而谷歌的文章,但没有回答吧)
Okay, going slightly crazy trying to figure this out. (I have read hundreds of questions/answers, and google articles, but none have answered it)
我刚刚从使用 mod_php的改为使用PHP的FastCGI通过FPM和使用中的this问题,纯粹是因为我是IM pression下,这是容易来指定使用这种设置单独的虚拟主机的php.ini文件。
I have just changed from using mod_php to using PHP through FastCGI and fpm, using the method described in this question, purely because I was under the impression it was 'easy' to specify php.ini files for individual vhosts using this set-up.
什么我出过拉我的头发,是如何可以指定一个自定义的PHP ini文件中的每个虚拟主机使用?
What I'm pulling my hair out over, is how can I specify a custom PHP ini file each vhost uses?
幸运的是,这只是在我的测试平台,到目前为止...但我希望做同样的我的生产服务器上,如果我都不能算出这个
Luckily, It's only on my test rig so far ... But I am hoping to do the same on my production server if I can ever figure this out
推荐答案我想我可能是井后整个过程中,我采取了与池配置FPM,如@ChristianM提到的,因为我还没有找到一个完整的解释如何做到这一点。
I thought I may as-well post the whole process I took to configure fpm with pools, as @ChristianM mentioned, because I've not yet found a full explanation on how to do it.
这第一部分主要是一个AskUbuntu后的副本:askubuntu/questions/378734/how-to-configure-apache-to-run-php-as-fastcgi-on-ubuntu-12-04-via-terminal/527227#comment905702_527227
The first part of this is mostly a copy of an AskUbuntu post: askubuntu/questions/378734/how-to-configure-apache-to-run-php-as-fastcgi-on-ubuntu-12-04-via-terminal/527227#comment905702_527227
最后一部分是如何配置池,并获得虚拟主机使用培训相关池设置
The last part is how to configure pools, and get the vhost to use the relevent pool settings
下面有云:
在 www.vps/blog/2013/04/08/apache-mpms-$p$pfork-worker-and-event/ )
sudo apt-get install apache2-mpm-worker安装的FastCGI和PHP5-FPM:
Install fastcgi and php5-fpm:
sudo apt-get install libapache2-mod-fastcgi php5-fpm现在让你需要的器官功能障碍综合征,并禁用那些您不:
Now enable mods you need, and disable those you don't:
sudo a2dismod php5 mpm_prefork sudo a2enmod actions fastcgi alias mpm_worker创建php5.fcgi文件,并给使用它的网络服务器的权限。
Create the php5.fcgi file and give the webserver permission to use it.
sudo touch /usr/lib/cgi-bin/php5.fcgi sudo chown -R www-data:www-data /usr/lib/cgi-bin创建PHP5-FPM一个全局配置
Create a global config for php5-fpm
sudo nano /etc/apache2/conf-available/php5-fpm.conf粘贴在下面(我们将使用一个插座,而不是IP地址)
paste in the following (we'll use a socket instead of IP address)
<IfModule mod_fastcgi.c> AddHandler php5.fcgi .php Action php5.fcgi /php5.fcgi Alias /php5.fcgi /usr/lib/cgi-bin/php5.fcgi FastCgiExternalServer /usr/lib/cgi-bin/php5.fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization -idle-timeout 3600 <Directory /usr/lib/cgi-bin> Require all granted </Directory> </IfModule>请注意:确保所有的configs遵循相同的新的要求所有授予'/'要求所有被拒绝'语法......否则,你就重启后感到痛苦......
Note: Ensure all configs follow the same new 'Require all granted'/'Require all denied' syntax ... Otherwise you'll feel the pain after restarting ...
启用PHP5-FPM的conf
Enable the php5-fpm conf
sudo a2enconf php5-fpm重新启动Apache和FPM
Restart apache and fpm
sudo service apache2 restart && sudo service php5-fpm restart这实质上设置为创建一个PHP的全球FastCGI配置,其采用了文件/etc/php5/fpm/php.ini文件。
This setup essentially creates a global fastcgi configuration for php, which uses the file /etc/php5/fpm/php.ini file.
如果您有多个虚拟主机,这将需要不同的PHP配置,继续下面的
If you have multiple vhosts, that are going to need different php configurations, continue with the example below
首先,/etc/php5/fpm/pool.d目录中,你会发现默认的www.conf文件。复制此,将其命名为一些培训相关:
First, within the /etc/php5/fpm/pool.d dir, you will find the default www.conf file. Copy this, naming it something relevent:
sudo cp /etc/php5/fpm/pool.d/www.conf /etc/php5/fpm/pool.d/domain2.conf编辑这个文件,更改池名称:
Edit this file, changing the pool name:
[...] [domain2] [...]和改变监听套接字的名字的东西培训相关:
And change name of the listen socket to something relevent:
[...] listen = /var/run/php5-fpm-domain2.sock [...]然后复制/usr/lib/cgi-bin/php5.fcgi文件,再次将其命名为一些培训相关:
Then copy the /usr/lib/cgi-bin/php5.fcgi file, again naming it something relevent:
cp /usr/lib/cgi-bin/php5.fcgi /usr/lib/cgi-bin/php5-domain2.fcgi现在你已经准备好到的mod_fastcgi模块添加到DOMAIN2虚拟主机。这几乎与上述相同的所描述的,但要注意对于别名,FastCgiServer'和'-socket'
Now you're ready to add the mod_fastcgi module to the domain2 vhost. It's almost the same as the one described above, but notice the changes for 'Alias','FastCgiServer' and '-socket'
<VirtualHost *:80> ServerName domain2 [...] <IfModule mod_fastcgi.c> AddHandler php5.fcgi .php Action php5.fcgi /php5.fcgi Alias /php5.fcgi /usr/lib/cgi-bin/php5-domain2.fcgi FastCgiExternalServer /usr/lib/cgi-bin/php5-domain2.fcgi -socket /var/run/php5-fpm-domain2.sock -pass-header Authorization -idle-timeout 3600 <Directory /usr/lib/cgi-bin> Require all granted </Directory> </IfModule> [...] </VirtualHost>重新启动Apache和FPM
Restart apache and fpm
sudo service apache2 restart && sudo service php5-fpm restart现在测试的变化。
在您的新/etc/php5/fpm/pool.d/domain2.conf文件,添加一个PHP价值变动(我选择了session.name值):
In your new /etc/php5/fpm/pool.d/domain2.conf file, add a php value change (I've chosen the session.name value):
[...] php_admin_value[session.name] = 'DOMAIN2' [...]现在重新启动之前FPM测试配置:
Now test the configuration before restarting fpm:
sudo php5-fpm -t如果配置失败,但更重要的是会告诉你,如果你的配置是好的它会告诉你。然后你就可以继续前进,重新启动FPM:
It will tell you if the configuration fails, but more importantly will tell you if your configuration is fine. Then you can go ahead and restart fpm:
sudo service php5-fpm restart最后,如果你想成为超级确保PHP价值已定,您的网站中创建info.php的,并且只需添加:
And finally, if you want to be super sure the php value has been set, create info.php within your site, and just add:
<?php phpinfo(); ?>更多推荐
指定每个虚拟主机的PHP ini文件,FastCGI的/ PHP
发布评论