View previous topic :: View next topic |
Author |
Message |
one_time -
Joined: 30 May 2006 Posts: 8
|
Posted: Tue May 30, 2006 3:39 pm Post subject: GZIP & HTML compression |
|
|
Perhaps someone could help me out with this...
I am trying to enable gzip compression for html files and I cannot get it to work. I have done a search of the forums and found some tips, followed them, but when I enable gzip for html, my page comes up blank.
These are the steps I have taken:
1. I created a file called gzip.php with the following code:
Code: | <?php
ob_start("ob_gzhandler");
?> |
2. I saved this file to my /htdocs ... directory.
3. I opened up my php.ini file located in C:\Windows and edited auto_prepend_file to look like this:
Code: | auto_prepend_file = "F:\Abyss Web Server\htdocs\gzip.php" |
***note: I seem to have 2 php.ini files... one in the PHP root directory and one in C:\Windows. I edited them both. I'm not sure if this matters.
4. I went into the server console and 'Configure' --> 'Scripting Parameters' --> under 'Interpreters' (Fast CGI \ php-cgi.exe) - 'Edit' (the pencil icon) --> under 'Associated Extensions' - 'Add" --> 'Extension' = 'html'.
5. Restarted server, reloaded page and it's blank. If I remove the 'html' extension it loads properly again.
Am I adding the extension to the wrong interpreter? Fast CGI is the only option I have available.
Any help would be greatly appreciated.
one_time |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue May 30, 2006 5:27 pm Post subject: |
|
|
I should have warned everyone that for some reason this method does not
work. I apologize for writing the tutorial like that.
To compress your HTML files, you will need to put the PHP code at the top of
the HTML file's source before the HTML starts, and declare "html" and "htm"
as one of your associated extensions for PHP.
Here's an example of a compressed HTML file.
Code: | <?php
ob_start("ob_gzhandler");
?>
<html>
<head>
<title>Compressed Page</title>
</head>
<body bgcolor="white">
<h3>This page uses Gzip Compression</h3>
</body>
</html>
|
Note: For XHTML files, PHP won't interpret them without first escaping some of
the characters in the <?xml part of the source code. Hope this helps. |
|
Back to top |
|
 |
one_time -
Joined: 30 May 2006 Posts: 8
|
Posted: Tue May 30, 2006 5:41 pm Post subject: |
|
|
Thanks for your reply. I did as you suggested and insterted the php code into my index.html --
Code: | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?php
ob_start("ob_gzhandler");
?>
<html xmlns="http://www.w3.org/1999/xhtml"> |
I added the html and htm extensions to abyss using the same method as in my previous post, but unfortunatley I get the same result as before - a blank page.
Perhaps someone could post a step-by-step process for enabling gzip for html? (gzip for dummies haha...) I understand the basics, but I really rely on what the pros post in these forums to keep my server functioning. I'm not an expert by any means.
Thanking everyone in advance. |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue May 30, 2006 5:49 pm Post subject: |
|
|
Have you tested my example to see if it works? You didn't add the PHP code
at the very top before the HTML code. Try my example first. |
|
Back to top |
|
 |
one_time -
Joined: 30 May 2006 Posts: 8
|
Posted: Tue May 30, 2006 6:12 pm Post subject: |
|
|
Thanks for the reply.
I moved the position of the php code to the top of the index:
Code: | <?php
ob_start("ob_gzhandler");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> |
still get a blank page.
Heres a link to a screenshot of my console configuration:
http://ennui-anomie.no-ip.org/images/capture_30052006_130523.gif
Thanks |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue May 30, 2006 6:34 pm Post subject: |
|
|
Is your server running on a Windows Operating System? I noticed the Abyss
icon at the top of your Mac OS X menu. You're using a Windows PHP path in
a Mac OS X Operating System environment from what I see.
Make sure the Zlib extension is enabled. Check your phpinfo() script to see
if you see ZLib in the list of PHP extensions. Hope this helps you. |
|
Back to top |
|
 |
one_time -
Joined: 30 May 2006 Posts: 8
|
Posted: Tue May 30, 2006 6:40 pm Post subject: |
|
|
I'm running Windows XP... it's just a mac style. I looked into escape characters for XHTML, but I can't see anything that would require one. |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue May 30, 2006 6:43 pm Post subject: |
|
|
Ok, did you try my example above to see if it works? I can help you debug
the XHTML if you want, but please test my example and tell me if it worked. |
|
Back to top |
|
 |
