Web pages not displaying correctly/500 internal se

28 posts / 0 new
Last post
#1 Mon, 08/25/2008 - 09:19
Berilac

Web pages not displaying correctly/500 internal se

Have just setup 3 web domains and have set up within Virtualmin.

When I type in an address it displays correctly, well 1 does. Am awaiting a response from my ISP about the other 2. So not to bothered about them.

The one that displays is http://www.letmemindyourchild.co.uk

The problem is when I am trying to install some scripts. Gallery, wordpress etc, I am not able to go to the web address quoted at the end to complete the installation. Comes up with 500 internal server error.

Any ideas as were to start to look for a solution?

I have heard and read that these 500 errors are a nightmare to resolve. Just my luck. I am wondering if this is a php problem.

Have looked in the apache error log and the only error that is displayed is: Premature end of script headers: index.php

Does this even when accessing via localhost to, if that makes any difference.<br><br>Post edited by: Berilac, at: 2008/08/25 09:21

Mon, 08/25/2008 - 10:12
andreychek

Howdy,

Two questions for you:

1. Is there any other errors related to the problem in the error_log, or is the &quot;premature end of script headers&quot; the only thing you see?

2. During the installation of the apps, Virtualmin outputs various information about what's going on.

Do you see anything listed in that which could be a problem? For example, I've seen times where a warning specified in it ended up preventing it from working -- where the warning was a simple matter of installing or configuring X or Y.
-Eric

