Thursday, March 25, 2010

Setting up a local virtual server in Linux

If you're like me, then you design web sites on your local server before pushing the update out to the site.  I tend to take and make my local server http://domain/.  This allows me to fully test and run the site just as it runs on the server, but without the lag/extra steps with working on the server itself, not to mention my changes don't effect the visitor's experience until I push the update.

To do this, go to:


It will look like this:       localhost

You need to update this file so your browser knows to look locally for the domain.  Add a line for your domain name...       domain
OR       domain2.loc

Next you need to tell apache about your new domain. Go to /etc/apache2/sites-available/ and create a file for your new domain. Since my new domain is literally "domain" that's what I will call my file, with no file extension. Within that file I'll put this....

NameVirtualHost domain:80

<VirtualHost domain:80>
ServerName domain
DocumentRoot /var/www/domain/

Once you've got this setup you're good to go. All you need to do is restart apache...

/etc/init.d/apache2 restart

Now I can access this local domain by simply typing http://domain/ and it won't effect the users browsing my site.

Wednesday, March 24, 2010

Internet Explorer (IE) and image/pjpeg, what's that all about?

I had a user report to me today that jpg image uploads were not functioning. I had him send me the images so that I could try uploading them to my site. They worked just fine. So what's the problem? Some genius over at Microsoft decided that instead of using image/jpeg as the mime type for JPG's they would use image/pjpeg.

If you're checking mime types for your image uploads, be sure to include image/pjpeg in the list or you'll find yourself dealing with bug reports.

Tuesday, March 16, 2010

Server Load Average and what to do about it

To take a look at your load average, to your server's command line and type "top" and it'll show you the top processes your server is running.

I was going to write up some descriptions on this as my research continued, but I found the perfect source. So rather than rewrite it the guide and try to explain things I don't have an expert's opinion on, I'm going to forward to a real source, that knows what they're talking about.

Understanding Linux CPU Load - when should you be worried?

Wednesday, March 10, 2010

Determine if PHP file is being access via Cron

I ran into an issue where I needed to determine which config settings to load in my API. It picks up automatically whether I'm working locally or on the server. It kept loading the local configuration based on my code. So I asked some smarter people for some assistance and was given the right answer. This will determine whether it's being loaded via command line.

if (php_sapi_name() == 'cli') {
    return true;
} else {
    return false;