Category Archives: software

WordPress and Mail-icious Logs

mariusz_mail

 

Remember a couple months back when I wrote about my ridiculous error log woes? Well, I must be the Queen of Crappy Logs because all that fun slammed back into my life in the form of mail log overload. So what gives!? I’ve cleaned my code on older CakePHP installations, added a new WordPress installation for a new project, swapped out any standard wp_mail() functionality for Mandrill API fun, and followed my usual routines for new websites. WHY IS MY SERVER ON FIRE!?

Apparently this hosting-space-savvy developer needed a lesson in managing a server on her own. I got to see first-hand what happens when you disregard any anti-spam precautions when firing up a new WordPress site. I’ve known about Akismet or Mollom, but never thought they were super necessary. I rarely see the deep admin side of my hosted servers so out of sight out of mind, right? NOT ANYMORE! This is now my server I need to protect; I can’t just turn a blind eye while the mail log file grows 1GB/half hour and crunches all CPU. MUST. SAVE. THE WORLD. THE SERVER!

At first, I didn’t realize this was spam. I naturally thought back to my error fun from weeks ago and approached this instance as another flare-up. I start by referencing my friend cat /dev/null >mail.log to help clear some space. This moment of clarity lasts seconds, as the spam attempts continue to overflow the screen. I figure, “Hey, I have Mandrill hooked up. Why is Postfix even trying to work without an active local mail server?” This thought leads me to turning off/stopping Postfix.

Nothing.

OKAY! I’ll completely unload Postfix so HA! Won’t even be an option for ya now, server. Take THAT. Wait…what’s it doing? It’s using a DIFFERENT mail option!? Ninety-two kill PID attempts later and holy hell I’ll put back Postfix. Cripes.

::spam logs continue and I swear they’re even faster/angrier::

WHY WON'T YOU DIE

 

…ugh okay. Now what!? Why is this thing so angry! I start to wonder if it’s in fact the WordPress installation. Maybe if I turn off the site for a moment? I flip the switch — silence. Mk, so it’s definitely this WordPress site. This pause gives me a moment to actually read the lines in this out-of-control log stream. That’s when I notice a bunch of phony email addresses using our WordPress site as a domain name. I definitely don’t have any emails listed for that domain name so finally the spam lightbulb goes off. Great! At least I have a clue!

Time to bust out the anti-spam guns. The most popular solution is Akismet so I went there and got a key. Back in my day ::shakes a cane::, Akismet was free to anyone. I can understand that their popularity and success has resulted in them asking for some maintenance help. Anything would be worth a quiet mail log at this point. I snag a key and pop it into place in my WordPress installation. I also decide to shove a Captcha plugin even though I disabled all commenting for good measure. It’s amazing how resilient these spam bots are even when all commenting/pinging functionality is turned off.

Welp! It’s not complete log silence, but I can see a shift in the log messages. Instead of trying to send these spam mails through a dormant mail server, I see Akismet doing it’s job of double-checking each one and rejecting accordingly. Lovely! I may still be racking up a sizable log file over time, but at least my server CPU is back to normal and free again. Hooray!

Now that I have some time to consider alternative measures, I can’t help but question if Akismet is the best solution for WordPress spam protection. They are very robust now and provide a great third-party check, but is that server-to-server jump so necessary for the sake of some phony email? For now, I believe it is. I can see myself shifting my stance once I get my feet wet and more familiarized with the whole spam front. There are many alternatives out there that can keep you within your own server; privacy-crazed developers rejoice! Be sure to check them out for yourself and save yourself from this chaotic, spammy mess!

That’s all for now! Happy coding :)

 

Back to Stack Dog

Moving Old Sites to Mavericks Server

I recently upgraded a web server from Snow Leopard to Mavericks (subtle upgrade ha) and naturally anticipated a few headaches. Fortunately, the upgrade went rather smoothly! Mavericks loaded right up; server app made everything simple; a quick MySQL download got my databases in place; and the existing websites got nestled nicely in their proper locations. All gravy!

::one day later::

Server is crashing! What!? What is going on? Ah, maybe it’s that 90GB apache error_log file! FUN! So what gives?

Should have figured that moving CakePHP files circa 2009 to a brand new server with the latest PHP would be a BIT of a clash. A ‘bit’ = monumental. PHP recently bundled their E_STRICT error reporting with E_ALL. You used to be able to segment them off or call them separately, but now you’re getting ALL strict reports in one swoop. Needless to say, the default settings in all my older CakePHP sites are not up on this change. Holy logging, batman! Every little move on each website is logging at least 10 PHP Strict errors at a time. The log viewer is struggling, the OS is lagging, everything is taking a hit. Fortunately, my little friend “cat /dev/null > error_log” was my savior! Cleared out that bad boy in one hit and bought myself some time to fix the error reporting.

