Moved Wordpress Website, Now it Cannot modify header information - php

I moved my Wordpress-based website from an Apache server to a Nginx server, and something, somewhere went wrong.
I'm getting a mangled website (as in: CSS isn't being loaded so the lay-out is completely wrong). When I try to access /wp-admin to log in, I get:
Warning: Cannot modify header information - headers already sent by (output started at /var/hpwsites/u_potgieter/website/html/webroot/wp-config.php:1) in /var/hpwsites/u_potgieter/website/html/webroot/wp-login.php on line 390
Warning: Cannot modify header information - headers already sent by (output started at /var/hpwsites/u_potgieter/website/html/webroot/wp-config.php:1) in /var/hpwsites/u_potgieter/website/html/webroot/wp-login.php on line 403
I was also getting error messages from WP Super Cache plugin, but I was able to disable that from PHPmyAdmin.
Looking at the website (www.potgieter.nl), and checking firebug, I get the impression the PHP isn't being executed properly. As far as I understand Wordpress, it uses PHP to call things like posts, pages and CSS. Now the text, Javascript and images are being called correctly and are displayed. Even the slider works. However, the sizing, positioning and color are all horribly wrong.
I ran ps -ef from the SSH, and it showed PHP is running:
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 Jun17 ? 00:00:30 /usr/lib/systemd/systemd --switched-root --system --deserialize 21
u_potgi+ 19752 19744 0 16:29 ? 00:00:00 sshd: u_potgieter#pts/0
u_potgi+ 19753 19752 0 16:29 pts/0 00:00:00 -bash
u_potgi+ 19924 19919 0 16:44 ? 00:00:00 sshd: u_potgieter#notty
u_potgi+ 19925 19924 0 16:44 ? 00:00:00 /usr/libexec/openssh/sftp-server
u_potgi+ 20774 19753 0 17:08 pts/0 00:00:00 php
u_potgi+ 20781 20776 0 17:10 ? 00:00:00 sshd: u_potgieter#pts/1
u_potgi+ 20782 20781 0 17:10 pts/1 00:00:00 -bash
u_potgi+ 20804 20782 0 17:10 pts/1 00:00:00 ps -ef
I'm runnning PHP7
~]$ php -v
PHP 7.0.5 (cli) (built: Apr 19 2016 12:44:23) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
I have seen the question linked to below, and I've tried to follow the steps outlined there as best I could, but to no avail.
How to fix "Headers already sent" error in PHP
I am looking for the reason the website isn't loading properly, so I can start looking for a way to solve the issue.
Any and all help would be greatly appreciated.
Edit: this is the first bit of my wp-config.php. There is no whitespace on line one, nor is there any other HTML before the <?php tag.
<?php
/**
* The base configurations of the WordPress.
*
* This file has the following configurations: MySQL settings, Table Prefix,
* Secret Keys, WordPress Language, and ABSPATH. You can find more information
* by visiting {#link http://codex.wordpress.org/Editing_wp-config.php Editing
* wp-config.php} Codex page. You can get the MySQL settings from your web host.
*
* This file is used by the wp-config.php creation script during the
* installation. You don't have to use the web site, you can just copy this file
* to "wp-config.php" and fill in the values.
*
* #package WordPress
*/

I'm not sure how well you checked the question you linked because it's answers are quite clear.
The error message is also clear wp-config.php:1
You are looking for something that will cause output to be produced on line 1 of wp-config.php
You probably have whitespace before the opening php tag
eg
<!-- empty line here -->
<?php
...
..

Related

Local IIS installation doesn't show phpinfo page

