Executing PHP code in .xml file

Discussion in 'General' started by Sam fas, May 30, 2018.

Tags:
  1. Sam fas

    Sam fas New Member

    Hello all,
    Sorry if i post in wrong place. Just i can't post in ALL Category.
    Server information : Ubuntu 16.04.3 LTS
    PHP : PHP 7.0.30-0ubuntu0.16.04.1 (cli)
    Apache2
    ISPConfig : ISPConfig 3.1dev

    i had tried every thing Possiple using .htaccess

    AddType application/x-httpd-php .xml
    AddHandler x-httpd-php .xml
    AddHandler php-script .php .xml
    AddType application/x-httpd-php .xml
    AddType application/x-httpd-php .xml

    But this never work. please share how to do it

    Regards

    Sam
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    This depends on the PHP mode that you use. When you take a look into the generated .vhost file of that site, theree you can see jow the file extensions are mapped to the php handler.
     
  3. Sam fas

    Sam fas New Member

    Till, thank you for the answer.
    Sorry i didn't mention that.
    I am using PHP-FPM for this vhost.

    Thanks
    Sam
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    If your server is using mod_fastcgi (which is the case for centos 7, Debian 8 and older and ubuntu before 17.04, if i remember correctly,), then the handler is:

    <FilesMatch "\.xml$">
    SetHandler php-fcgi
    </FilesMatch>

    If you use a newer distribution, then the SetHandler line is a bit more complicated and site-specific, you should look that up in the vhost file of the site.
     
  5. Sam fas

    Sam fas New Member

    @till thank you for the reply.

    When i add :
    <FilesMatch "\.xml$">
    SetHandler php-fcgi
    </FilesMatch>

    no effect at all When i add it to /etc/apache2/sites-available/domain.ltd.vhost
    under

    <IfModule mod_fastcgi.c>
    <Directory /var/www/clients/client0/web4/cgi-bin>
    Require all granted
    </Directory>
    <Directory /var/www/domain.ltd/web>
    <FilesMatch "\.php[345]?$">
    SetHandler php5-fcgi
    </FilesMatch>
    </Directory>
    <Directory /var/www/clients/client0/web4/web>
    <FilesMatch "\.php[345]?$">
    SetHandler php5-fcgi
    </FilesMatch>
    <FilesMatch "\.xml$">
    SetHandler php5-fcgi
    </FilesMatch>
    i get
    Access denied.

    do i am configuring in wrong place or what?
     

Share This Page