IMPORTANT NOTE: I understand it’s bad practice to turn off/ignore error warnings. I’ve seen plenty of condescending users on Stack Overflow throw that jab. The issue is the lack of time to fix ALL the errors (many rather useless) before the server crashes. So! If you need to buy time or just don’t have the threshold to weed out every single warning, then this post will help. I simply believe that silencing some overkill warnings is far better than corrupting your databases/crashing your hard drive. That’s just me. Onwards!

I likely could have updated the php.ini file, but that requires an Apache restart and I wasn’t sure I wanted to hide reporting from ALL sites on the server. I just know which sites are most clunky so I opted for code-based changes. Here’s the thing: anything on Stack Overflow made it sound like one simple code change would fix everything. What a thought! It got my hopes up until I realized it didn’t work haha (at least for me).

I kept seeing “all you need to do is put ‘error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);’ in your website/cake/bootstrap.php!”…sounded lovely and super easy, but I still saw craploads of errors in my logs even after clearing all forms of cache/tmp folders. No dice. Per usual, I assumed I wasn’t doing something right so I tried mannnnny variations of the reporting settings. Remove the ~, put ‘E_ALL ^ E_STRICT’ instead, change the order, etc. I even decided to move the error reporting changes from the bootstrap and put it into the core files instead. Nothing. After a while, I decided to just double up my efforts and put the logging changes in the core file AND bootstrap files. So aside from the bootstrap.php error_reporting line, I went to website/app/config/core.php and swapped the defaul error logging settings, “Configure::write(‘log’, true);”, with “Configure::write(‘log’, E_ALL & ~E_NOTICE & ~E_STRICT);” One last refresh of everything, cleared the log file one more time, and opened the server app while wincing.

…silence…

FINALLY. The logs ceased, my OS resumed normal speeds, and the server app wasn’t churning! Success! 24 hours later, any my error_log file is a mere 2MB with 3 of 9 sites updated with logging changes. Much better. Plenty of time to work on things!

So to conclude, here’s how you buy time with old CakePHP websites and PHP 5.4:

  1. Keep the “cat /dev/null > error_log” handy! You can always use this with ssh from a different computer if your computer starts to lag too much or crash. Just remember to be in that apache directory first, of course.
  2. In yourcakesite/cake/bootstrap.php, change existing error_reporting line to “error_reporting(E_ALL & ~E_STRICT & ~E_DEPRECATED);”
  3. In yourcakesite/app/config/core.php, change default “Configure::write(‘log’, true);” to “Configure::write(‘log’, E_ALL & ~E_NOTICE & ~E_STRICT);”
  4. Clear tmp cache files for kicks; never hurts.
  5. Enjoy a quieter log stream!

Not sure if anyone is carrying older sites forward like we are at this point, but hopefully this helps if so! Always something to learn when upgrading servers and sites.

Now for a calm Wednesday! Happy coding!

Back to Stack Dog

Asana to the Rescue!

I thought about writing a drawn-out, comparison-based post about my experiences with project management software, but this seems like a better idea:

asana_snag

That’s right. Stack Dog fully endorses (and chews on) Asana! This is NOT to be taken lightly, folks, because I am queen of “eh, I don’t need to make a list.” I really struggle to justify the use of time for to-do lists when I’m pretty good at prioritizing/executing without any sort of reminder. I’ve been told, “Oh, you just don’t have enough things to do,” which I find to be hysterical. My personal secret is an amazing guilt pattern; I can make anyone’s request seem as though an innocent puppy will be slaughtered mercilessly should I dare forget about doing it. Despite my stubborn tendency to adopt these tools, I listened to a fellow programming colleague and tried Asana.

Yay for simplicity with a smart twist! You can fire up Asana in minutes with a Google account and have a running project list shortly after that. The nice part, too, is you can quickly share your project with someone without them seeing all of your projects/tasks. That right there is what won me over; I can essentially move annoying, convoluted email threads out of my inbox and into an organized, constructive layout while allowing my clients to comment/add tasks as they please. You can even upload files/images as needed, which helps for drafting and designing processes. Again, it’s all rather simple and light, but intuitive with the purpose of crossing things off and collaborating to get things done.

Previously to Asana, I have worked with Basecamp, Zendesk, Jira, etc. and they all have their own wonderful traits. The only issue is they can quickly become a nightmare for people like me who just want to jot something down and show that it has been crossed out. Those platforms are so robust and extremely customizable, but you can lose hours to data entry about something that, frankly, you should just be working on right now. Yes, there is a great payoff in the form of amazing analytics and visuals for your projects, which can translate to an improved process in the future, buuuuuut it sometimes eclipses the project itself. Plus, some of the bigger software are simply lacking that intuitive flair and therefor cannot be quickly shared with a less-than-savvy client. Asana rocks the socks in that department. Seriously, try it out and share a project with your [insert technologically incapable family member here]; you’ll hear the pause as they start to ask a question because they realized they figured it out. It’s a lovely moment.

So, again, if you’re all “I-hate-lists-but-I-think-I-need-to-be-more-organized”, then go here now. You can come back and yell at me if you don’t see what I mean.

