Вопрос

Having Ubuntu on virtual machine. Running Apache and need 2 virtual hosts on different ports, e.g. 69 and 100. (On 80 running nginx with php-fpm + fastcgi). Using port forwarding to host system to access from browser like localhost:69/ or localhost:100/

Config /etc/apache2/sites-available/default :

<VirtualHost *:69>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
...
        <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
        </IfModule>
</VirtualHost>

<VirtualHost *:100>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/html
...
</VirtualHost>

Added those ports as well to /etc/apache2/ports.conf

PHP not working for 2nd virtual host. If I add same <IfModule mod_fastcgi.c> directive i get error:

FastCgiExternalServer: redefinition of previously defined class "/usr/lib/cgi-bin/php5-fcgi"

What is correct way to configure it?

Это было полезно?

Решение

You can only have one of them. As this person points out: https://serverfault.com/questions/384715/fastcgi-error-with-apache2

Try adding it into the general config, not in side the virtualhost. It seems like you're trying to configure apache virtual hosts the way you'd do it for nginx. Maybe just add it to the apache.conf before the lines to read in sites_enabled

Normally this would be in a conf-enabled file.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top