Posts Tagged freebsd

The difference between a tuned performance BSD webserver and a stock linux webserver

First up we have a tuned FreeBSD 8.1 server running Apache 2.2(clearly working up a sweat)

56MB of virtual memory and 40MB of resident memory usage

PID USERNAME THR PRI NICE SIZE RES STATE C TIME WCPU COMMAND
55392 www 1 106 0 56460K 39664K CPU2 2 15:43 50.49% httpd

 

Follow that up with what is probably a pretty stock linux server running apache 2.2.

98MB or virtual memory usage and 73MB of resident.

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
7546 nobody 15 0 98648 73m 2040 S 0.7 1.0 0:00.53 httpd

 

That’s nearly HALF the memory usage for 2 servers doing exactly the same thing running exactly the same software minus the OS.  See kids, it pays to play with your httpd.conf :)  The irony of course is that the tuned server has 2GB of ram and the stock server has 16GB.  Oh well :)

Search the blog for tuning tips but one of the key things is knowing what every apache module does and ditching absolutely every single one you don’t absolutely need.  Trim the fat off apache and then you can work on tuning the actual settings in apache.

PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND

Tags: , , , , , , ,

ATTN FreeBSD users – Throw Zend in the trash as that shit won’t work at all in 3 months

Well as some of you may or may not know php 5.2 is going to be going the way of the dinosaur come March, it’s already been depreciated and no longer being supported but in March it’s being removed from the port tree all together from what I understand.  This brings me to the topic of today’s post which is that the kind folks over at Zend have made it abundantly clear(Refer to this) that they have no intention of supporting FreeBSD at all in the future with their new products, Zend Guard in particular.  The catch here is that Zend Optimizer, the one product that does work with FreeBSD is also depreciated and does not work with php 5.3.  Come March, unless you plan on using a completely vulnerable and exploitable version of php Zend Optimizer will no longer work at all.

So the moral and point of this whole post is to give you a little warning so you can make arrangements.  It means getting rid of this Zend bullshit and make sure that you account for all your software currently encoded with Zend and get onto something not governed by such old world profit driven business models to something more progressive like Ioncube.

 

Prepare ye mortals, the end is nigh! 

Tags: , , , , , ,

Openx Hell – Upgrading to 2.8.7

So I was finally forced to upgraded to 2.8.7 when my previous install was hacked thanks to a security vulnerability in 2.8.2.  I knew there was a reason I was holding off on this because when I cleaned out the hack and upgraded I was greeted with an infinite look between admin/index.php and admin/install.php.   Solving this was silly enough, I just went in and made sure that the permissions in the openx directory were as they were supposed to be according to the install file and then I created a directory called ‘UPGRADE’ in openx/var then tried to log in.. No loop this time, instead I was told that my openx was already upgraded and I needed to remove the UPGRADE dir and then click continue..  I removed the dir, clicked continue and then was able to log in.. Phew.. Unfortunately after that my plugins were all messed and just when I was about to light my hair on fire I stumbled across the following tutorial here:  http://forum.openx.org/index.php?showtopic=503492171

 

1) Download 2.8.7 – http://www.openx.org/products/source-download

2) Back up your database and openx files

3) Copy your /var/www.example.com.conf.php and images directories over per step 5 here http://www.openx.org/docs/upgrading-openx

4) Disable maintenance

5) Remove your openx folder, and put the fresh install in its place (see notes below). You’ll have to do this anyway if you have an install in the root rather than a directory.

6) Go to your openx root http://www.example.com/openx and follow the upgrade instructions.

6.1) This point is moot for my install instructions but I’ll include it for completeness. When it asks you to enter the path for your *previous* openx installation (http://www.openx.org/files/docs_28/admin_guide/install_configuration-previous.png), ENTER THE NEW PATH. I mention this because many people (like myself) were trying (as the docs told us) to install into a openx_new folder. If you do this and enter the previous path as asked, you will *not* be able to proceed in the installation as it will throw all kinds of errors at you. The only way to proceed if you are using the openx_new method is to enter the NEW path.

6.2) The upgrade wizard should progress smoothly, all plugins will fail but it will let you proceed.

7) Go here and verify you are on 2.8.7 – /www/admin/updates-product.php