Mon, 08/25/2008 - 10:29 (Reply to #2)
Berilac

Thx for the quick reply andychek.

There was one other error, but I didnt think it related.
Have added error log for info, well last 20 lines.

No errors showed up on installation, just said at the bottom of the page, successfully installed gallery please continue to http://webpage.com/gallery/index.php to complete installation

Mon, 08/25/2008 - 10:32 (Reply to #3)
Berilac

Huh, attachment didnt add so here it is:

[Mon Aug 25 14:40:49 2008] [error] [client xx.xx.xxx.xx] File does not exist: /var/www/joking/public_html/favicon.ico
[Mon Aug 25 18:52:48 2008] [error] [client xx.xxx.xx.xxx] File does not exist: /var/www/joking/public_html/favicon.ico
[Mon Aug 25 19:05:55 2008] [error] [client xx.xxx.xx.xxx] File does not exist: /var/www/joking/public_html/favicon.ico
[Mon Aug 25 19:05:57 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
[Mon Aug 25 19:06:57 2008] [error] [client xx.xx.xxx.xx] Premature end of script headers: index.php
[Mon Aug 25 19:06:57 2008] [error] [client xx.xx.xxx.xx] File does not exist: /var/www/joking/public_html/favicon.ico
[Mon Aug 25 19:11:08 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
[Mon Aug 25 19:11:32 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
[Mon Aug 25 19:14:17 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
[Mon Aug 25 19:16:14 2008] [error] [client xx.xx.xxx.xx] Premature end of script headers: index.php
[Mon Aug 25 19:19:31 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
[Mon Aug 25 19:25:55 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
[Mon Aug 25 19:27:50 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
[Mon Aug 25 19:43:43 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
[Mon Aug 25 19:46:18 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
[Mon Aug 25 19:49:27 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php
[Mon Aug 25 19:54:20 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: install.php
[Mon Aug 25 19:56:32 2008] [error] [client xx.xx.xxx.xx] Premature end of script headers: install.php
[Mon Aug 25 20:02:59 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: install.php
[Mon Aug 25 20:03:06 2008] [error] [client xx.xxx.xx.xxx] Premature end of script headers: index.php

Mon, 08/25/2008 - 10:38 (Reply to #4)
andreychek

This forum is a bit like the cookie monster, except that it eats posts and attachments.

Your logfile attachment was just the latest casualty.

I suspect, as you mentioned, that there's a PHP issue lingering within your install scripts problem.

Would you mind if I logged into your system and looked around? If that's okay, you can email your login details to eric@virtualmin.com.

The other option is that you might want to verify that PHP itself is working, by creating a test PHP script. However, I could certainly do that for you.
-Eric

Mon, 08/25/2008 - 10:59 (Reply to #5)
Berilac

I must say I can give this site a 200% recommendation.

Its Bank holiday monday, well it is here, and the quickness of help is amazing, cant fault it.

Kev King

Mon, 08/25/2008 - 11:52 (Reply to #6)
andreychek

Okay, there's good news, and there's bad news :-)

The good news is that I do see the problem. In the main Apache error log, it shows this:

mod_fcgid: server /var/www/joking/public_html/test.php(1546) started
suexec policy violation: see suexec log for more details

And then, checking out the suexec log, it shows:

[2008-08-25 22:41:23]: uid: (UID/USERNAME) gid: (GID/GID) cmd: php5.fcgi
[2008-08-25 22:41:23]: command not in docroot (/var/www/USERNAME/fcgi-bin/php5.fcgi)

The SuExec related tools provided by Virtualmin are compiled with support to run under /home. The catch there is that they pretty much have to -- you'll get errors like you're seeing if they're run in a different environment, such as under /var/www.

I believe the only way you could run PHP scripts within /var/www is to switch the PHP execution mode to mod_php rather than CGI or FCGId.

You could do that by going into Server Configuration -&gt; Website Options, and then modify &quot;PHP script execution mode&quot;.

In a perfect world, that's less desirable (since all scripts run as Apache at that point), but that might be what you'd need to do if you like the current location of your DocumentRoot.

I hope that helps :-)
-Eric

Mon, 08/25/2008 - 11:59 (Reply to #7)
Berilac

Ah thank you Eric, or I could move my virtual servers and make default location /home in future. If that makes it easier to administer at a later date.

And there was me thinking I was being clever keeping all web stuff in one place.

Will have a think and see which route to take, later.

Once again thankyou Eric very prompt, excellent.

Mon, 08/25/2008 - 12:32 (Reply to #8)
Berilac

Ah, nope still same error.

Have re installed servers under the default virtualmin setting doc root /home

But still unable to complete installation as before, strange. Same error message, premature end of script headers: install.php

Mon, 08/25/2008 - 14:37 (Reply to #9)
andreychek

Howdy,

Well, it's a different error now showing up in the logfiles.

The &quot;command not found docroot&quot; error is gone -- but both fcgid and cgi die off running even a basic PHP test script (running PHP's phpinfo().

I'm struggling to figure out what's wrong with this -- so far as I can tell, the configuration looks good.

One of the biggest differences I can see between it and other Virtualmin systems is that you're running PHP from the dotdeb repo.

That, and for whatever reason, Virtualmin doesn't seem to have generated php.ini files in ~/etc/php5. But I attempted to account for that by have it look at the php.ini files in /etc/.

So, I suppose in an attempt to rule out the issue, would you consider installing the Virtualmin PHP package in place of the dotdeb package you have now?

If that doesn't work, it'll at least rule out a number of things. And that will give me some time to think of what else might be going on :-)
-Eric

Mon, 08/25/2008 - 14:59 (Reply to #10)
Berilac

Yes Eric, if we can get to the bottom of this great.

I included dotdeb because it was listed somewhere where I was reading up on something so added to expand my repo's. Will comment out if it is going to be an issue.

Probably different error's in log now because the doc root is now where it should be, I have set it to /home for virtual servers as per default and re-installed webs to that location. I should have mentioned that.

My wife will be chuffed if I can get her web site up and going for her.

And I can move onto the next problem, which will enevitably occur....

Kev King

Tue, 08/26/2008 - 02:41 (Reply to #11)
Berilac

Have had to get some sleep since first posting, but when I have tried this morning, login scripts are being requested to be downloaded and not giving an error now. Not sure if I am making progress or not on this. It must be a php problem but I have no idea as to where to start.

Well got to go to work now will look at it again later.

Default doc route for virtual servers is now /home as per virtualmin default setup. I was hoping that would be the cure all.

Kev King

Tue, 08/26/2008 - 05:34 (Reply to #12)
andreychek

Howdy,

Yeah, so, if you're using FCGId, your server produces an Internal Server error. If you're using standard CGI, it prompts to download the file as you're seeing now. I was switching between the two in trying to test it last night and probably left it on CGI (CGI removes some more variables).

The next thing to do would be to not only comment out the dotdeb repository, but to actually remove the dotdeb PHP5 packages, and install Virtualmin's PHP5 packages in their place.

I'm not certain they're the culprit, but I'm running low on ideas as to what else it may be!
-Eric

Tue, 08/26/2008 - 10:09 (Reply to #13)
Berilac

Right o, before I do that, just a quick bit of advice. I take it its just a case of &quot;apt-get remove --purge php5&quot;. I dont want to go and do anything silly and remove something by mistake. The server is working near normal at the moment, so dont want to really bugger it up, if you know what I mean.

Kev King

Tue, 08/26/2008 - 11:44 (Reply to #14)
andreychek

So, if you run this, you'll see a list of everything that you'll need to remove:

dpkg -l 'php5*'

I don't recall if your apt command will correctly remove all the other PHP5 related packages or not.

But, looking at that list on your system, I do see a number of PHP5 modules from multiple repositories mixed in there -- it's entirely possible PHP is failing due to that.

So the steps I'd take:

* Run your above &quot;remove&quot; command -- and balk if it offers to delete something not previously seen in your dpkg -l 'php5*' output :-) It should only be removing php5-* packages.
* Comment out the dotdeb repository in /etc/apt/sources.list
* Run apt-get update
* Run apt-get install php5 php-cli php5-cgi php5-common php5-mysql [and any others you want]
* Restart Apache

Try try try again! ;-)
-Eric

Tue, 08/26/2008 - 11:47 (Reply to #15)
andreychek

Erm, I forgot to add in my list above, that before installing any new php5 packages from the Debian or Virtualmin repositories, that you should re-run the dpkg -l 'php5*' command to verify that no php5 related packages are installed.

Make sure PHP5 is all good and un-installed before continuing!
-Eric

Tue, 08/26/2008 - 13:37 (Reply to #16)
Berilac

My god that was a bit of a bugger weedling out the last of the dotdeb entries. But all done, clean install of php5 and no signs of the dotdeb's using dpkg -l 'php5*'

reloaded Virtualmin and have gone to PHP page but it cant find any cofig files or route to them?, what one do I select to activate?

/etc/php5/apache/php.ini=Configuration for mod_php
/etc/php5/cgi/php.ini=Configuration for scripts run via CGI
/etc/php5/cli/php.ini=Configuration for command-line scripts

There are 3 there but none will save when that option is selected.

Sorry to be a pain.
Kev King

Tue, 08/26/2008 - 14:02 (Reply to #17)
andreychek

Here we go,

I went into Server Configuration -&gt; Website Options, and chose FCGId. That regenerated the PHP5 related files in the fcgi-bin dir, and now it works! It's pointing at your new PHP5 files now. I think the work you did to install the PHP5 from the other repository resolved it.

Also, choosing CGI in that same menu did the same for the files in the cgi-bin dir. So either one of those will work.

I put a test.php script in your DocumentRoot, you can go to YOURDOMAIN.com/test.php to see PHP run.

If you're trying to choose between the 3 configs you mentioned above, I'd go with the CGI related one.

Have a good one,
-Eric

Tue, 08/26/2008 - 14:03 (Reply to #18)
Berilac

Quick update, have just tried loading a script install web page and it has loaded as it should.
Its a bit late here now so have aborted installation for now and will complete tomorrow.

It looks promising though........will update fully in the morning.

Thanks for your time and patience Eric.

Wed, 08/27/2008 - 00:35 (Reply to #19)
Berilac

Yep tis still working this morning.

Just one small problem now, anything in /var/www will not display, ie phpmyadmin will wont load, just gives the option for downloading the php script.

And there is no php.ini in any of the 3 /etc/php5 directories, so none of those 3 options will save, because it cant see any config files. I must be missing something?
I have re-installed all the php5 stuff, or thought I had, but there must be something still missing?

Am nearly there with this one.

Wed, 08/27/2008 - 05:04 (Reply to #20)
andreychek

That's good news that it's working!

Regarding /var/www -- remember that you really did solve a problem by moving things to /home. PHP scripts are going to be run by SuExec, making them run as the user who owns the file. And SuExec only will work on /home.

What I did on my box was to make a dir under /home for those sorts of things -- along the lines of /home/apache. Then I set that up as the DocumentRoot for the default VirtualHost, rather than /var/www.

As to why the php.ini files are missing?

My best guess is that those are copied over when the users homedir is created. Since they didn't exist at that point, it wasn't able to copy them.

What I would do is this:

* mkdir /home/USERNAME/etc/php5
* cp /etc/php5/cgi/php.ini /home/USERNAME/etc/php5
* chown USERNAME:GROUPNAME /home/USERNAME/etc/php5
* chown USERNAME:GROUPNAME /home/USERNAME/etc/php5/php.ini

Where &quot;USERNAME&quot; and &quot;GROUPNAME&quot; are the user and group who owns that particular account / domain.
-Eric

Wed, 08/27/2008 - 10:31 (Reply to #21)
Berilac

I was wondering if that was the case with /var/www not now the default doc root. So will now have to use /home as the web directory, thats nothing major. Will just have to copy over those apps which were there.
But those are minor changes, at least things seem to be working now.

I really appreciate all your help, thank you.

Wed, 08/27/2008 - 11:19 (Reply to #22)
Berilac

Getting loads and loads of,
Cron &lt;xxxx@xxxxx&gt; /etc/webmin/virtual-server/collectinfo.pl e-mails stating:
sh: line 1: 26161 Segmentation fault /usr/bin/php5-cgi -v 2&gt;&amp;1 &lt;/dev/null
all with different seg fault numbers

Would this be something to do with the problem I have had? And does it mean there is still something amiss?

I was getting loads of them awhile back, but ignored them, thinking them non important. But since my recent problems, i think I should have took heed earlier.

Wed, 08/27/2008 - 14:10 (Reply to #23)
andreychek

Alright, so, looking at the command that's dieing above, it's trying to run this:

/usr/bin/php5-cgi -v

So when I try to run that on your system, I get the same error. Same problem even while running /usr/bin/php.

Digging a little deeper, it looks like the problem was based around two PHP extensions:

[code:1]
php5 -v
PHP Warning: Cannot load module 'PDO_ODBC' because required module 'pdo' is not loaded in Unknown on line 0
PHP Warning: Cannot load module 'pdo_pgsql' because required module 'pdo' is not loaded in Unknown on line 0
PHP 5.2.0-8+etch11 (cli) (built: May 10 2008 10:46:24)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2006 Zend Technologies
Segmentation fault
[/code:1]

Also, in looking at the strace output, it died fairly quickly after attempting to load those two extensions.

I moved the ini files that loads them from /etc/php5/conf.d to /root/php-ini.

Now when I run php from the command line, it runs successfully, without the segmentation fault.

So I believe that's working now!
-Eric

Wed, 08/27/2008 - 14:43 (Reply to #24)
Berilac

Excellent, that will save all that mail coming thank you.
Still problems with final install of for instance gallery tho. It goes, or went to step 5, mysql php not installed. But it is cuz I have checked apt-get and it is installed. No listing in php modules in server config tho of php5-mysql. Strange.
As I have deleted all servers and started from scratch again to cancel out any misconfiguration, but some problems are still popping up.
Have noted some discrepencies in /etc/apache2/mods-available and /etc/apache2/mods-enabled.
Looks like not everything has installed or installed to the desired directories? Will missing or non loaded mods in this directory cause php to not fully function?
This is driving me potty, one problem solved, just leads to another. I suppose this is what real computing is all about :)

Kev King

Wed, 08/27/2008 - 15:13 (Reply to #25)
andreychek

For whatever reason, some ini files are missing from /etc/php5/conf.d, it looks like.

I created 2 of those, gd.ini and mysql.ini, which should get your gallery install going. Those ini files simply load the mysql and gd extensions.
-Eric

Wed, 08/27/2008 - 15:16 (Reply to #26)
Berilac

yeah just noticed, once again thank you Eric, excellent service. Far beyond what I have experienced elsewhere or expected.

Can not recommend Virtualmin highly enough.

Thu, 08/28/2008 - 06:48 (Reply to #27)
Berilac

Eric, just a quick update on the situation.

All 3 webs working and scripts have been installed on all 3 and are working properly.

Excellent, I am a happy bunny, and will celebrate with a few beers tonight.

Many thanks team for your efforts
Kev King

Topic locked