Permission denied with apache filter - php

I use apache httpd on Centos7 (SELinux) and am trying to create an output filter to modify all served html pages. I've browsed some tutorials on how to create them, but I keep stumbling on step one even before I get to the coding part.
Currently I have this in my httpd.conf
ExtFilterDefine portal_header mode=output intype=text/html cmd="/var/www/root/main/portal/portal.php"
SetOutputFilter portal_header
To pinpoint my problem I have deleted all the actual code in the file /var/www/root/main/portal/portal.php for the moment and currently it looks like this
#!/usr/bin/php
<php?
/* test */
?>
But when I know try to access any html on the server I get "500 Internal Server Error". After commenting out the SetOutputFilter line in httpd.conf the pages work so the error is generated by the filter.
In my error log it reads
[Fri Feb 10 14:36:55.458174 2017] [ext_filter:error] [pid 171495] (13)Permission denied: [client 10.2.8.109:49278] AH01458: couldn't create child process to run `/var/www/root/main/portal/portal.php'
[Fri Feb 10 14:36:55.458215 2017] [ext_filter:error] [pid 171495] (13)Permission denied: [client 10.2.8.109:49278] AH01467: can't initialise output filter portal_header: aborting
I have at least
changed the file permissions to 777
verified that php is located at /usr/bin/php and owned by apache group with proper rights
tried to add and remove ScriptAlias and/or SetHander cgi-script for the directory in httpd.conf
tried with completely empty script file
but none of the above has any effect. The only change in matters was that when I deliberately mis-spelled the file name I got "No such file or directory" error instead.
Does anyone have an idea what I should do to make this work? For the moment I would be happy to see the script to even do nothing at all, if it just didn't break, and only afterwards add some functionalities into it.
UPDATE: I was able to pinpoint the problem to SELinux policies, since after disabling them (setenforce 0) the error vanished. So currently I'm trying to figure out how I should alter the policies.

I ran into a similar problem when trying to improve on a simple sed filter command.
According to the https://httpd.apache.org/docs/2.4/mod/mod_ext_filter.html documentation it should be possible to use a command like sed as a filter and indeed it does:
The following filter works for me and replaces global links to local ones so that i can use a docker image with data from an existing site.
# Filter configuration
# mod_ext_filter directive to define a filter which
# replaces text in the response
#
ExtFilterDefine fixtext mode=output intype=text/html \
cmd="/bin/sed s#http://ceur.ws.org#http://capri:8880#g"
<Location "/">
# core directive to cause the fixtext filter to
# be run on output
SetOutputFilter fixtext
</Location>
when trying to replace the sed command with accessing a script with
"cmd=/root/bin/filter.sh"
I got the error message :
AH01458: couldn't create child process to run `/root/bin/filter.sh'
AH01467: can't initialise output filter fixtext: aborting
which is your original reason for your question.
Now i am also looking for a better solution and tried:
cmd="/bin/bash /root/bin/filter.sh"
assuming that the shebang resolving might be the culprit. Interestingly i then get:
AH01461: apr_file_write(child input), len 0
AH01468: ef_unified_filter() failed
and that's why i am already posting this answer in the hope I'll find a proper solution soon or others might be able to help because the list of related AH014## error codes is getting longer in this Q&A thread.
See https://github.com/omnigroup/Apache/blob/master/httpd/modules/filters/mod_ext_filter.c for the relevant source code.
I am assuming that the apr_proc_create is not capable of calling scripts using a shebang. So my workaround was to
call the command directly
switch to awk
Working apache filter.conf
# Filter configuration
# mod_ext_filter directive to define a filter which
# replaces text in the response
#
ExtFilterDefine fixtext mode=output intype=text/html \
cmd="/usr/bin/awk -f /var/www/filter.awk"
<Location "/">
# core directive to cause the fixtext filter to
# be run on output
SetOutputFilter fixtext
</Location>
working awk script to filter links
# WF 2020-06-03
#
# filter HTML output thru this awk script to fix global links to local ones
#
# you might want to try out this filter from the command line with
# cat /var/www/html/index.html | awk -f filter.awk
#
# setup the replacement
BEGIN {
port=8880
host="capri"
sourceServer="http://ceur-ws.org"
targetServer=sprintf("http://%s:%s",host,port)
}
# for each line
{
# get the line
line=$0
# replace any sourceServer reference with the targetServer reference
gsub(sourceServer,targetServer,line)
# output the modified line
print line
}
/root/bin/filters.sh
#!/bin/bash
# WF 2020-06-02
# filter all html output thru this script
port=8880
host=capri
# substitute all hard links in CEUR-WS with a local link
/bin/sed s#http://ceur.ws.org#http://$host:$port#g
# try out this filter with
# cat /var/www/html/index.html | /root/bin/filter.sh | grep capri