8) Ignore the advice here (http://forum.openx.org/index.php?showtopic=503426422) and instead get the 2.8.7 plugins from here https://svn.openx.org/openx/tags/2.8/openx-….7/etc/plugins/ – download all of these and save them into a folder

9) Now the fun begins… open two windows….

First window: /www/admin/plugin-index.php
Second window: /www/admin/maintenance-plugins.php?action=rep

9.1) Ok now go to the second window and run the plugin report. You’ll see lots of errors. Your end goal is for all these to show “No Errors”.

9.2) Go to the first window and click browse, and select one of the zip files. It will install, throw lots of errors. Starting at the top, work your way down through the list. You should see that at least a few of the plugs now have “Disable” next to them instead of “Install”. This is good.

9.3) Repeat step 9.2 over and over again until all the plugins have “Disable” next to them. I think that as you go on, you don’t need to run through the whole list each time, and can focus just on choosing plugins that haven’t installed yet. There appears to be a very complicated sequence of dependencies, I have no idea what the “shortest path” is. When all the plugins look installed, it’s time to proceed to 9.4..

9.4) Go to the second window and run a plugin report. You may see that some of the plugs still show they have errors. For those plugins, go back to the first window and reinstall them (even though they look like they’ve installed). There seems to be a second layer of dependencies that don’t show up on this screen and can be verified only with the second window.

9.5) Go back to the second window and check the status of the plugins. Repeat step 9.4 until all plugins show “No Errors”

10) Clean everything up by going to /www/admin/maintenance-plugins.php and running ALL the rebuild commands on the page.

11) You’re done! If this has helped you, I would love to hear it.

Tags: , , , , ,

Importing 1000′s of posts, publishing 1000′s of drafts and mysql fun

Alright so for one of my side businesses I am using wordpress as a platform to create large directories for businesses to use to find other businesses.  It’s like a big ass yellow pages but for specific businesses.  Anyways part of the fun has been figuring out how to get 5000-6000 listings per city into a wordpress blog as painlessly as possible and it has been anything but painless figuring it out.  So through my blood sweat and tears I have learned a few things and figured I’d share 3 or 4 of them to make someone elses life a little less dreadful.

*PS: You need to be root on your server for this to work, if you aren’t don’t waste your time cause none of this will work*

*PPS: Read this article all the way through before doing anything or you’re going to spend time redoing shit*

1.) Importing a shit-ton of posts

So after you’ve put together the 1000′s of posts you need to get it into wordpress.  A decent tool for the job is CVS-importer [Found HERE].  I have it importing upwards of 6000 posts in under 5 minutes, but only after I’ve tweaked mysql some.  If you are running on a share server where you don’t have root access to mysql you’re going to have a hell of a time getting this to work with large numbers of posts.  Under default mysql configurations I’ve gotten it to import 400 posts in a go but anything over that and it started to peter out.  In section 3 I’ll go over some mysql tweaks.

Now the one key element to this working out is that you have to have CVS-Importer publish all of your posts as DRAFT.  Make bloody well sure that is checked or else the thing will croak on you.. For whatever reason I can import 2000 posts in 150 seconds as drafts but doing 500 as published posts hangs the system.  No clue why, but that’s the rub on that

2.) Publishing 1000′s of draft posts at once

So at first glance this looks to be a pretty f’ing daunting task.  You’ve got 5000 posts sitting as drafts and publishing them 10 or 20 at a time is giong to take forever.  Well it still will take a while but a hell of a lot less than you think.

Login to your box, go into mysql, use the wordpress database your are importing all these posts into and do the following

UPDATE wp_posts  SET post_status = 'publish' WHERE post_status != 'static';

replace PUBLISH with with either draft, private, or publish and viola.

Alternatively if you want to just do this on a per author basis do the following from inside mysql:

UPDATE wp_posts SET post_status='publish' WHERE post_author='NUMBER';

Again replacing PUBLISH and also replacing NUMBER with the ID # of whatever user you are importing these posts under.

Viola, 10000 posts published in less than 20 seconds :)

*Alternatively this sort of thing can be done from phpMyadmin if you dont’ want to go through shell, in which case I’d also recommend picking up some pampers at Wal-Mart right now as they are on sale :p *

A huge thanks to WPMU.org for the above tip, man that girl just saved me hours of work: http://wpmu.org/daily-tip-bulk-edit-of-the-status-field-for-all-posts-in-wordpress-database/

