C
C
Coraelstraze2019-05-08 10:24:21
linux
Coraelstraze, 2019-05-08 10:24:21

Internal Server error 500 when connecting mod_fcgid on Apache CentOS 7?

There is a server on VirtualBox on CentOS 7. A bunch of Nginx + Apache (where nginx is the frontend, and Apache is the backend).
Because with dynamics, apache works for me, I understand that I need to connect fastcgi to it.
It costs PHP 7. It's just that sites work in mod_php mode.
1. Connected mod_fcgid module (required LoadModule is in httpd.conf)
2. Contents in fcgid.conf:

# This is the Apache server configuration file for providing FastCGI support
# through mod_fcgid
#
# Documentation is available at
# http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html

# Use FastCGI to process .fcg .fcgi & .fpl scripts
AddHandler fcgid-script fcg fcgi fpl

# Sane place to put sockets and shared memory file
FcgidIPCDir /run/mod_fcgid
FcgidProcessTableFile /run/mod_fcgid/fcgid_shm

DirectoryIndex index.php

FcgidFixPathinfo 1
FcgidMaxRequestsPerProcess 10000

3. Uncommented in php.ini:
cgi.fix_pathinfo=1
4. Created /var/www/php-cgi directory (sites are in /var/www/daniel/site1.ru/public_html....). It contains a php.fcgi file with the following content:
#!/bin/sh
PHP_FCGI_MAX_REQUESTS=10000
export PHP_FCGI_MAX_REQUESTS
exec /usr/bin/php-cgi

5. The site2.ru.conf file contains:
<VirtualHost *:8080>
ServerName site2.ru
ServerAlias www.site2.ru
DocumentRoot /var/www/daniel/site2.ru/public_html
ErrorLog /var/log/httpd/site2_ru_error.log
CustomLog /var/log/httpd/site2_ru_requests.log combined
SuexecUserGroup daniel daniel

<IfModule mod_fcgid.c>
FcgidBusyTimeout 3600
</IfModule>

<Directory "/var/www/daniel/site2.ru/public_html">
Options +ExecCGI
AddHandler fcgid-script .php
FcgiWrapper /var/www/php-cgi/php.fcgi .php
AllowOverride All
Order allow,deny
Allow from all
</Directory>

</VirtualHost>

6. I have the following permissions: apache runs under daniel:daniel and the entire /var/www/ directory recursively too.
The directories /var/www/php-cgi generally gave 777 in the end, because I googled what happens because of these rights an error.
At first I had an error with Permissions, I put the user daniel:daniel in /run/mod_fcgid/ and gave permissions 755.
The error with permissions disappeared, but now the main error has appeared, on which I am stuck.
When I go to the site, I have Internal Server Error 500. I
found errors only in the logs /var/log/httpd/site2_ru_error.log.
[Wed May 08 01:47:21.480618 2019] [fcgid:warn] [pid 32082] (104)Connection reset by peer: [client 127.0.0.1:52274] mod_fcgid: error reading data from FastCGI server
[Wed May 08 01:47:21.480722 2019] [core:error] [pid 32082] [client 127.0.0.1:52274] End of script output before headers: index.php

In php.ini and in fcgid.conf I tried to increase the amount of memory and the timeout. In vain.
Need help!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question