Related

Apache2 with PHP support in Yocto

I am using Yocto to create a build including apache2 but I have a hard time adding php support. I had it running previously (read: last year) but since then there have been changes to the meta-webserver layer in meta-openembedded. From the README file in meta-webserver:
"This layer used to provide a modphp recipe that built mod_php, but
this is now built as part of the php recipe in meta-oe. However, since
apache2 is required to build mod_php, and apache2 recipe is in this
layer and recipes in meta-oe can't depend on it, mod_php is not built
by default. If you do wish to use mod_php, you need to add "apache2"
to the PACKAGECONFIG value for the php recipe in order to enable it."
I have added the following line to php in my own layer:
PACKAGECONFIG_append = " apache2"
But I get compilations error when it can't find what appears to be apache include files when compiling mod_php (I include only one error below, I get a similar error for ap_config.h as well):
In file included from /home/martin/Yocto/poky/rpi/tmp/work/x86_64-linux/php-native/5.6.12-r0/php-5.6.12/sapi/apache2handler/mod_php5.c:26:0:
| /home/martin/Yocto/poky/rpi/tmp/work/x86_64-linux/php-native/5.6.12-r0/php-5.6.12/sapi/apache2handler/php_apache.h:24:19: fatal error: httpd.h: No such file or directory
| compilation terminated.
Has anyone managed to compile apache2 with php support lately and can give some assistance on how to do it? Thanks!
With valued help from Armin Kuster I managed to solve my issue. Armin noticed that PACKAGECONFIG_append = " apache2" overrides the existing PACKAGECONFIG and sets "apache2" only. Based on his suggestion I changed my bbappend file to include the following:
DEPENDS = "apache2"
RDEPENDS_${PN} = "apache2"
PACKAGECONFIG = "sqlite3 apache2 ${#bb.utils.contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}”
I don’t know if the DEPENDS and RDEPENDS are necessary any longer but they don’t seem to hurt.
I then realised that just adding 'php' to my layer.conf doesn't build the binaries like they did in the past. I had to explicitly specify php-cli and php-modphp. My layer.conf now includes this:
IMAGE_INSTALL_append = " apache2 php php-cli php-modphp"
With this the PHP recipe builds and includes both the php binary and the php apache module. However, the file /etc/apache/modules.d/70_mod_php5.conf does not load the PHP module since the PHP5 environment variable is not defined (see default file below). I didn't know where to specify the environment variable so instead I ended up overriding this file in my own layer and in my version I simply removed the IfDefine.
# vim: ft=apache sw=4 ts=4
<IfDefine PHP5>
# Load the module first
<IfModule !sapi_apache2.c>
LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
</IfModule>
# Set it to handle the files
AddHandler php5-script .php .phtml .php3 .php4 .php5
AddType application/x-httpd-php-source .phps
DirectoryIndex index.html index.html.var index.php index.phtml
</IfDefine>
I hope that this can be of help to others with the same issue.
To add PHP support with apache in yocto , make the following changes in the bitbake recipe file.
Below is the diff output of the php.inc file
10c10
< openssl libmcrypt"
---
> openssl libmcrypt apache2-native apache2"
52c54,55
< EXTRA_OECONF = "--enable-mbstring \
---
> EXTRA_OECONF = "--with-apxs2=${STAGING_BINDIR_CROSS}/apxs \
> --enable-mbstring \
129c132
< if ${#bb.utils.contains('PACKAGECONFIG', 'apache2', 'true', 'false', d)}; then
---
> if ${#bb.utils.contains('PACKAGECONFIG', 'apache2', 'true', 'true', d)}; then
200c203
< PACKAGES = "${PN}-dbg ${PN}-cli ${PN}-cgi ${PN}-fpm ${PN}-fpm-apache2 ${PN}-pear ${PN}-phar ${MODPHP_PACKAGE} ${PN}-dev ${PN}-staticdev ${PN}-doc ${PN}"
---
> PACKAGES = "${PN}-dbg ${PN}-cli ${PN}-cgi ${PN}-fpm ${PN}-fpm-apache2 ${PN}-pear ${PN}-phar ${MODPHP_PACKAGE} ${PN}-dev ${PN}-staticdev ${PN}-doc ${PN} ${PN}-modphp"
236a240
> #FILES_${PN} += "${sysconfdir}"
Hope , this helps to work out :)

Can't find ordinal 372 in WAMP/Apache's openssl.exe

The PHP framework I use needs OpenSSL for various features, but when executing anything related to OpenSSL, I get the following error: "Can't find ordinal 372 in DLL-file C:\wamp64\bin\apache\apache2.4.17\bin\openssl.exe".
I don't know how to correct this at all, I looked everywhere already. I'd appreciate the help, as I don't know how to fix this.
To fix the issue, two things are needed:
1) Make sure that you don't have symbolic links for libeay32.dll and ssleay32.dll in your Apache bin directory
(For example, mine is: C:\wamp64\bin\apache\apache2.4.23\bin)
If you do have symbolic links (i.e. the file size are 0 bytes), you need to download the dlls from Apache Lounge.
For example, I grabbed the two .dll files from the 64-bit version of Apache 2.4.23 hosted at https://www.apachelounge.com/download/
2) Once you have the actual .dll files restored, you need to make sure that WampServer isn't overwriting them. WampServer 3 has a configuration script that runs every time it starts. In that script it will overwrite those .dlls with symbolic links. You must DISABLE that functionality. To do so, comment out the references to those two files in: C:\wamp64\scripts\config.inc.php (mine were located at lines 133 and 139).
That should allow you to enable the mod_ssl module in Apache. You'll also need to uncomment the "Include conf/extra/httpd-ssl.conf" after you get Apache booting properly with mod_ssl enabled. (However, you'll likely need to delete most of whats in there and start over since it includes lots of hardcoded paths and bugs)
... "Can't find ordinal 372 in DLL-file C:\wamp64\bin\apache\apache2.4.17\bin\openssl.exe"
I'm speculating its PEM_SealInit or SSL_CONF_cmd_argv from OpenSSL 1.0.2; or ASN1_i2d_fp or SSL_SESSION_set1_id_context from OpenSSL 1.1.0.
# OpenSSL 1.1.0
$ find $PWD -type f -iname '*.num' -exec grep " 372" {} \;
ASN1_i2d_fp 372 1_1_0 EXIST::FUNCTION:STDIO
SSL_SESSION_set1_id_context 372 1_1_0 EXIST::FUNCTION:
...
# OpenSSL 1.0.2
$ find $PWD -type f -iname '*.num' -exec grep " 372" {} \;
PEM_SealInit 372 EXIST::FUNCTION:RSA
SSL_CONF_cmd_argv 372 EXIST::FUNCTION:
...
You will need to verify it by using dumpbin or Dependency Walker. Also see How can I find the exported function name from ordinal (export by ordinal)? on Stack Overflow.
The ordinals are created using <openssl src>\util\mkdef.pl. You can see the source code from OpenSSL's GitHub presence. Here is 1.0.2 and here is 1.1.0.
Here are the head comments for the file:
#!/usr/local/bin/perl -w
#
# generate a .def file
#
# It does this by parsing the header files and looking for the
# prototyped functions: it then prunes the output.
#
# Intermediary files are created, call libcrypto.num and libssl.num,
# The format of these files is:
#
# routine-name nnnn vers info
#
# The "nnnn" and "vers" fields are the numeric id and version for the symbol
# respectively. The "info" part is actually a colon-separated string of fields
# with the following meaning:
#
# existence:platform:kind:algorithms
#
# - "existence" can be "EXIST" or "NOEXIST" depending on if the symbol is
# found somewhere in the source,
# - "platforms" is empty if it exists on all platforms, otherwise it contains
# comma-separated list of the platform, just as they are if the symbol exists
# for those platforms, or prepended with a "!" if not. This helps resolve
# symbol name variants for platforms where the names are too long for the
# compiler or linker, or if the systems is case insensitive and there is a
# clash, or the symbol is implemented differently (see
# EXPORT_VAR_AS_FUNCTION). This script assumes renaming of symbols is found
# in the file crypto/symhacks.h.
# The semantics for the platforms is that every item is checked against the
# environment. For the negative items ("!FOO"), if any of them is false
# (i.e. "FOO" is true) in the environment, the corresponding symbol can't be
# used. For the positive itms, if all of them are false in the environment,
# the corresponding symbol can't be used. Any combination of positive and
# negative items are possible, and of course leave room for some redundancy.
# - "kind" is "FUNCTION" or "VARIABLE". The meaning of that is obvious.
# - "algorithms" is a comma-separated list of algorithm names. This helps
# exclude symbols that are part of an algorithm that some user wants to
# exclude.
I just encountered the same problem, on Windows and using xampp instead of Wamp.
Doing what's described in the commentaries of this page solved it : PHP cURL Installation.
I copied the 3 .dll files from the PHP installation directory to the apache/bin directory and rebooted xampp.