Happy coding!

 

Back to Stack Dog

MySQL a.k.a. MyHEADACHE

Okay, I’m subjecting myself to developer shame and scrutiny, but I’m tired of hitting these little snarls. In other words, this post is more for myself than anyone else. Plus, the other point of this blog is to document my trials and solutions so brace yourself.

I’m simply trying to get a new installation of MySQL up and running on a Mavericks-based server. There are 20,398,430,284 (maybe fewer) articles regarding the process, but I somehow manage to slam into walls. Part of me believes it’s the fact that there ARE too many articles and it’s so easy to get on a wrong track vs. following one installation process. Either way, I think I have the combo that did it for me once and for all.

Credit to these folks:

Originally, I followed one guy’s take on it all and ended up with no mysql database and completely locked out of the root user (with or without password attempts; cute, I know). So! I decided to start over. But nooOOooo you need to COMPLETELY removed all MySQL fun from your drive before trying again. That uninstallation link above was the key to that. I missed a few files and especially the logged history notes. Time to put the Joe Schmoe blogs aside and stick to basics. (I know, I know — KISS). I stuck to the walkthrough suggestions and simply downloaded from MySQL dev site and followed those steps. To immediately avoid the root battles, I decided to try the “mysqladmin -u root -p ‘PASSWORD'” immediately. SEEMED to work from there, but I wasn’t convinced thanks to my earlier walls. I ran the mysql_secure_installation script in order verify my user settings and to get things locked down and cleaned up from the start. I was able to update the root password at this point if I’d like, which was NICE. This little process (much like CakePHP bake) helps you clean up your testing databases/usernames to prep for production. Given that I’m simply transferring servers, I’m all about getting the production replica in place and nixing the test gear. Sweet success!

Now I can finally put things back into place. Again, I’m fully aware that this isn’t something ‘hard’; it’s just finicky and my attention span can be rough. I found solace in the fact that most walkthroughs reference the notorious 2002 socket fix, which reminds me that there are still nuances in this whole MySQL process. I’m sure Oracle is battling to make it even tougher to fork out in the future, too. Apple always had MySQL in their Server Admin services list until the recent OS releases. I see a pattern! ::sigh:: Hello, MariaDB!

Well that’s all for now. Happy coding (now that you can)!

Back to Stack Dog

The Neverending Text Edi-Tour

I hope you read that title and immediately started singing like I did. No? Oooookay…

Eh hem…I was unexpectedly persuaded into trying a new text editor, Sublime Text 2, despite having downloaded the newly-released and highly-anticipated Coda 2 this year. While Sublime was downloading, I began to recap the “text edi-tour” that I inadvertently traveled throughout my career and debated whether or not an ideal editor actually exists for me. Yes, there are so many out there that can fit any particular niche, but I can’t help but notice that many editors are extremely gimmicky or bloated. “Look! This one fills in your pages with lines from Nicolas Cage movies!”, “Awesome!! This one visually renders any move or change you make!”, “OMG this one plays the entire Rocky theme song every time your function fires without an error!”

I realize that some folks love the extra bells and whistles, but I see them as a distraction from actually, ya know, writing code. Perhaps I’m just a creature of habit; why stop using the tool that lets me get right to the point? Why give that up to endure the learning curve in a new software that potentially sucks? Well, today I found out why it pays off to keep an open mind with editors.

I was going “oooOooo” within fifteen minutes of using Sublime Text 2. Despite using the spanking new Coda 2, I was still doing happy dances due to the subtle features and streamlined feel of Sublime. You mean I can add any sort of open-sourced package to my editor by using a shortcut and a quick download?! I can find designed themes that soothe my screen-squinting headaches!? You mean it writes big chunks of code in place of a simple word trigger?! Okay, I’m even going to get granular here and mention how happy I was to see that it would simply open a file on a single click, but would tab the file for further use if double-clicked. SO good! No more ongoing tabs of files that I barely edited.

Before I get ahead of myself, I will stay fair and mention the excessive number of questionable [hilarious] packages available to us. One in particular caught my eye and perfectly fits in with the “super unproductive” scenarios I listed: Hipster Ipsum

Yup! You read that right. “Hipster w/ a shot of Latin.” Ah yes. Just what the dev world needs. But I have to say that sometimes a grueling project full of boring content and repetitive functions could take a shot of this kind of nonsense. Dare I say I might use Hipster Ipsum someday? Eh, doubtful.

So from a pen and paper to Notepad, Dreamweaver, jEdit, BBEdit, TextWrangler, Vim, vi, Eclipse, Coda, and now Sublime — have I found my ideal text editor? I’m thinking yes! Seriously, I encourage any developer to try it out. I was very skeptical, but Sublime is truly a simplified yet super powerful means of streamlining your workflow. We may never reach the end of the edi-tour, but at least keep an open mind and help yourself find a decent resting spot along the way :)

Happy coding!

 

 

 

Back to Stack Dog