Open Source

PHP 7.1 with Apache on CentOS 7.x

Back in the long long ago you could roll out LAMP with a single yum command. In 2017, distro game has hardly kept up with the evolution in PHP and still comes with PHP 5.4 - to go to 7 in RHEL/CetOS 7 you have to do some surgery.

First remove all the php packages. Then let this rip.

yum install epel-release yum-utils

rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm

yum-config-manager --enable remi-php71

yum install -y php71-php-pecl-memcached php71-php-mysql php71-php-xml php71-php-cli php

That's all, just restart httpd and hack your /etc/php.ini (needs explicit definition for the time zone)

Firefox 3.0 RC1 is out!

I'm generally not a fan of beta testing browsers because its hard enough to get reliable rendering even on solid releases but Firefox is worth making an exception for. Today the Mozilla Foundation released Firefox Release Candidate 1 and the list of enhancements is remarkable.

With Firefox and developments with Adobe AIR the webapp world has never been more exciting.

Load Balancer Fun

I really don't like talking smack about my competitors both because I know how difficult of a task we all have always being a step behind spammers and I choose to put my energy into building our own products. After all, with all due professional respect, nobody has unplugged more of their appliances than me.

But yesterday I had a particularly frustrating day of learning more about Linux load balancing than I particularly wanted to. And after several hours of piecing together the concepts through Google and outdated documents and technologies I figured - screw it, I'll just go buy one from them and move on to one of the other billion projects I have on my desk. I look at the model breakdown and the first thing that strikes me is obvious hard locks in the appliance to limit the number of real servers so you'd have to upgrade to the higher model just because. Ok, fine, what's $500 wasted on top of $1499? So I go to the order form and they got more fees - multiyear IDS protection subscriptions.

Ok, so now this is just getting ridiculous. So I figured let me hit up chat and see if there is "I'm not a sucker" form. So I ask politely, "Can I buy your load balancer without the extended support contract?" and instead of saying yes or no, he/she responds with "I can send you more information about that, what is your email address?" and I say "No thanks, I don't want you spamming me, I am buying right now I just want to know if its possible to get it without the energizer updates"; They let me sit around for a minute or two and come back with the barrage of questions: "The updates come with IDS, blah, blah, blah" and I respond with "I just need a load balancer, can I please just order one without updates" and they say "No." and close the chat faster than I can even blink.

So suffice to say they lost that order. I mean, I can understand that they are crooks and are using the same deceptive advertising that has been available from the beginning of time - low advertised price but by the time you get to the counter you end up paying almost double. And would I have paid $2K? Yeah. But after that treatment I won't. And this is perhaps yet another reason why you don't want to be a sales prick, you just might end up pissing off the guys that run data centers and will now spend another day trying to figure it out - and when they do, you will lose a hell of a lot more than the $399 or whatever bs markup it was.

So that's the lesson for the day: Don't be a prick when people are trying to give you money. You can still sell by saying "no"  but you can't sell if you're throwing customer out of the store.

Anyhow, if you've got Linux Kung Fu, this is what I'm trying to do:

ipvsadm -A -t 65.99.255.235:25 -s wrr
ipvsadm -a -t 65.99.255.235:25 -r 65.99.255.242:25 -m -w 1
ipvsadm -a -t 65.99.255.235:25 -r 65.99.255.246:25 -m -w 1

Stock CentOS 5 (RHEL 5) 2.6.18 kernel with net.ipv4.ip_forward turned on and I have a public IP that I want to distribute traffic over the two real servers with direct return (direct path return) with both real servers on the public range. The load balancer is at 65.99.255.230 and here is the tcpdump:

08:29:33.214112 IP (tos 0x0, ttl  64, id 5746, offset 0, flags [DF], proto: TCP (6), length: 60) 65.99.255.230.56232 > 65.99.255.246.smtp: S, cksum 0x4bde (correct), 2861789973:2861789973(0) win 5840 <mss 1460,sackOK,timestamp 64775527 0,nop,wscale 7>
08:29:33.214171 IP (tos 0x0, ttl  64, id 0, offset 0, flags [DF], proto: TCP (6), length: 60) 65.99.255.246.smtp > 65.99.255.230.56232: S, cksum 0x1f4c (correct), 3193828587:3193828587(0) ack 2861789974 win 5792 <mss 1460,sackOK,timestamp 377709289 64775527,nop,wscale 2>
08:29:33.214179 IP (tos 0x0, ttl  64, id 5747, offset 0, flags [DF], proto: TCP (6), length: 52) 65.99.255.230.56232 > 65.99.255.246.smtp: ., cksum 0x6485 (correct), ack 1 win 46 <nop,nop,timestamp 64775527 377709289>
08:29:33.214232 IP (tos 0x0, ttl  64, id 5748, offset 0, flags [DF], proto: TCP (6), length: 52) 65.99.255.230.56232 > 65.99.255.246.smtp: F, cksum 0x6484 (correct), 1:1(0) ack 1 win 46 <nop,nop,timestamp 64775527 377709289>
08:29:33.214753 IP (tos 0x0, ttl  64, id 38405, offset 0, flags [DF], proto: TCP (6), length: 52) 65.99.255.246.smtp > 65.99.255.230.56232: ., cksum 0x5f0a (correct), ack 2 win 1448 <nop,nop,timestamp 377709289 64775527>
08:29:33.218077 IP (tos 0x0, ttl  64, id 38407, offset 0, flags [DF], proto: TCP (6), length: 117) 65.99.255.246.smtp > 65.99.255.230.56232: P 1:66(65) ack 2 win 1448 <nop,nop,timestamp 377709293 64775527>
08:29:33.218091 IP (tos 0x0, ttl  64, id 0, offset 0, flags [DF], proto: TCP (6), length: 40) 65.99.255.230.56232 > 65.99.255.246.smtp: R, cksum 0x33d0 (correct), 2861789975:2861789975(0) win 0
08:29:33.218095 IP (tos 0x0, ttl  64, id 38409, offset 0, flags [DF], proto: TCP (6), length: 52) 65.99.255.246.smtp > 65.99.255.230.56232: F, cksum 0x5ec4 (correct), 66:66(0) ack 2 win 1448 <nop,nop,timestamp 377709293 64775527>
08:29:33.218102 IP (tos 0x0, ttl  64, id 0, offset 0, flags [DF], proto: TCP (6), length: 40) 65.99.255.230.56232 > 65.99.255.246.smtp: R, cksum 0x33d0 (correct), 2861789975:2861789975(0) win 0
08:29:33.222272 IP (tos 0x0, ttl  64, id 23742, offset 0, flags [DF], proto: TCP (6), length: 60) 65.99.255.230.45127 > 65.99.255.242.smtp: S, cksum 0xb04d (correct), 2865052113:2865052113(0) win 5840 <mss 1460,sackOK,timestamp 64775535 0,nop,wscale 7>
08:29:33.222380 IP (tos 0x0, ttl  64, id 0, offset 0, flags [DF], proto: TCP (6), length: 60) 65.99.255.242.smtp > 65.99.255.230.45127: S, cksum 0xb60a (correct), 2798131280:2798131280(0) ack 2865052114 win 5792 <mss 1460,sackOK,timestamp 408392 64775535,nop,wscale 2>
08:29:33.222396 IP (tos 0x0, ttl  64, id 23743, offset 0, flags [DF], proto: TCP (6), length: 52) 65.99.255.230.45127 > 65.99.255.242.smtp: ., cksum 0xfb43 (correct), ack 1 win 46 <nop,nop,timestamp 64775535 408392>
08:29:33.222476 IP (tos 0x0, ttl  64, id 23744, offset 0, flags [DF], proto: TCP (6), length: 52) 65.99.255.230.45127 > 65.99.255.242.smtp: F, cksum 0xfb42 (correct), 1:1(0) ack 1 win 46 <nop,nop,timestamp 64775535 408392>
08:29:33.223193 IP (tos 0x0, ttl  64, id 8985, offset 0, flags [DF], proto: TCP (6), length: 52) 65.99.255.242.smtp > 65.99.255.230.45127: ., cksum 0xf5c7 (correct), ack 2 win 1448 <nop,nop,timestamp 408393 64775535>
08:29:33.242440 IP (tos 0x0, ttl  64, id 8987, offset 0, flags [DF], proto: TCP (6), length: 117) 65.99.255.242.smtp > 65.99.255.230.45127: P 1:66(65) ack 2 win 1448 <nop,nop,timestamp 408412 64775535>
08:29:33.242454 IP (tos 0x0, ttl  64, id 0, offset 0, flags [DF], proto: TCP (6), length: 40) 65.99.255.230.45127 > 65.99.255.242.smtp: R, cksum 0x9847 (correct), 2865052115:2865052115(0) win 0
08:29:33.242458 IP (tos 0x0, ttl  64, id 8989, offset 0, flags [DF], proto: TCP (6), length: 52) 65.99.255.242.smtp > 65.99.255.230.45127: F, cksum 0xf572 (correct), 66:66(0) ack 2 win 1448 <nop,nop,timestamp 408412 64775535>
08:29:33.242465 IP (tos 0x0, ttl  64, id 0, offset 0, flags [DF], proto: TCP (6), length: 40) 65.99.255.230.45127 > 65.99.255.242.smtp: R, cksum 0x9847 (correct), 2865052115:2865052115(0) win 0