3.)Tweaking Mysql

Something I figured out when first trying to import large numbers was that the default mysql install was not setup with this kind of thing in mind, so there’s a bit of tweaking you’re going to have to do to help it handle the amount of data coming in and I’m guessing also the way that this plugin imports things.

Mainly you need to increase key_buffer_size from 128 up to somewhere around 384M.  I didn’t test it with a ton of posts at 256M but it did work for a couple thousand.  The key here is to tweak it so it is using just enough memory to do what you want but not a drop more.  For me with big imports of 6000-7000 posts 384M did the trick, but there are a couple of new blogs coming up with 20,000 + posts in them so chances are I might have to temporarily increase it for those and then probably scale it back down once that is done.

I am running FreeBSD and for me I have to edit my /etc/my.cnf and add the following line:

[mysqld]
key_buffer_size=384M

That should just about do it, was yet another big day of learning today so I thought I’d share a little bit as there isn’t a lot of resources out there for this sort of thing.. Also I’ll freely admit that wordpress probably isn’t the best platform to be doing this sort of thing on in general, if you can get away with a specific piece of software for directories you’d be better off.  Hell I imagine joomla or drupal would probably be more efficient but for how I am structuring everything wordpress was the name of the game.

414 Request-URI Too Large

414 Request-URI Too Large

Tags: , , , , , , , , ,

FreeBSD 8.1, Zend Optimizer, php52-extensions and the dreaded Segmentation Fault (Core Dumped)

So I haven’t slept in 43 hours, it’s been at least 10 years since I’ve pulled this kind of stunt before but as you know from my last blog post here my server blew up and then my lappy blew up, so lots and lots to keep me busy with.. Part of that fun was doing a brand new fresh OS install on my server, and getting everything working just as it was before is never a cakewalk.  Well it was looking like it was until I started seeing this little Segmentation Fault at the end of my php -v statement.  I mean not to mention the 5-6 hours I spent wresting with ZendOptimizer but that was resolved and wasn’t nearly as epic, nor as disappointing at the 20+ hours that went into figuring this god awful problem.

For whatever reason when php52-mysql or php52-pdo_mysql were installed there would always be a segmentation error in shell.  It didn’t affect the websites mind you, that ran fine but running anything with php through shell wasn’t not happening(there goes 1/2 my cron).  So what do I do? I hop on freenode, undernet and efnet and start asking around as well as googling my face off.  And man oh man there are a ton of reasons why this could be happening and trust you me I went through them all.. But the key problem with my problem solving was that I was looking in completely the wrong place.  You see early on I was convinced that this was a php problem.  Probably set that way as an impatient chap named GoMYSQL on #mysql on freenode quite quickly told me it was and to take my question out of his sacred and holy channel.  So for the next 30 hours or so I proceeded to rip the very fabric of php apart in search of what cuold be causing this.  I commented out everything in extensions.ini, in php.ini narrowing it all down to mysql.so or alternatively pdo_mysql.so caused the same problem.   There was talk about the order of the extensions in extensions.ini causing issue so I tried mysql.so in every single spot on that list to no avail, the only thing that made the seg fault go away was to comment out mysql.so itself but then that kind of left me without a slightly important piece of functionality.

Well guess the fuck what?  It isn’t a php issue at all, it is a problem with mysql55.  For whatever reason I installed mysql55 instead of mysql50(bigger is better right?) and whether it’s a conflict with mysql55 and Zend, or Zend, php52-mysql and mysql55, or all of the above and eaccelerator or what but having that version of mysql installed caused this whole mess in the first place.

So her I am, 43 hours later and probably at least a dozen pots of green tea, completely out of option I figure why the hell not try mysql50?  On this old server it’s a hell of a wait to deinstall and recompile but nothing else is working.  Lo and fucking behold the minute it’s up and php52-extentions and php52-mysql are recompiled along side all my worries dissapear.  No more zend seg faults, no more mysql.so seg faults nada, zip zilch.

