Server side includes not working on .php files
Due to the CMS framework we are using (OpenCart), we had to go with server side includes (SSI) to load text content on our webpages (which are dynamic PHP). No doubt php_include would be ideal, however the page templates does not allow php for security reasons. At any rate, we are able to get SSI to work on .html pages, but not on .php. The Apache configuration files and loaded modules are listed below. Any suggestions would be greatly appreciated!
Example code for the SSI on an .html page
.htaccess (public_html)
/etc/httpd/conf/httpd.conf
Loaded Modules
.htaccess (public_html)
Options +Includes
AddOutputFilter INCLUDES .html .php/etc/httpd/conf/httpd.conf
# Further relax access to the default document root:
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.4/mod/core.html#options
# for more information.
#
Options +Includes
AddOutputFilter INCLUDES .php .html
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
XBitHack on
#
# Controls who can get stuff from this server.
#
Require all granted
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
DirectoryIndex index.html index.php
SetHandler application/x-httpd-php
Loaded Modules
core_module (static)
so_module (static)
http_module (static)
mpm_prefork_module (shared)
systemd_module (shared)
cgi_module (shared)
access_compat_module (shared)
actions_module (shared)
alias_module (shared)
auth_basic_module (shared)
auth_digest_module (shared)
authn_core_module (shared)
authn_dbd_module (shared)
authn_dbm_module (shared)
authn_file_module (shared)
authz_core_module (shared)
authz_dbd_module (shared)
authz_groupfile_module (shared)
authz_host_module (shared)
authz_user_module (shared)
autoindex_module (shared)
dav_module (shared)
dav_fs_module (shared)
dav_lock_module (shared)
dbd_module (shared)
deflate_module (shared)
dir_module (shared)
env_module (shared)
expires_module (shared)
file_cache_module (shared)
filter_module (shared)
headers_module (shared)
include_module (shared)
log_config_module (shared)
log_forensic_module (shared)
logio_module (shared)
mime_module (shared)
mime_magic_module (shared)
negotiation_module (shared)
proxy_module (shared)
proxy_fcgi_module (shared)
proxy_http_module (shared)
proxy_wstunnel_module (shared)
remoteip_module (shared)
rewrite_module (shared)
setenvif_module (shared)
slotmem_shm_module (shared)
socache_dbm_module (shared)
socache_shmcb_module (shared)
socache_redis_module (shared)
speling_module (shared)
status_module (shared)
unique_id_module (shared)
unixd_module (shared)
userdir_module (shared)
bwlimited_module (shared)
ssl_module (shared)
security2_module (shared)
ruid2_module (shared)-
Hey there! Would you happen to be running LiteSpeed or just Apache? This is a known limitation of the LiteSpeed server: article to switch to Apache from LiteSpeed, but it would not work.
0 -
The daemon is actually "lsws" and you would likely know if you were running LiteSpeed as there is an additional fee for that tool. It would likely be best to create a ticket so we can see this behavior on your machine. 0 -
OK. We have the LiteSpeed PHP extensions enabled under EasyApache4: php71-php-litespeed php72-php-litespeed php73-php-litespeed php74-php-litespeed That wouldn't affect this right? I'll go ahead and create a ticket in the mean time. 0 -
I wouldn't expect those to be related to the issue. If you can post the ticket number here once that is submitted I can follow along on my end and make sure the thread gets an update once we have a resolution. 0 -
I wouldn't expect those to be related to the issue. If you can post the ticket number here once that is submitted I can follow along on my end and make sure the thread gets an update once we have a resolution.
Ticket #944365440 -
Thanks for that - I'm following along with that ticket on my end now. 0 -
Solution: 1. WHM " MultiPHP Manager change PHP handler from cgi
todso
for active PHP version 2. WHM " Software " EasyApache4 " Apache Modules enablemod_ruid2
module 3. WHM " Restart Services " HTTP Server (Apache) restart Apache 4. WHM " MultiPHP INI Editor " Editor Mode changeoutput_buffering
fromOff
to4096
or higher (Production Value: 4096)0 -
Thanks for posting the details! 0 -
Does anyone have suggestions for the following error message? PHP Warning: Response::output(): Headers already sent. You cannot change the session module's ini settings at this time in /home/admin_user/public_html/system/library/response.php on line 118
We tried addob_start();
to the index.php file, however it still shows these errors in the log.0 -
Does anyone have suggestions for the following error message?
PHP Warning: Response::output(): Headers already sent. You cannot change the session module's ini settings at this time in /home/admin_user/public_html/system/library/response.php on line 118
We tried addob_start();
to the index.php file, however it still shows these errors in the log.
You Might try reading this answer0 -
OK. The article references that the
echo
function produces 'output' which can terminate sending HTTP headers. The warning/error message indicates line 118 in the response.php file below is the issue.Response::output(): Headers already sent. You cannot change the session module's ini settings at this time in /home/admin_user/public_html/system/library/response.php on line 118
class Response { private $headers = array(); private $level = 0; private $output; /** * Constructor * * @param string $header * */ public function addHeader($header) { $this->headers[] = $header; } /** * * * @param string $url * @param int $status * */ public function redirect($url, $status = 302) { header('Location: ' . str_replace(array('&', "\n", "\r"), array('&', '', ''), $url), true, $status); exit(); } /** * * * @param int $level */ public function setCompression($level) { $this->level = $level; } /** * * * @return array */ public function getOutput() { return $this->output; } /** * * * @param string $output */ public function setOutput($output) { $this->output = $output; } /** * * * @param string $data * @param int $level * * @return string */ private function compress($data, $level = 0) { if (isset($_SERVER['HTTP_ACCEPT_ENCODING'>) && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'>, 'gzip') !== false)) { $encoding = 'gzip'; } if (isset($_SERVER['HTTP_ACCEPT_ENCODING'>) && (strpos($_SERVER['HTTP_ACCEPT_ENCODING'>, 'x-gzip') !== false)) { $encoding = 'x-gzip'; } if (!isset($encoding) || ($level < -1 || $level > 9)) { return $data; } if (!extension_loaded('zlib') || ini_get('zlib.output_compression')) { return $data; } if (headers_sent()) { return $data; } if (connection_status()) { return $data; } $this->addHeader('Content-Encoding: ' . $encoding); return gzencode($data, (int)$level); } /** * */ 108 public function output() { 109 if ($this->output) { 110 $output = $this->level ? $this->compress($this->output, $this->level) : $this->output; 111 112 if (!headers_sent()) { 113 foreach ($this->headers as $header) { 114 header($header, true); 115 } 116 } 117 118 echo $output; } } }
Any thoughts? Seems like this issue only presented itself when we updated PHP from 7.2 to 7.3 a few weeks back. We never had these error messages before.
Just wondering if you could update to 7.4 might be more stable than 7.3. If not I would suggest try to switch back to 7.2 and see if the issue persists now. sorry I don"t have much more to offer you in the way ofhelp. Hopefully @cPRex might be able to tomorrow when he is on the forums :)0 -
Just wondering if you could update to 7.4 might be more stable than 7.3. If not I would suggest try to switch back to 7.2 and see if the issue persists now. sorry I don"t have much more to offer you in the way ofhelp. Hopefully @cPRex might be able to tomorrow when he is on the forums :)
Updated to 7.4 earlier today, but the error messages are still there. The CMS recommends using 7.4, so I"ll probably just have to start the witch hunt for any files that may have an extra space before "0 -
What is the name of the cms you are using ? If you don"t mind me asking 0 -
What is the name of the cms you are using ? If you don"t mind me asking
OpenCart0 -
I'm not familiar with any issues on the PHP side of things that would cause those errors. 0 -
This wouldn't be a reason for the "headers already sent" error would it? Google Font GET request failing with a 403? -04-22 at 16.28.25.png">77457 0 -
This wouldn't be a reason for the "headers already sent" error would it? Google Font GET request failing with a 403? 77457
Never mind, ignore that.0
Please sign in to leave a comment.
Comments
21 comments