I see the connection come up, and the weights look right:

IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port           Forward Weight ActiveConn InActConn
TCP  65.99.255.235:smtp wrr
  -> i246 Route   1      0          0        
  -> i242 Route   1      0          1 

So I’m missing something here… If you can see it from there, let me know.

Howto: Speeding up AJAX web applications with htaccess and mod_expires

After the millionth time of watching my mobile phone choking on loading quarter meg of Javascript of Shockey Monkey’s new mobile rich interface I finally remembered the pain while searching for my lost Blackjack earlier this afternoon. Not only did Katie find it (love yooou honey!) but I also sat down to finally put the pesky Javascript static-code reloads to a grave.

Here is an article on how to use Apache’s mod_expires to enforce selective caching of javascript files.

http://www.vladville.com/using-apache-mod_expires-for-faster-ajax-sites

That sounded like a mouthfull. Here is what it means: I telll your browser how long it needs to cache my Javascript code. One day? One month? One year? My call. By telling it which Javascript libraries do not change often I can force it to cache them and not have to download them every single time. Faster load times, less bandwidth, more efficient experience. And hopefully less need for a phone warranty as you watch that GPRS ghettonet connection struggling with the last few K worse than a fat man with the 26th mile of the marathon.

P.S. Yes, of course I am still working on Shockey Monkey! Lack of hype does not translate into lack of development, there are over 4,000 people using, you didn’t think I’d just let that slide did you? Geez.

Compiz and Beryl Merge

Perhaps one of the best developments in the Linux GUI world in quite some time, two of the biggest projects that bring eye-candy to Linux are getting together! If you’ve never seen Beryl in action just search YouTube for it, it will blow you away.

And just in case you’re thinking – so what, what kind of an idiot is impressed by the shiny objects? Well, how do you explain Vista and every single Mac user? UI usability is big, and this is a sign that things like Gnome and KDE now get to stand shoulder to shoulder with the others.

Fun with Fsync & Bind Mounts

ShagadelicThe answer to “Why don’t you blog about your work Vlad” and the final dagger in the back of my female audiences libido: moving sendmail spools to tmpfs.

First off, why bother? Well, with the ram being as cheap as it is and finally some solid hardware and software tmpfs is really getting a lot of play. It also helps when yours truly wakes up from an one hour nap and finds a node with 68,000 messages waiting in the spool because of poor disk performance. Talk about a motivator to work on optimizing the mail stream!

 

Doin’ it the wrong way

The first step is to actually create a tmpfs disk and mount it.

