Showing posts with label fedora core 4. Show all posts
Showing posts with label fedora core 4. Show all posts

Tuesday, February 17, 2009

Please check your autoconf installation and the $PHP_AUTOCONFenvironment variable is set correctly and then rerun this script.

This is a very simple fix if you are running Redhat Enterprise / CentOS 5.2.  

yum install autoconf

I came across this while setting up memcache / memcached.  I had tried running phpize from the memcach-2.2.4 directory but was getting the error "Please check your autoconf installation and the $PHP_AUTOCONFenvironment variable is set correctly and then rerun this script."

Once I had autoconf installed I was able to finish the install process
./configure
make
make install

I know there are easier ways to do all of this on CentOS, but we are using a newer version of PHP (5.2.6) than came with CentOS (5.1.6), so using yum to install this would not have worked.

Tuesday, February 10, 2009

How to: mod_expires & mod_deflate in Apache running on CentOS 5

While trying to improve the performance of our internal workflow I was tasked with setting up mod_deflate and mod_expires, based off of Yahoo's! Best Practices for Speeding Up Your Website.

The nitty gritty of these two is to make sure they are both listed in your httpd.conf file:
LoadModule expires_module modules/mod_expires.so
LoadModule deflate_module modules/mod_deflate.so

Since this server is running the default CentOS 5 apache I already had the support I needed.  I then continued on to find the documentation online. Both modules support vhost context so that is the route I went with. I added the lines below to each vhost that I wanted the settings to take place for.

ExpiresActive On
                ExpiresByType image/gif A2592000
                ExpiresByType image/jpeg A2592000
                ExpiresByType image/png A2592000
                ExpiresByType text/css A2592000
                ExpiresByType application/x-javascript A2592000
                ExpiresByType application/pdf A2592000
        

The syntax for the ExpiresByType directive is:
ExpiresByType mime/type TimeInSeconds. 

The A2592000 is Access time + one month.  If I wanted the file to be cached for one month from modification date I would have done M2592000 instead.

Other handy numbers in seconds:
86400 = One Day
604800 = One Week
2592000 = One Month
31536000 = One Year (365 Days)
157680000 = Five Years
3153600000 = Ten Years

Why might these large numbers come in handy?  Well you want to set far future expiration dates for things that don't change often.  The catch is if you need to update one of these items with a far future expiration date.  You have to change the file name.  Modify the case of the filename will work in the short term but really you want to start adding version strings to all of your static files like CSS and JavaScript.  

mod_deflate is much easier to setup.  Simply add the line:
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript text/css

Again based on the mod_deflate documentation you can add this directive to the vhost directives.  Please note that this directive can be placed on just about any context level and as such is very powerful.  Also note that you should not try to compress image file because they are already compress and it really is just a waste of CPU and time.

Using these two methods we where able to reduce our website on a first visit from 190.7Kb total to 157.3Kb total.
Before:
9.4K HTML/Text
32.1K Javascript
12.9K Stylesheets
0.4K CSS Images
135.9K Images
190.7K Total

After:
3.1K HTML/Text
15.0K Javascript
2.9K Sytlesheets
0.4K CSS Images
135.9K Images
157.3K Total

I also used the yuicompressor to minify our main Javascript and our CSS file.
After:
3.1K HTML/Text
12.3K Javascript
2.2K Sytlesheets
0.4K CSS Images
135.9K Images
154.0K Total

As you can see using mod_deflate to compress the Javascript and CSS is a more substantial savings in terms of bandwidth than trying to minify.

Granted based on my observations if we really wanted to save on bandwidth and make our pages load faster we would reduce the substantial image footprint.

In case anyone is wondering where I culled all of these numbers from I used Y! Slow for Firebug in Firefox. 

Friday, November 14, 2008

Adding a Virtual Host to Apache2 based on Port

Today I had to setup an internal testbed server for one of our websites.  I didn't want to create a new host name for the site on our Apache server so I went with port based virtual hosts.

There are a few things you need to add for this to work.  My first attempt to make this happed in Webmin didn't produce the results I wanted, so I turned to my trusty text editor vi.

vi /etc/httpd/conf/httpd.conf

Now I had to add in a line similar to:
Listen 8080

Also you have to tell apache to use name based virtual hosting. So add in the line:
NameVirtualHost *:8080

Then finally you can create the directives for your virtual host.
DocumentRoot /your/path/here
ServerName 1.2.3.4:8080


Wednesday, October 29, 2008

Using AT to schedule a command for later in Linux / CentOS

I know this should be one of those basic things ALL Systems Administrators knows but I just learned it today.  I just re-installed a  server with CentOS 5.2.  While it is mostly up to date there are a bunch of packages that need to be updated.  I didn't want to hog all of our bandwidth during production hours and I forget to do stuff once I get home, so I want this to happen with out me thinking about it too much.

From a command prompt I typed:
at midnight tomorrow [ENTER]
yum -y update [ENTER]
[CTLR + D]
 This set up my command to update via my Yum repositories tonight at 12:00:00am (well technically tomorrow).

That is all.

Tuesday, October 21, 2008

warning: locate: warning: database /var/lib/slocate/slocate.db' is more than 8 days old Fedora 4 Core 4 Fedora Core 4

warning: locate: warning: database /var/lib/slocate/slocate.db' is more than 8 days old
warning: Please make sure the daily cron job is enabled in /etc/updatedb.conf
The quick way to fix this error is to run locate -u from the command line as root.
Then edit the locate config file (vi /etc/updatedb.conf) and change the line "DAILY_UPDATE=no" to "DAILY_UPDATE=yes"

Thats it!