Apache error 500 on large file uploads (mod_security)

As far as I've tried, none of the usual solutions works for me. Well, my problem, I'm receiving an 500 Error every time I upload a "large file" (600 KB ~), with smaller images it works fine. So..., even with this (extreme) .htaccess file it keeps happening, and yes, .htaccess are active:
upload_max_filesize = 100M
post_max_size = 100M
memory_limit = 128M
max_input_time = 6000
max_execution_time = 6000
So, I take a look at the logs and find this (is only one line, just pasted it as easy to read with line jumps):
[Mon Jul 27 17:09:28.<port> 2015] [:error] [pid 21423] [client <ip>]
ModSecurity: Access denied with code 44 (phase 2).
Match of "eq 0" against "MULTIPART_UNMATCHED_BOUNDARY" required.
[file "/etc/httpd/conf.d/mod_security.conf"]
[line "35"] [id "<another id>"]
[msg "Multipart parser detected a possible unmatched boundary."]
[hostname "<my host>"] [uri "<my script>"] [unique_id "<id (useless I think)"]
But, now I not able to find how to edit the mod_security (it has the default config, and empty activated_rules) config in order (i think) to allow this "large" file uploads. I'm running PHP 5.3 in Apache 2.4/CentOS 7.
The fact you have a ModSecurity alert means that you can't have empty activated_rules folder or you are including the rules in some other way.
There are known problems with ModSecurity for this error and it seems very susceptible to false positives.
The main advice when I rule is raising too many false positives is to just turn off that rule (I'm assuming it's rule 200003 that's firing but replace the id as appropriate):
SecRuleRemoveById 200003
I got the same error:
ModSecurity: Access denied with code 44 (phase 2). Match of "eq 0" against "MULTIPART_UNMATCHED_BOUNDARY" required. [file "/etc/httpd/conf.d/mod_security.conf"] [line "34"] [id "200003"] [msg "Multipart parser detected a possible unmatched boundary."]
But #nilpo answer was correct
I got this issue due to the image name and after changing the name issue solved.
But it's not something I want because I know the solution but my customer did't know that they have to change the name.
try to check FcgidBusyTimeout parameter in fcgi configuration
Rename the file you are attempting to upload. This error indicates the file name contains a character that is disallowed by mod_security. Rename the file and then try uploading it again. By disabling the mentioned line in mod_security.conf, it will happily skip past this check but that leaves your server open to vulnerabilities.
all i am found SOLUTION!!!
UBUNTU 16.04 + Apache (MY mod_secure WORK AND UPLOAD OK)
0. apache a2enmod headers (activate headers and .htaccess)
1. CHECK .htaccess !!!!!
//in .htaccess
php_value upload_max_filesize 50M
php_value post_max_size 50M
//if you want custom in .htaccess
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
https://www.maketecheasier.com/securing-apache-ubuntu/ instruction for commands
sudo nano /etc/apache2/mods-enabled/security2.conf - last 2 lines i am comment
sudo nano /etc/modsecurity/modsecurity.conf - configuration mod_secure is easy
sudo nano /etc/apache2/apache2.conf - apache configuration CTRL+W
//on/off
bash->a2dismod mod-security2 //off
or
bash->a2dismod security2 //off
bash->a2enmod mod-security2 //on
bash->a2enmod security2 //on
If you want you can remove specific rules:
http://www.inmotionhosting.com/support/website/modsecurity/find-and-disable-specific-modsecurity-rules
SecRuleRemoveById 950004 in modsecurity.conf
4. Byteconverter - http://whatsabyte.com/P1/byteconverter.htm
THIS IS ENOUGHT!!!!
4 hour!!

Apache Server Throwing 500 Internal Server Error

I had a LAMP application running wordpress and I deleted the whole directory and replaced with new files - php based.
Now, when I go to view my server running CentOS - it just shows a 500 Internal Server error.
I've tried:
restarting server
restarting apache service itself
both completed successfully, but this didn't fix anything. Now, I do not know where to go from here.
apache logs # /usr/local/apache/logs/error_log on apache:
[Tue Apr 22 11:12:15 2014] [error] [] SoftException in Application.cpp:357: UID of script "index.php" is smaller than min_uid
I found the fix myself, this wasn't an error with Mysql at all, but rather a permissions issue with the index.php file I had.
The error, which I found in /usr/local/apache/logs/error_log was:
:is smaller than min_uid Premature end of script headers: index.php
To fix, I did this:
ls -l in the directory causing the issue (mine was public_html)
You should see the index file (e.g. index.php) that should be causing the issue. It is due to a root user having the only permission to the file and not your CPanel (or system) username. (note this system/cpanel name)
Run the following within the errorneous directory(Note: this command must be run within all subdirectories of the primary errorneous directory.):
sudo chown yoursystemuserhere:yoursystemgroupuserhere index.php
or to apply to the whole directory (thanks to #Prix):
sudo chown -R user:group /folder
You're all set.
Further literature here: http://www.inmotionhosting.com/support/website/general-server-setup/uid-smaller-than-min-uid
I hope this helps someone else in the future.
I had similar symptoms on my cPanel VPS - I was able to use easyApache to recompile Apache and PHP which fixed the problem for me.
(I realise my problem was slightly different to yours, but it may be helpful for people in the future who have the same problem I had).
chown -R user.usergroup /path_to_the_directory
Will resolve this. It is basically permission issues.
just install wordpress latest version make sure you have atleast php version 5.3 and above also look global register variable if it off or just delete htacess file from server and see what will happens
generally 500 internal server gives when file permission is missing so you should delete htacess file

Connection reset by peer: mod_fcgid: error reading data from FastCGI server

I am having issue on PHP where my app is trying to run a php backup file and suddenly getting HTTP Error 500 Code. I have checked the logs and this what it saying.
[Tue Aug 28 14:17:28 2012] [warn] [client x.x.x.x] (104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server, referer: http://example.com/backup/backup.php
[Tue Aug 28 14:17:28 2012] [error] [client x.x.x.x] Premature end of script headers: backup.php, referer: http://example.com/backup/backup.php
Anyone knows how to fix this? I'm really stuck in here and can't find solution in internet.
Hope anyone could share their knowledge.
Thanks.
James
I managed to solved this by adding FcgidBusyTimeout . Just in case if anyone have similar issue with me.
Here is my settings on my apache.conf:
<VirtualHost *:80>
.......
<IfModule mod_fcgid.c>
FcgidBusyTimeout 3600
</IfModule>
</VirtualHost>
I had very similar errors in the Apache2 log files:
(104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
Premature end of script headers: phpinfo.php
After checking the wrapper scripts and Apache2 settings, I realized that /var/www/ did not have accordant permissions. Thus the FCGId Wrapper scripts could not be read at all.
ls -la /var/www
drwxrws--- 5 www-data www-data 4096 Oct 7 11:17 .
For my scenario chmod -o+rx /var/www was required of course, since the used SuExec users are not member of www-data user group - and they should not be member for security reasons of course.
if you want to install a PHP version < 5.3.0, you must replace
--enable-cgi
with:
--enable-fastcgi
in your ./configure statement, excerpt from the php.net doc:
--enable-fastcgi
If this is enabled, the CGI module will be built with support for FastCGI also. Available since PHP 4.3.0
As of PHP 5.3.0 this argument no longer exists and is enabled by --enable-cgi instead. After the compilation the ./php-cgi -v should look like this:
PHP 5.2.17 (cgi-fcgi) (built: Jul 9 2013 18:28:12)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
NOTICE THE (cgi-fcgi)
I had this issue and realized that the file cgi-bin/php-fcgi had no execution rights.
It had 644 mode while is should have 755 mode.
Setting the correct mode was impossible (probably because the file was opened or sth), so I copied that file from another domain directory where it had proper rights already set and that fixed everything.
I had the same problem with a different and simple solution.
Problem
I installed PHP 5.6 following the accepted answer to this question on Ask Ubuntu.
After using Virtualmin to switch a particular virtual server from PHP 5.5 to PHP 5.6, I received a 500 Internal Server Error and had the same entries in the apache error log:
[Tue Jul 03 16:15:22.131051 2018] [fcgid:warn] [pid 24262] (104)Connection reset by peer: [client 10.20.30.40:23700] mod_fcgid: error reading data from FastCGI server
[Tue Jul 03 16:15:22.131101 2018] [core:error] [pid 24262] [client 10.20.30.40:23700] End of script output before headers: index.php
Cause
Simple: I didn't install the php5.6-cgi packet.
Fix
Installing the packet and reloading apache solved the problem:
sudo apt-get install php5.6-cgi if you are using PHP 5.6
sudo apt-get install php5-cgi if you are using a different PHP 5 version
sudo apt-get install php7.0-cgi if you are using PHP 7
Then use service apache2 reload to apply the configuration.
The famous Moodle "replace.php" script can generate this situation too.
For me it was taking ages to run and then failed with a 500 message in the browser and also with the above error message in my apache error log file.
I followed up on #james-wise answer:
FcgidBusy is readably described in the Apache documentation. I tried this: doubled the amount of time which apache would give my script to run, by inserting the following line in /etc/apache2/mods-available/fcgid.conf
FcgidBusyTimeout 600
Then I restarted Apache and tried to run my replace.php script again.
Fortunately this time the script instance ran to completion, so for my purposes this served as a solution.
I came across this one while debugging a virtualmin/apache related error.
In my case, I am running virtualmin and had in my virtual machine's php.ini
safe_mode=On.
In my Virtual Machine's error log, I was getting the fcgi Connection reset by peer: mod_fcgid: error reading data from FastCGI server
In my main apache error log I was getting:
PHP Fatal error: Directive 'safe_mode' is no longer available in PHP in Unknown on line 0
In my case, I simply set safe_mode = Off in my php.ini and restarted apache.
stackoverflow.com/questions/18683177/where-to-start-with-deprecated-directive-safe-mode-on-line-0-in-apache-error
Not in this questions askers case but often:
What does the "premature end of script headers" error mean?
That error means that the FCGI call was exited unexpectedly.
In some cases it means that the script "backup.php" did crash.
How to fix this?
If the crash of a script was the cause, fix the script so that it does not crash. Then this error is fixed, too. To find out if and why a script crashes, you need to debug it. For example you can check the PHP error log. Errors logged to STDERR normally go into the error handler of the FCGI.
I had the same problem with long-running scripts with the error messages
"Premature end of script headers: index.php" and "Connection reset by peer: mod_fcgid: error reading data from FastCGI server" in error_log.
After hours of testing this helps for me (CentOS 6, PHP-FPM 7, Plesk 12.5.30):
edit the config file:
/etc/httpd/conf.d/fcgid.conf
Set a higher running time. In my case 600 seconds
create the new entry:
FcgidBusyTimeout 600
adapt following entries:
FcgidIOTimeout 600
FcgidConnectTimeout 600
restart httpd:
service httpd restart
In CentOS releases suexec is compiled to run only in /var/www. If you try to set a DocumentRoot somewhere else you have to recompile it - the error in apache log are:
(104)Connection reset by peer: mod_fcgid: error reading data from FastCGI server
Premature end of script headers: php5.fcgi
Just install php5-cgi
in debian
sudo apt-get install php5-cgi
in Centos
sudo yum install php5-cgi
Check /var/lib/php/session and its permissions. This dir should be writable by user so the session can be stored
As already mentioned this could be happening due to fcgi handler permission issues. If you're using suexec - don't forget to check if apache has this module enabled.
I increased max execution time to 600 seconds job done !
If you're on a shared server like me the host said it was a result of hitting memory limits, so they kill scripts which results in the "Premature end of script headers" seen in this error. They referred me to this:
https://help.dreamhost.com/hc/en-us/articles/216540488-Why-did-procwatch-kill-processes-on-my-Shared-serv
Given an increase in memory, the issues went. I think a backup plugin Updraft on wordpress was perhaps over zealous in its duty/settings.
In my case I was using a custom extension for my PHP files and I had to edit /etc/apache2/conf-available/php7.2-fpm.conf and add the following code:
<FilesMatch ".+\.YOUR_CUSTOM_EXTENSION$">
SetHandler "proxy:unix:/run/php/php7.2-fpm.sock|fcgi://localhost"
</FilesMatch>
I've tried the majority of answers that I've found on this issue. My issue was with wp-cron.php executing a particular function.
I'm working on Plesk CentOS7, Apache server.
I used this related question and suggested answer to help me find out how to adjust the fcgid.conf memory limit utilizing the command line.
Upon trying to troubleshoot the limits on the fcgid.conf file (/etc/httpd/conf.d/fcgid.conf) and restarting apache gracefully, I found that there was no change.
After seeing that other cron jobs were running properly, I decided to refer back to my function declared in functions.php and found that some of the arguments declared were not being specified properly, so there was a loop occurring that would eventually lead to the timeout.
Upon fixing this and running the cron again, it ran as it should.
Hope this helps someone else in a similar position!
I got the same problem (with Plesk 12 installed).
However, when i switched from execute PHP as FastCGI to Apache Module the website worked.
Checked my suexec log:
$ cd /var/log/apache2/
$ less suexec.log
When you find something like this:
[2015-03-22 10:49:00]: directory is writable by others: (/var/www/cgi-bin/cgi_wrapper)
[2015-03-22 10:49:05]: uid: (10004/gb) gid: (1005/1005) cmd: cgi_wrapper
try this commands
$ chown root:root /var/www/cgi-bin/cgi_wrapper
$ chmod 755 /var/www/cgi-bin/cgi_wrapper
$ shutdown -r now
as root.
I hope it can help you.

Categories