/bin/mount -t tmpfs tmpfs -o size=256M,nr_inodes=1M /var/spool/mqueue.in

That works. This creates a 256MB ram disk and mounts it in /var/spool/mqueue.in. Start up sendmail and everything works fine until mail has to be moved around and processed. Then you get bit in the ass by fsync errors (fsync is enabled by default on the 2.6 kernels). Time to turn that beast off:

  # override compile time flag REQUIRES_DIR_FSYNC 
 O RequiresDirfsync=false

Now we got the ramdisk, we disabled fsync, it should work now without a problem, right? Heh. Nope. Sendmail queue’s need to be on the same filesystem and same partition. If they aren’t sendmail starts complaining and poof.

 

Doin’ it the right way

This one actually belongs to my bud Pablo who has hacked in bind mounts on pretty much every box I’ve ever had. Bind mounts function similarly (or exactly) like folder mounts with NTFS, a folder (or directory) from one file system can be seen at another point on another file system. Go Pablo: 

mkdir /var/sendmail/tmpfs
mount -t none /var/sendmail/tmpfs

mkdir /var/sendmail/tmpfs/mqueue
mkdir /var/sendmail/tmpfs/mqueue.in

mount /var/sendmail/tmpfs/mqueue /var/spool/mqueue -o bind
mount /var/sendmail/tmpfs/mqueue.in /var/spool/mqueue.in -o bind

 

So to sum it up

First, thank god I found a woman to marry me because girls don’t respond well to pickup lines referencing linux filesystem optimization. Second, moving sendmail to tmpfs really helped, remarkably. In the few hours since the tweak the load average really went down – Linux calculates the load average by the amount of cycles all running processes take up – so if a ton of children are fired up and waiting on IO for something the load goes through the roof. Memory and IO really improved as well but you’ll have to take my word for it because the output from vmstat looks hella ugly. See why I don’t write about what I do?

Good intro to MySQL

Needed to get some air and clear my head.. so I went to the local Linux User Group (www.golug.org) mostly because its one of the few places I can go to without looking like a human being. No shaving, no haircut, no problem – dirty jeans and “I read your email shirt” and I’m out the door.

Kevin Korb presented a very nice introduction to MySQL and SQL in general. He has a writeup here. Take a look at it, the paper is a pretty comprehensive description of the basics to get you started. MySQL is a powerful SQL server and yes, it runs on Windows too. Check it out.

Which Office is Cheaper?

Get legal. Get OpenOffice.orgThe free one or the commercial one? Alright, so it's a trick question but a fairly legitimate one as Microsoft continues to wage a war against piracy. Let's for a second assume that the person running a pirated version of Office is indeed a criminal and not an innocent bystander that bought it from some OEM email that made it through the spam filters. Do you think they will A) Steal Office 2007 or B) Go legit with OpenOffice? 

This is probably the true indication on whether Office users actually use and appreciate most features available in Office 2003 any beyond. I personally do not use even 10% of things beyond Outlook. I'm a very "IT Basic" user and do not even have PowerPoint, FrontPage, Project and the rest of the extended family installed on my main workstation. For me though, Outlook is the glue that holds them all together. With Microsoft integrating the remainder of their family into each and every app, then integrating the entire platform into live.com it would seem that the 10% will shrink to even less.

I've looked at Open Office time and time again and I just do not like it. It feels like Claris Works that we were forced to use on Mac's because the school system made a poor purchasing decision and trained its students on something they will never see in the real world. But in spite of that, I hold on to my Outlook. I use notepad more than I use Word, yet I have this $500 thing on my desktop. So OpenOffice folks, please, why don't you take a lesson from Microsoft interface design team and make OpenOffice 2 look more like Office 2003. If people didn't know there was a difference in what they are looking at (like Firefox), perhaps they would not see the difference and actually switch.

Oh sweet RSS Irony

So I'm going through my local Linux user group mailing list and a thread with the subject "[GoLugTech] Is this do-able in linux?" pops up. Alright, I'm intrigued if something can be done with Linux, what do you need? Are you curious too? Is that awesome or what?