one_time -
Joined: 30 May 2006 Posts: 8
|
Posted: Tue May 30, 2006 6:56 pm Post subject: |
|
|
Ahhh... OK, gotcha.
I created a basic HTML file with the code you provided. The message displays correctly in Dreamweaver. But again, if I point the broweser to it:
http://ennui-anomie.no-ip.org/Untitled-1.html [deleted]
I get a blank page. If I try to "View Source' within the browser, it comes up blank.
BTW, I'm not running on port 80 if that matters.
Thanks for all your help so far... much appreciated.
Last edited by one_time on Tue May 30, 2006 7:22 pm; edited 1 time in total |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue May 30, 2006 7:19 pm Post subject: |
|
|
Try this script: info.php
Code: | <?php
phpinfo();
?>
|
Do you see Zlib in the list of PHP extensions? |
|
Back to top |
|
 |
one_time -
Joined: 30 May 2006 Posts: 8
|
Posted: Tue May 30, 2006 7:40 pm Post subject: |
|
|
I opened up phpinfo.php in my F:\Abyss Web Server\scripts\phpMyAdmin\ directory:
Code: | <?php
/* $Id: phpinfo.php,v 2.5 2005/11/22 11:58:37 cybot_tm Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/**
* Gets core libraries and defines some variables
*/
define( 'PMA_MINIMUM_COMMON', true );
require_once('./libraries/common.lib.php');
/**
* Displays PHP information
*/
if ( $GLOBALS['cfg']['ShowPhpInfo'] ) {
phpinfo();
}
?>
|
I assume I should be looking for zlib here, didn't see it. I added this line:
Code: | */
define( 'PMA_MINIMUM_COMMON', true );
require_once('./libraries/common.lib.php');
require_once('./libraries/zip.lib.php');
/** |
Though I have no idea if that's the right syntax. I then added the info.php script to my index:
Code: |
<?php
ob_start("ob_gzhandler");
?>
<?php
phpinfo();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head> |
Still nothing. I'm not sure if I did all of this correctly though... |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Tue May 30, 2006 8:11 pm Post subject: |
|
|
Just use the code <?php phpinfo(); ?> in a new file called info.php, and browse
to this file using your website's address. http://localhost/info.php
Don't use any other script besides the one I already gave you. Now tell me if
the ZLib PHP extension is listed, better yet, put it on your server so that I can
access it myself to see if it's installed. |
|
Back to top |
|
 |
one_time -
Joined: 30 May 2006 Posts: 8
|
Posted: Tue May 30, 2006 9:57 pm Post subject: |
|
|
Good News!!!!
It occured to me that the problem may be with PHP. I was briefly toying around with WordPress recently (hated it), and I got to thinking that my PHP installation may be corrupted by it. After poking around a bit more, I realized I couldn't get php.info to display or even get PhpMyAdmin to run... not a good sign. So I simply re-installed PHP according to TrustAbyss's tutorial
http://www.trustabyss.com/php_install.html
and bingo! works like a charm.
After re-installing, I added the original code:
Code: | <?php
ob_start("ob_gzhandler");
?> |
To the top of my index.html.
I was able to access info.php via local host which indicated that zlib was present. I added the html and htm extensions to Abyss and my page displays now.
I then checked out the page at
http://www.websiteoptimization.com/services/analyze/
and it confirms that indeed my page has HTTP compression!
Thank you for all your help. I'm still learning all this stuff, so it's nice to have someone around patient enough to help out.
Great support for a free piece of software!!
one_time |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
|
Back to top |
|
 |
one_time -
Joined: 30 May 2006 Posts: 8
|
Posted: Tue May 30, 2006 11:14 pm Post subject: |
|
|
Oh yeah... I forgot... I also needed to enable
Code: | zlib.output_compression = On |
in php.ini
Cheers!
one_time |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Wed May 31, 2006 5:39 am Post subject: |
|
|
You don't have to enable that option. The page will compress even if it is set
to "zlib.output_compression = Off." |
|
Back to top |
|
 |
|