E
E
Evgeny2014-08-08 16:13:17
PHP
Evgeny, 2014-08-08 16:13:17

Why does apache mod_fcgid give *.php scripts in plain text?

Good day!
When setting up the apache server with mod_fcgid, the following problem occurred:
All *php files are given "as is", i.e. the code

<?
echo 'test';

Looks like in browser
<?
echo 'test';

but
test
I will not be grateful for help in solving.
The following is information that may be helpful:
# cat /etc/redhat-release
CentOS release 6.5 (Final)

# rpm -qa | grep -iE "http|mod_fcgid"
mod_fcgid-2.3.9-1.el6.x86_64
httpd-tools-2.2.15-31.el6.centos.x86_64
httpd-2.2.15-31.el6.centos.x86_64

# php-cgi -v
PHP 5.5.15 (cgi-fcgi) (built: Aug  7 2014 05:56:28)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

# which php-cgi
/usr/local/bin/php-cgi

# php -v
PHP 5.5.15 (cli) (built: Aug  7 2014 05:56:14) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

# httpd -v
Server version: Apache/2.2.15 (Unix)
Server built:   Jul 23 2014 14:17:29

# cat /var/www/php-cgi/php.cgi 
#!/bin/sh
PHPRC=/usr/local/lib/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=500
exec /usr/local/bin/php-cgi

# cat /etc/httpd/conf.d/test.ru.conf 
<VirtualHost *:80>
  DocumentRoot /var/www/vhosts/test.ru/html
  #DirectoryIndex index.php
  ServerName test.ru
  ServerAlias www.test.ru
  CustomLog /var/www/vhosts/test.ru/access.log vcombined
  ErrorLog /var/www/vhosts/test.ru/error.log

  <IfModule mod_fcgid.c>
    SuexecUserGroup www staff
    <Directory /var/www/vhosts/test.ru>
      Options +ExecCGI
      AllowOverride All
      AddHandler fcgid-script .php
      FCGIWrapper /var/www/php-cgi/php.cgi .php
      Order allow,deny
      Allow from all
    </Directory>
  </IfModule>
</VirtualHost>

Logs:
# tail /etc/httpd/logs/error_log 
[Fri Aug 08 05:29:59 2014] [notice] suEXEC mechanism enabled (wrapper: /usr/sbin/suexec)
[Fri Aug 08 05:29:59 2014] [notice] Digest: generating secret for digest authentication ...
[Fri Aug 08 05:29:59 2014] [notice] Digest: done
[Fri Aug 08 05:29:59 2014] [notice] Apache/2.2.15 (Unix) DAV/2 mod_fcgid/2.3.9 configured -- resuming normal operations

# tail /etc/httpd/logs/suexec.log 
[2014-08-08 04:23:47]: uid: (500/www) gid: (500/staff) cmd: php.cgi
[2014-08-08 04:35:58]: too few arguments
[2014-08-08 04:53:32]: uid: (500/www) gid: (500/staff) cmd: php.cgi
[2014-08-08 05:31:38]: uid: (500/www) gid: (500/staff) cmd: php.cgi

Thanks for any help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny, 2014-08-08
@jennik

I beg your pardon. Short_tags was disabled in php.ini. Therefore, PHP was not interpreted.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question