Ian Winter Ian Winter

Compilation Fun

Building a new server today with a CLAMP installation. ColdFusion, Linux, Apache, MySQL and PHP.

Server in question was a RHES4 server. Going to install the following apps:

  • ColdFusion 7.0.2 (CU3)
  • apache 2.2.8
  • MySQL 5.0.51a
  • PHP 5.2.5

Suppose to be a quick job, but, oh no.

First up the server already had a MySQL 4.1 RPM installed which was causing some issues. When trying to do a straight update it failed.

rpm -Uvh MySQL-server-community-5.0.51a-0.rhel4

You can't remove it with rpm -e either. After some Google love discovered that it's some issues with compatibility. So off to the MySQL site again to wget the shared-compat RPM.

rpm -Uvh MySQL-shared-compat-community-5.0.51a-0.rhel4

Now the server will upgrade just fine. Next up get the client libraries and headers installed (we'll need them for the PHP compile later).

rpm -Uvh MySQL-devel-community-5.0.51a-0.rhel4
rpm -Uvh MySQL-client-community-5.0.51a-0.rhel4

I'll skip the crap about getting it running for now. Next up is apache.

Pretty easy compile this one, probably don't need rewrite and deflate separate but did it anyway.

./configure \
	--prefix=/usr/local/apache2 \
	--enable-mods-shared=most \
	--enable-rewrite \
	--enable-deflate
make
make install

Quick check that it runs and then onto PHP.

./configure \
	--prefix=/usr/local/apache2/php \
	--with-apxs2=/usr/local/apache2/bin/apxs \
	--with-mysql=/usr \
	--with-config-file-path=/usr/local/apache2/php \
	--enable-force-cgi-redirect \
	--disable-cgi \
	--with-zlib \
	--with-gettext \
	--with-gdbm
make clean
make
make install

The key stage is the make clean. For some odd reason if you don't make clean first you get an error like the following, the make clean will stop this happening.

httpd: Syntax error on line 55 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: undefined symbol: zend_ini_string 

ColdFusion should be easy, will probably need to recompile the connector again but hey... that's the fun, I think.

mod_gzip is your friend

To save bandwidth on one off the servers I look after I decided to implement mod_gzip.

The server in questions is running RedHat ES3, apache 1.3.37, Coldfusion 7.0.2 and has the cPanel/WHM control panel.

First off was to get mod_gzip compiled, now this can be done manually, download a pre compiled one or in my case just go into WHM and rebuild apache with the mod_gzip box checked. The version it puts in is 1.3.26.1a.

As I'd already got Coldfusion running on this webserver the resulting httpd.conf file it creates became invalid so I had to move a few things about. To cut to the chase the order in which modules load is crucial with Coldfusion due to the was the mod_gzip and mod_jrun modules work intercepting requests. The following is my httpd.conf (abbriviated) with the relevant sections.

LoadModule ...

--snip--

LoadModule jrun_module /usr/local/coldfusionmx7/runtime/lib/wsconfig/1/mod_jrun.so

<IfModule mod_jrun.c> JRunConfig Verbose false JRunConfig Apialloc false JRunConfig Ssl false JRunConfig Ignoresuffixmap false JRunConfig Serverstore /usr/local/coldfusionmx7/runtime/lib/wsconfig/1/jrunserver.store JRunConfig Bootstrap 127.0.0.1:51011 #JRunConfig Errorurl <optionally redirect to this URL on errors> #JRunConfig ProxyRetryInterval 600 #JRunConfig ConnectTimeout 15 #JRunConfig RecvTimeout 300 #JRunConfig SendTimeout 15 AddHandler jrun-handler .jsp .jws .cfm .cfml .cfc .cfr .cfswf </IfModule>

LoadModule gzip_module libexec/mod_gzip.so

<IfModule mod_gzip.c> mod_gzip_on Yes mod_gzip_can_negotiate Yes mod_gzip_static_suffix .gz AddEncoding gzip .gz mod_gzip_update_static No mod_gzip_command_version '/mod_gzip_status' mod_gzip_temp_dir /tmp mod_gzip_keep_workfiles No mod_gzip_minimum_file_size 500 mod_gzip_maximum_file_size 500000 mod_gzip_maximum_inmem_size 60000 mod_gzip_min_http 1000 mod_gzip_handle_methods GET POST mod_gzip_item_exclude file .js$ mod_gzip_item_exclude file .css$ mod_gzip_item_exclude file .swf$ mod_gzip_item_exclude mime ^image/ mod_gzip_item_include file .php$ mod_gzip_item_include file .cfm$ mod_gzip_item_include file .jsp$ mod_gzip_item_exclude file .pdf$ mod_gzip_item_include file .fic$ mod_gzip_item_include file .html$ mod_gzip_item_include file .htm$ mod_gzip_item_include mime ^text/html mod_gzip_item_include mime ^text/plain mod_gzip_item_include mime ^text/xml #mod_gzip_item_include mime ^application/force_download$ #mod_gzip_item_include mime ^application/pdf$ mod_gzip_item_include handler type-coldfusion mod_gzip_item_include handler jrun-handler mod_gzip_dechunk Yes #then the logging directives LogFormat "%h %l %u %t "%V %r" %<s %b mod_gzip: %{mod_gzip_result}n In:%{mo d_gzip_input_size}n -< Out:%{mod_gzip_output_size}n = %{mod_gzip_compression_rat io}n pct." common_with_mod_gzip_info2 CustomLog "logs/mod_gzip.log" common_with_mod_gzip_info2 mod_gzip_add_header_count Yes mod_gzip_send_vary On </IfModule> AddType type-coldfusion .fic

--snip-- ClearModuleList AddModule ... --snip-- AddModule mod_jrun.c AddModule mod_gzip.c

In my test case I had a page show as 18224 bytes originally which compressed down to 3956 bytes a saving of 14268 bytes or 79%! To test the compression I was using the <a href="http://www.port80software.com/tools/compresscheck.asp">port80software.com</a> compression check. You can also see <a href="http://www.port80software.com/tools/compresscheck.asp?url=flatpackedworld.co.uk%2Fblog%2F">this site's</a> report.

More Information (stuff I read):

<ul> <li><a href="http://www.owensperformance.com/blog_content.cfm?articleid=206">owensperformance.com</a> - cheers Irvin! <li><a href="http://sourceforge.net/projects/mod-gzip/">mod_gzip on sourceforge</a> <li><a href="http://schroepl.net/projekte/mod_gzip/install.htm">How to install mod_gzip</a> </ul>

Coldfusion 6.1 Linux Hotspot Crashes

Had another hotspot crash on a Linux server again today after months of not having any. Doing a bit of googling and finding myself back on Steven Erat's very useful blog I found a user comment saying that in Sun's JRE 1.4.2_10 they seem to have fixed the problem. As a result I've updated it along with a couple of hotfixes to CF and all seems well.

You can get the JRE from Sun's Java site.

eximstats failed

If you've got a Linux box running Cpanel/WHM and you've updated recently you may now have eximstats failed and also noticed some DBD::MySQL errors in the process. Quick fix which worked for me is:

/scripts/realperlinstaller --force DBD::mysql
/scripts/restartsrv_eximstats
/etc/init.d/chkservd restart

Powered by BlogCFC, 5.9.002. Contact Me

All comments, view, rants, raves and opinions are mine and mine alone.

del.icio.us Digg Flickr Last.fm LinkedIn Pownce Twitter YouTube