After migrating a site to new server I run into a strange problem with big file downloads that just stop/break without any specific reason at anytime. Downloads are not direct than are done using PHP (I’ll write more about that soon and I’ll link to that post from in here when I do) suddenly break without any notice. Browser reports that file has been successfully downloaded, Apache doesn’t report any errors but file is broken and not downloaded entirely.
I was pulling my hair for days, since sometimes downloads were working fine but sometimes they would just stop. Things got worse in case of downloading multiple files at the same time. Sometimes one or two downloads would break, sometimes all, sometimes none. It was driving me mad. Since I have been traveling those days across Northern Europe, I have been able to test the file download from multiple locations/countries and various connection types (ADSL, Cable, WiFi hot spots) and was still experienced same problems.
The setup on that server was bit complex and it used Apache to serve dynamic content, separate web server for static content. Downloads were done using PHP or using mod_xsendfile but either way problem persisted. So I figured out that something must be timing out and that is braking the connection. Since it would happen that out of 4-5 simultaneous downloads one or two would break and few would download normally. Finally, I tried increasing Apache timeout from 10 seconds to 30 seconds and it worked out! I was so pissed of and happy at the same time… The solution was so easy and in front of my nose but I needed so much time to figure it out… I felt so stupid for a second but then I solved the problem and I’ve learned something new…
It turns out that if there were no communication between server and client for 10 seconds the Apache would simply close connection and download would break. Nothing will be reported on both sides since it’s “normal” way to end the communication. This was also going on when mod_xsendfile was used to serve/download files. The problem was even greater when internet connection was worse (WiFi) and when I was downloading more files at once since than the connection would have to be split on few files.
So if you’re making a download server for larger files make sure you setup your Apache timeout to some reasonable value (30 seconds or more). Under term “larger files” I consider everything larger than pictures, but basically 50mb file could be called “larger file” since for it’s download it is required some time and of course open connection.
My IP got banned by CPHulk few times and it is really not a pleasant thing knowing that you need to access your server but you just can’t because CPHulk blacklisted your IP. Great way around it is to white list your IP address in front so you don’t end up in that situation. It’s quite easy, all you need to do is to login at SSH and execute this lines:
Just don’t forge to replace xxx.xxx.xxx.xxx with your IP address 🙂
Ok so today I had to dump 700mb mysql database. I have tried using standard syntax:
mysqldump -uUSER -pPASS db_name > dump.sql
But I have got the following error:
Mysqldump: Got error: 1016: Can’t open file: ‘./db_name/xxx.frm’ (errno: 24) when using LOCK TABLES
I’ve searched a bit and I have found that solution was to add parameter –lock-tables=false so the final working mysqldump command was like this
mysqldump -uUSER -pPASS db_name --lock-tables=false > dump.sql
Today I have got a request from a client that has a server with no control panel on it to change one ftp password. Server is using proftpd as it’s ftp server. This is really easy task to do if proftp is setup by default and uses /etc/passwd for storing it’s passwords.
If you know username all you need to do is type in
(replace USERNAME with actual username), enter new password two times and you’re done.
If you however don’t know the username (and that can happen too) you can open /etc/passwd file and try and locate it in there.
Today something weird happened. I started up my computer and clicked on Chrome icon – and nothing. I click again nothing… This is weird… I start up Windows Task Manager and then I click again Chrome icon and I monitor Processes list at Windows Task Manager and chrome.exe doesn’t come up… So I start up Total Commander and go to c:\Users\USER\AppData\Local\Google\Chrome\Application\ and there is chrome.exe and there is debug.log. I start the chrome.exe and nothing again. In debug.log I’ve noticed lots of lines like this one:
[0214/035118:ERROR:client_util.cc(315)] Failed to load Chrome DLL from 0029F7E0
[0214/035118:ERROR:client_util.cc(356)] Could not find exported function RelaunchChromeBrowserWithNewCommandLineIfNeeded
Also I see two directories above: /16.0.912.77 and /17.0.963.46. So this looks to me like some update gone wrong. I start Opera and start searching a at Google on how to solve this since I don’t want to loose all my logins, bookmarks etc… Few minutes later I have found a simple solution that worked but not fully… To solve this problem I had to copy the chrome.exe from /application folder into /application/17.0.963.43 folder (newer version folder). Then by running chrome.exe from that directory did start a browser but when I click on a Key (settings in Chrome) and go to “About Google Chrome” I can see error message “Update server not available (error: 1)” that means that my Chrome will not update itself in future.
So I went to FileHorse.com and downloaded the latest version of Google Chrome and at the moment it was 19.0.1036.7 and I start the chrome_installer.exe I just downloaded and nothing happens…. No installation stuff, nothing… Well I know Google guys like minimalism but this was nothing… but in my Google Application folder I see two new things: new folder /19.0.1036.7 and new file new_chrome.exe. So after trying few more things I found the solution. I had to delete old chrome.exe and rename new one from new_chrome.exe to chrome.exe and it was finally it!!! Chrome was working, update at about page is again saying “Google Chrome is up to date (19.0.1036.7)”.
Ok but why did this happen?
Well I started searching the web and I found out that this happened because of using Chromium or Chrome portable. And I’ve been using/trying both! So one of those probably started auto-update and than used settings stored in registry from my installed Chrome and messed it all up. So my advice for you today is: DO NOT use Chrome along with Chrome Portable or Chromium Portable or any other browser running on Chromium open-source platform!
In order to get to Windows Task Manager using CTRL + ALT + DEL shows you screen (with following options: Lock this computer, Switch User, Log Off, Change Password, Start Task Manager):
Some times getting to that screen is not easy and it takes a lot of time especially if some application is stuck or it’s using all CPU power or allocated lots of memory.
But there’s are two quicker ways to do start Windows Task Manager directly, without that blue screen, that is really slow sometimes.
1. Right-click on empty space in your Windows 7 taskbar and select “Task Manager”, like on the picture below:
2. Press CTRL + SHIFT+ ESC. The result will be the same: Windows Task Manager will start:
In order to protect your server the best way possible, beside running iptables you should install some additional software. I can recommend ConfigServer Security & Firewall. I’m using it on couple of servers right now and it’s prove it self to be stable and low on resource usage. It also has WHM/cPanel plugin that helps you managing your firewall even if you’re not very experienced user/admnin.
Before installing you must be sure that you do not have any other firewalls installed (such as APF)
Installation is really simple. You just need to run those couple of commands in SSH:
tar -xzf csf.tgz
Don’t forget to disable testing flag by setting TESTING = 0.
You can do that easily in WHM/cPanel: after logging in at WHM and in Plugins section of sidebar you’ll find “ConfigServer Security&Firewall”. Then click on Firewall Configuration and change testing value. Save it and restart firewall and there you go! Your CSF firewall is up and running!
Continue Reading →
Today I a customer of mine came to me with a problem with web site that he have just moved from one host to another. And on that new host all his links on his site suddenly had ?PHPSESSID=k234j2knk… in the end. Since that is totally unusable since that site doesn’t even uses sessions and could affect his search engine rankings, he wanted it out of the way. The new host he moved that site to was shared and it doesn’t allow editing of php.ini any way so I had to make some other solution.
After failing with adding one of those on top of php files, as suggested on most pages that I found on Google:
// stop PHP from automatically embedding PHPSESSID on local URLs
I suggested him to just switch hosts again, but he said he already paid up front for the whole year… and that it’s not an option… and that he wants that off his site… So, I’ve Googled some more and finally found a simple solution (that doesn’t require editing of 100’s of files in his case because of poorly programmed site). All I had to do is just put one line of code in .htaccess file and BOOM! All those nasty ?PHPSESSID were gone!
php_flag session.use_trans_sid off
Everyone of us probably has hundreds if not thousands of images taken with his digital camera or cell phone. When viewing these pictures on computer (or TV) you will find that lots of pictures needs to be rotated to be displayed correctly. Doing this by hand can really take some time. Luckily, I have found an easier way of solving this problem. It’s also very fast and easy to use!
Most of modern digital cameras (and cellphones) save many extra data to JPEG. That’s called EXIF data. Many useful information about how the picture was taken is stored in there. In sample I provided on the right you can see part of the EXIF data saying that the picture was made using my Nikon D50, that I didn’t use the flash and that exposure time is 1/250 sec and that focal length was 80mm. Beside that, there are many other details that are not displayed in this sample, and among those is Orientation tag that says how the camera was positioned in time of shooting.
Our mission is to automatically rotate multiple images in batch using data saved under that field. For that purpose I will use FastStone Image Viewer that you can download from my favorite software download site FileHorse.com. This software is free for personal use (professionals should buy a license). It’s really amazing piece of software for image manipulation (viewing, converting, cropping, re-sizing, watermarking – you name it!)
Ok, once you’ve downloaded, installed and started FastStone Image Viewer, you need to find images that you need to rotate. Once in folder with images select them by pressing CTRL+A and then go to Tools – > JPEG Lossless Rotate -> Auto-Rotate based on EXIF Orientation Tag just like on picture above. A popup will ask you are you sure you want to do it, press yes and wait until your photos are auto rotated (if you have lots of photos or slower computer it can take some time to process them all). It’s easy as 1-2-3! Take a look at the samples below:
Feel free to leave your comments in the comment box below!
Today I went to update some plugins on one WordPress installation but then I accidentally closed the tab while update was in process. When I went back to WP admin or (to blog homepage) I was getting this error: “Briefly unavailable for scheduled maintenance. Check back in a minute“. Since I couldn’t access WP Admin my hands were tied and I could do anything. So I logged in at the FTP to see how the plugins folder looks like and is something damaged. And in www (pubic_html) folder I noticed file “.maintenance“. I made backup of it and then deleted it and reloaded the blog and – IT WAS WORKING AGAIN! And WP admin was working again! WordPress never stops amazing me!