I've installed PHP on my windows 10 computer, and started IIS.
But when I browse to http://localhost/phpinfo.hml the page is completely blank.
And if I look at the file view in IIS, it seems that it's not aware that the file exists.
I've verified that the phpinfo.html file is in the right place:
ls -l C:\inetpub\wwwroot\phpinfo.html
Directory: C:\inetpub\wwwroot
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a---- 7/16/2020 8:54 AM 72 phpinfo.html
And has the right contents:
PS C:\inetpub\wwwroot> cat .\phpinfo.html
<?php
// Show all information, defaults to INFO_ALL
phpinfo();
?>
PHP is installed:
php --version
PHP 7.4.1 (cli) (built: Dec 17 2019 19:23:59) ( NTS Visual C++ 2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
I gave my windows user full access to that directory. What am I doing wrong? How can I get this working?
If you want to show phpinfo page, you need to change phpinfo.html to phpinfo.php.
And you also need to handle PHP requests by using IIS Manager, you can set this in Handler Mappings.
More information about how to configure IIS to Handle PHP Requests you can refer to this link: Configure IIS to Handle PHP Requests

PHP SDK won't run my php-cgi

I'm trying get the helloworld example for the Google Appengine PHP SDK working, but I can't seem to get the dev_appserver to even run. This is the command line I use and the error I get:
$ /opt/google-appengine-php/dev_appserver.py --php_executable_path=/usr/bin/php-cgi src
INFO 2013-06-14 02:50:09,070 sdk_update_checker.py:244] Checking for updates to the SDK.
INFO 2013-06-14 02:50:09,331 sdk_update_checker.py:260] Update check failed: HTTP Error 404: Not Found
INFO 2013-06-14 02:50:09,458 api_server.py:138] Starting API server at: http://localhost:39069
INFO 2013-06-14 02:50:09,647 dispatcher.py:164] Starting server "default" running at: http://localhost:8080
INFO 2013-06-14 02:50:09,650 admin_server.py:117] Starting admin server at: http://localhost:8000
ERROR 2013-06-14 02:50:09,717 php_runtime.py:199] The PHP runtime is not available because: No input file specified.
The output from php-cgi -v is:
PHP 5.4.16 (cgi-fcgi) (built: Jun 7 2013 05:55:42)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
The output from whereis php-cgi is:
php-cgi: /usr/bin/php-cgi
I looked at the php_runtime.py file but I can't even find the string No input file specified so I'm stumped!
Anyone have any idea what the problem is?
EDIT: I just tried running fgrep -r 'No input file specified' * in the App Engine directory and nothing shows up!!!
EDIT 2: It seems the message No input file specified comes from the PHP interpreter, no the App Engine SDK. But I still have no idea why?! the app.yaml and helloworld.php files are in the same directory and are copied from the tutorial page.
It seems the problem is the way I installed my system. My /home directory is actually a symbolic-link to /var/home (I have two partitions: / and /var) but PHP has a directive to limit where it loads files from, open_basedir. By default it includes /home but PHP resolves symlinks so all my files were coming from /var/home and /var (or anything below) are not included.
So the solution is to replace /home with /var/home in the open_basedir directive of my /etc/php/php.ini file.
EDIT: Also, since I installed the AppEngine PHP SDK in /opt/google-appengine-php I had to add that directory to open_basedir too.

PHP fopen() returns NULL, always

I'm attempting to open a file for parsing (a binary file), however no matter what fopen() is always returning NULL.
I've ruled out nearly everything to the point where I have a test script with simply:
<?php
$idx = fopen('/usr/home/username/web/appname/dev/www/debug/18194001.idx','r');
trigger_error(var_export($idx,true));
exit();
The output from trigger_error(var_export()); is:
[31-Mar-2013 16:30:34 UTC] PHP Notice: NULL in /usr/home/username/web/appname/dev/www/debug/ajax.idx.php on line 3
No matter what flags I specify for the second fopen() option, I get the same result.
Now, the obvious question is whether or not the file exists, and do I have permissions to read it? The answer to both of those is yes. I've used the relative path and absolute path, both read the file correct. file_get_contents() also reads the file with no issues.
is_readable() and file_exists() both return true
The output of ls -lah for that file is:
-rwxrwxrwx 1 username username 2.0K Mar 30 15:02 18194001.idx
Where 'username' matches the username the web server process and PHP (lighttpd and php-fpm) are running under. The parent directory also has read/read/read rights for user/group/all.
I've tried other files, and I've noticed pretty much anything I throw at fopen is returning a NULL value.
Help?
PHP info:
PHP 5.4.6 (cli) (built: Oct 10 2012 10:43:19)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
with XCache v2.0.1, Copyright (c) 2005-2012, by mOo
Lighttpd info:
lighttpd/1.4.31 (ssl) - a light and fast webserver
Build-Date: Sep 7 2012 15:38:20
OS:
FreeBSD hostname.hostname.hostname 8.2-RELEASE FreeBSD 8.2-RELEASE #0: Thu Feb 17 02:41:51 UTC 2011 root#mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC amd64
You cannot meaningfully var_export a fopened resource, you can however var_dump it:
$ php -r 'var_export(fopen("/tmp/a","w+"));'
NULL
$ php -r 'var_dump(fopen("/tmp/a","w+"));'
resource(5) of type (stream)
... because var_export() is meant to 'restore' a variable in PHP script, and resources require more setup then possible in instantiating a simple variable. If you want to know whether the fopen succeeded, just check it is not false.
$ php -r 'var_export(fopen("/this/does/not/exist","w+"));'
... some errors...
false
In other words, the fact you get NULL from a var_export means the fopen actually was successful.

Apache segfault by cakePHP website

