在阅读了很多教程之后,我成功地在Ubuntu 12 LTS上成功运行了Apache MPM-Worker和PHP-FPM。 我为每个用户都有独立的池,一切都像一个魅力。 不过,我需要为其中一个域安装SSL。 我设法创build自签名证书只是为了获得安全的连接和运行。 我的问题是,我目前的设置,我将无法运行SSL的另一个域名,因为当重新加载Apache设置我得到一个错误(警告):
[Sun Mar 15 16:52:59 2015] [warn]第21行的/etc/apache2/sites-enabled/www.my-site-name.com中的Alias指令可能永远不会匹配,因为它与早期的Alias重叠。
我的设置如下:
/etc/apache2/conf.d/php5-fpm.conf
<IfModule mod_fastcgi.c> AddHandler php5-fcgi .php Action php5-fcgi /php5-fcgi </IfModule>
/etc/php5/fpm/pool.d/example.conf
[example] user = example group = example listen = /tmp/php5-fpm-example.sock listen.owner = example listen.group = example listen.mode = 0660
/etc/apache2/sites-enabled/www.my-site-name.com
<VirtualHost *:80> content goes here </VirtualHost> <IfModule mod_ssl.c> <VirtualHost *:443> content goes here </VirtualHost> </IfModule> <IfModule mod_fastcgi.c> Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi_example FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi_example -socket /tmp/php5-fpm-example.sock -idle-timeout 300 -pass-header Authorization -flush </IfModule>
当我把代码Alias / php5-fcgi …在VirtualHost *:80和VirtualHost *:443 (80和443两次)中,我得到一个错误的重复规则。 然而,当我把代码放在VirtualHost *:80和VirtualHost *:443之外 ,如上面的例子所示,那么这个规则就像全局规则一样。 这意味着如果我不为一个站点创build用户,它将该用户作为默认值应用 – 示例。 因此在我看来,我将无法为其他网站设置SSL。
如何在ifModule mod_fastcgi.c之后包含代码以实现安全和非安全连接,而不会从apache获取错误?
任何帮助我的情况,高度赞赏。
我发布了这个问题,不久之后,我在另一个Apache和多个PHP-FPM池中find答案
这个代码对我来说并不是100%的工作,但是它给我指出了正确的方法。
这段代码对我不起作用:
<FilesMatch \.php$> SetHandler php-script </FilesMatch>
所以我的代码很简单:
AddHandler php5-fcgi .php
我将这个代码包含在SSL中:
<IfModule mod_fastcgi.c> Alias /php5-fcgi /usr/lib/cgi-bin/php5-ssl-fcgi_example FastCgiExternalServer /usr/lib/cgi-bin/php5-ssl-fcgi_example -socket /tmp/php5-fpm-example.sock -idle-timeout 300 -pass-header Authorization -flush </IfModule>
注意Alias和FastCgiExternalServer中的ssl 。 这个configuration对我来说工作正常。