And for whatever reason this will be the very first post/article anywhere offering this advice because everyone else is dealing with a php issue.  So if this is you, if you have just installed php52 and php52-mysql or php anything-mysql and you are seeing everything loading fine except for mysql.so causing a segmentation fault do yourself a big favor and check what version of mysql you have installed.   If you are running mysql55 and Zend, or eAccelerator and Zend and mysql or any combination of the bunch get rid of mysql55 and install mysql50.  After you’ve done that you’re going to need to recompile php52-mysql and/or php52-pdo_mysql(or whatever version of phpxx-mysql you’re running) and then go in and recompile php52-extensions.  After all that restart apache and go to sleep!

I know that’s exactly what I’m about to do

Tags: , , , , , , , , , , , , , ,

Public Key not working with user@server but does work with root@server

Weirdest thing about my FreeBSD server that’s been bugging me for a long time.. I’m able to create rsa/dsa keys for passwordless logins but the catch was that it would only work if I was root on the client machine loggin in as root on the server.  After 6 hours of trouble shooting and mostly relying on the geniuses over at #freebsdhelp on efnet, running sshd in debug mode, running ssh in -vvv mode it came down to a stupid little error in the /etc/ssh/sshd_config file.

The line in question was:

AuthorizedKeysFile      ~/.ssh/authorized_keys2

and whoever set it up originally bunged it up because it needs to be

AuthorizedKeysFile      %h/.ssh/authorized_keys2

to work properly or else sshd will always refer to /root/.ssh/authorized_keys2 no matter who’s loggin in..

Hopefully this will help someone else save the nearly full work day of time to narrow this mother trucker down

Tags: , , , , , , , , , , ,

Nginx 502 errors, php problems, wordpress, oh my!

Well today is a glorious day as I finally managed to fix a problem that had been haunting my server for a month or so.  In the end it was a solution that I’ve been taught countless times as something I should be doing by default when upgrading php but alas my mind is not on of the more expensive models and so it rarely does what it should..

So it all started with a fairly minor issue I noticed in WordPress.   When I would try to load up the media gallery I would be greeted with a nice 502  Nginx error.  I’m sure if I wasn’t running nginx then it would have a blank white page or an apache error.  So naturally I started with the nginx error logs which didn’t lead to much.. Then I setup php to log all errors and again that didn’t lead me to much, finally however I monitored my httpd-error.log and this lovely message turned up:

[warn] (2)No such file or directory: Cannot reinit SSLMutex
/libexec/ld-elf.so.1: /usr/local/lib/php/20060613/gd.so: Undefined symbol “zend_parse_parameters_none”

After some asking around on irc I was told that it was definitely a php problem.  Nothing more specific than that, just a php problem.  There were a bunch of forum posts saying it might have something to do with fastCGI but all the suggestions had no effect.  However there was one forum I foudn that through a suggestion out there that lit up a light bulb in my brain.  That being that if php5-extensions isn’t recompiled and reinstalled when php is updated sometimes the fit hits the shan.  Sure enough I had upgrade php5 a while back, and then again since then but hadn’t bothered to recompile the extensions.  Hell I hadn’t even recompiled Zend or Eaccelerator which is pretty standard.

So long story slightly shorter, I went in deinstalled and cleaned up my php5-extensions, reinstalled it and viola, problem solved!!

Tags: , , , , , ,

How to update php5 or any port in BSD

Well I figured I would join the throng of blogs with a brief run down of cvsup , considering I just wrote a nice email about it and all I have to do is copy and paste to share it with the world :

Basically you just need to install cvsup by compiling and installing it

So head over to /usr/ports/net/cvsup and do a make && make install as root

After that is all installed

copy /usr/share/examples/cvsup/ports-supfile to a new location, such as /root or your home directory.
1. Edit ports-supfile you just moved to /root
2. Change CHANGE_THIS.FreeBSD.org to a CVSup server near you.  IE: cvsup.FreeBSD.org
3. You also want to scroll down and make sure the line “ports-all” is commented out and simply scroll down and uncomment out the ports-lang only.  This will make sure it only updates that tree instead of the entire thing.  (however you can ignore that last steo if you want to do a complete update) Save the file
4. Now to run cvsup, use the following:
# csup -L 2 -h cvsup.FreeBSD.org /usr/share/examples/cvsup/ports-supfile

or
# cvsup -L 2 -h cvsup.FreeBSD.org /usr/share/examples/cvsup/ports-supfile

Then go into /usr/ports/lang/php5 and do a quick make(as root) and then make install

Viola php5 is updated

Tags: , , , , ,

Page optimized by WP Minify WordPress Plugin