Without any -apparent- reasons, one of my cakePHP websites (v1.3.11) has stopped working (showing a "no data received" page in chrome - error 324) but the other is still fine -for the moment at least-.
/var/log/apache2/error.log shows a [notice] child pid 8502 exit signal Segmentation fault (11)
and /var/log/messages shows kernel: [15482058.932226] apache2[8502]: segfault at 7fff7f14fb58 ip 7f1b9d886e55 sp 7fff7f14fb60 error 6 in libphp5.so[7f1b9d576000+588000]
Here's my php -v
PHP 5.2.6-1+lenny13 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 1 2011 16:01:01)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
I absolutely have no idea on what heppened, so any idea is welcome.
EDIT:
It looks like the render() function in the /cake/libs/controller/controller.php is doing an infinite loop. Any ideas why this is happening? (it's happening on all the pages of the website and no code has changed lately...)
I had the same issue with cakephp 2.2.1.
I've resolved the issue by adding flush() in App.php's load function.
public static function load($className) {
if (!isset(self::$_classMap[$className])) {
return false;
}
flush();
...
I just downgraded my framework to what it was before thanks to a backup of those files I've done just before the updated and everything's fine now again.
Maybe something was wrong during the upload or something is not compatible with the latest version of the framework. I'll do some tests later about it and I'll comment on this "solution".
on core.php
Configure::write('debug',0);
I wonder if this might be regression in the last security update of Debian. I get very similar errors as you have, but we are not running cake. If we can confirm this, we should file a bug at Debian.
/var/log/messages[39144630.700032] apache2[13693]: segfault at 7fffff7fdfb8 ip 7f5195606a6a sp 7fffff7fdf50 error 6 in libphp5.so[7f519535c000+588000]
/var/log/apache2/error.log[error] child died with signal 11
$ php -v
PHP 5.2.6-1+lenny13 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 1 2011 16:01:01)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies
FYI I had the same problem today. Turning off debug kit solved it for me
I suddenly got this problem after I added post editing to the blog tutorial on a local virtual host.
For me, this problem went away when I went back through my files and found a syntax mistake. Once I fixed the syntax, it worked just fine.
For what it's worth, turning off DebugKit solved this problem for me in CakePHP 2.3.5. Except for adding DebugKit, the CakePHP installation is completely fresh. I got the same error 324 in Chrome as mentioned in the original post.

LAMP / CakePHP quirk - works locally, not on remote server. Debugging Tips?

DISCLAIMER - I am total PHP noob - looking for some help/tips on how to debug this problem...
I have a PHP/CakePHP based app running on Linux/CentOS and MySQL.
Its also running on my local dev machine (OSX Snow Leopard).
One small part of the app however is behaving inconsistently between the two.
I have copied the DB and the PHP code from the server to my local machine - so pretty sure they are in sink. Note the app was originally developed elsewhere and then deployed to the server.
The different is that there is a master/detail type page - on both sites the master part works fine, but the detail part is only working for my local/OSX version.
I have checked the DB and the detail records seem to be present as expected.
The PHP version is slightly different.
Linux Server:
HP: Error parsing /usr/local/lib/php.ini on line 803
PHP 5.2.16 (cli) (built: Mar 1 2011 11:48:38)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator
with the ionCube PHP Loader v3.3.20, Copyright (c) 2002-2010, by ionCube Ltd.
Server version: Apache/2.2.17 (Unix)
Server built: Mar 1 2011 11:42:56
Cpanel::Easy::Apache v3.2.0 rev5291
OSX Local:
PHP 5.3.3 (cli) (built: Aug 22 2010 19:41:55)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
Server version: Apache/2.2.15 (Unix)
Server built: Jul 1 2010 17:16:33
I have tried restart Apache, in case it was a caching issue. I have tried changing master details via mysql command line and those changes are being shown.
Tried turning on display_errors/display_startup_errors - but nothing is being shown.
Wonder if there are any CakePHP debug tips... perhaps should look into that.
My plan is to install the app on another server to see if that works and/or helps identify the difference/issue.
The PHP code that seems to be the issue is this (its in one of the cakePHP controllers):
$carInsuranceQuoteRequest = $this->CarInsuranceQuoteRequest->find('first', array(
'conditions' => array(
'CarInsuranceQuoteRequest.id' => $id,
) ,
'contain' => array(
'Company' => array(
'Attachment'
),
'CarInsuranceVehicleType',
'CarInsuranceVehicleMake',
'CarInsuranceVehicleModel',
'CarInsuranceVehicleVersion',
'CarInsuranceCoverageType',
'CarInsuranceQuoteResponse' => array(
'CarInsuranceQuoteSite'
),
),
));
The quote request object is being returned ok on both installs. But the quote response object is always empty on the linux box, even though they seem to be ok in the mysql db. The responses are being displayed fine under OSX.
The PHP error on line 803 is
; url_rewriter.tags: (ini file field description not available)
url_rewriter.tags = a=href,area=href,frame=src,input=src,form=,fieldset=
Thanks in advance for any tips, Chris
FWIW - my problem was due to the cakePHP models being wrong and so it wasnt able to navigate the relations. I had changed the mysql table. For some reason it got over the issue on my local machine.
Chris,
Try turning on CakePHP debug output in your app. In the file app/config/core.php you should find a line like this setting the CakePHP debug level:
Configure::write('debug', 0);
Change it to:
Configure::write('debug', 1);
or a higher value. This should produce some error output and get you going in the right direction in narrowing down the source of your problems.
Remember to set it back to 0 for a production configuration. The documentation for this is as follows:
/**
* CakePHP Debug Level:
* * Production Mode:
* 0: No error messages, errors, or warnings shown. Flash messages redirect.
*
* Development Mode:
* 1: Errors and warnings shown, model caches refreshed, flash messages halted.
* 2: As in 1, but also with full debug messages and SQL output.
* 3: As in 2, but also with full controller dump.
*
* In production mode, flash messages redirect after a time interval.
* In development mode, you need to click the flash message to continue.
*/
Also remember to check your Apache error log file for any helpful output.

Categories