Archive for category Linux / Freebsd

Updating/Installing wordpress themes or plugins without having to enter FTP info

I first saw this in action when I setup wordpress on a shared host after running it on my dedicated server for years.  All of a sudden when I clicked ‘install’ there was no FTP prompt, the bloody thing just installed!  I was amazed at this new development and looked into how it was done.

Simple enough if you don’t mind editing a file and changing some perms.

  1. First you need to make sure that the wp-content(and plugins and themes) directories are owned by your apache process.. in FreeBSD it’s httpd in linux it’s www-data
  2. Next you should chmod the wp-content, plugins and themes directory to 755.  For some reason WP hates things at 777
  3. Lastly you need to add this little line of code to the bottom of your wp-config.php file: define(‘FS_METHOD’, ‘direct’);
And that does it, from now on no more ftp credentials.. Huzzah!

 

Tags: , , , , ,

Attracta? More like Attacka! Horrible SEO service destroys server

Wow, a 2 day hellish experience has finally come to an end.  My CPU usage spiked up to 100% from 20% 3 days ago for no apparent fault of my own, IE: nothing had been done to or changed on the server at all.  The techs at my hosting company just assumed it was wordpress and drupal causing this havoc pushing me to upgrade to a VPS account but I, the only one who left the rational part of their brain on that day, knew better.  I mean I could literally see the minute when the spike happened and it didnt’ go down since so I knew this wasn’t something that I needed to throw more CPU power at.  The first thing I did was to check awstats and see if I was suddenly blessed with a page 1 ranking on google and was being flooded with traffic but I wasn’t.. So like a zombie I went through all of my sites, updating WordPress, implementing more aggressive caching, going through the nightmare of setting up caching for authenticated users on drupal(try doinig it with ACL installed if you think it’s so easy) and in the end no results.. So I moved my 3 biggest sites off that server onto one of my colo boxes and still nothing.  It took me a full 24 hours before I thought to check the access logs and shit on me, there it was.. I was getting upwards of 5 page requests per second per site(there’s 7 of them) from one IP address:  72.5.66.82.  A quick little bit of geoloco work and what do you know? It’s bloody attracta’s crawler, going balistic on my server.  I block that IP and surprisingly enough the CPU usage dropped like a rock, ram usage went down 10 fold.

Of course the next day it was back up again and of course Attracta’s crawler has more than 1 IP.  So I blocked the whole fucking range and now my CPU usage went from 100% down to 5% and on the plus side I have an even better, more effective caching scheme setup across the board.  Huzzah!

 

Morale of the story, steer cleer of Attracta unless you want to sign your server up to be a banquet.

Tags: , , , , , ,

WordPress Multisite and Nginx don’t play nice together

So you’ve just installed or upgraded to WordPress Multisite and upon checking out your first network site you are greeted with a page full of broken images.  Wondering why?  Well if you are using Nginx and apache chances are you’ll need to tell nginx to stop running on that domain, or at leaset tone it down to a bare min.  For me I have nginx detect which kinds of files are being loaded and if it’s one of a select few like images or css files it goes through nginx, everything else and it goes through apache.  All I had to do to fix my broken image problem was to go into my vhost file and limit nginx to simply .ico files for the domain in question.

 

Hope that helps

Tags: , , , ,

Pipe commands/output directly into your clipboard

Ah, I had this thought today while running cat on a php file that it would really be nice if, instead of catting the file and then selecting the output in terminal, scrolling up, all the way up and copying it, I could just run cat on a file and have the output go directly to my clipboard.  Well this is linux baby so OF COURSE you can do that because it just makes a whole lotta fricken sense.

I needed to go and installed a little program called ‘xclip’ and after that all I had to do was type: cat file.php | xclip and guess what’s sitting in my secondary clipboard? Ooh yea, the bloody contents of file.php.

The funny thing is that by default the input should go into my primary clipboard(ctrl+v) but it goes into my secondary clipboard instead(middle mouse-button).  Anyways, to get around that all I need to do is type: cat file.php | xclip -selection c  and it ends up in the primary clipboard.

Either way, this is definitely one of the damned coolest things I’ve discovered in linux for a while!  Yay for efficiency!

Tags: , , , , , , ,

phpmyadmin security measures on a Debian webserver

Well I had a rude awakening today that clearly showed my FreeBSD upbringing.  You see when you install phpmyadmin on FreeBSD it leaves it up to YOU to create the alias paths and whatnot.  Meaning that if you do nothing the system will remain as secure as possible, in linux the philosophy is very different, even in Debian.  In linux it figures that if you’re installing phpmyadmin that of course you are going to want a global alias installed so that anyone on any domain can just tack ‘phpmyadmin’ on the end of their domain and they will have access to phpmyadmin.  So if you do nothing in linux it will install the aliases by default which clearly creates a massive vulnerability as your mysql database and consequentially key parts of your system are wide open to anyone or anything that has half a brain to try that alias.

Of course to any security minded person this is complete and utter horse shit and if the sysadmin is too lazy or doesn’t know how to create an alias then he/she has no bloody right admining the box in the first place.  So anyways, I installed phpmyadmin a long time ago and instinctually, being a BSD boy through and through I figured I had to setup the alias manually. And of course instead of setting up a global alias I set it to one single domain on the entire server and of course instead of having the alias be phpmyadmin I set it to something cryptic that no one is going to guess.  I wiped my hands clean knowing my server was somewhat secure with phpmyadmin installed and never looked back…. Until tonight.

I log into my server and notice that instead of my usual .20 server load it is sitting at .6 with twice the httpd procs running.  This tips me off that someone or something is sniffing around where they shouldn’t be and so I open up lsof and ping the top apache proc.  Going through the list I find an error log being written to a LOT and so upon investigation of that log I see every 5 minuets something is pinging phpmyadmin/setup.php.  I thank my lucky stars that I deleted that file after installation and of course laugh because this bot is obviously looking at something that doesn’t exist.  I stopped laughing when I noticed that the error log was saying that /usr/share/phpmyadmin/setup.php doesn’t exist NOT domain.com/phpmyadmin/setup.php doesn’t exist.. This mean that /phpmyadmin/ was still aliasing to /usr/share/phpmyadmin and that’s when I lost it and started screaming bloody murder at this carebear fucking operating system that accomodates lazy fucking admins at the expense of security.. GGAAHHH!!!

Of course in freebsd we don’t have conf directories and .conf files for every god damn thing that is installed, with apache it pretty much all goes into the httpd.conf, hell on my last server the apache config AND the vhosts all went in httpd.conf.  Given that’s not the best wayt o do it but hey, I’m old school I was trained by men who came from simpler times.   Anyways back to Debian, I went into /etc/apache2 ran #find. -exec grep -H phpmyadmin {} \; and sure enough there inside /etc/apache2/conf.d was a phpmyadmin.conf file with all of the open, unsecure bullshit that came with it.  GAH! Have I said GAH yet?!? Because GGAAHHHHH!!! Who the hell is thinking this is a good idea to do BY DEFAULT?!?!   Anyways, I moved the god damn file out of there, restarted the webserver and made sure that my private phpmyadmin url was working, which it was and guess who’s not pinging my server every god damn second anymore?  Those hackers..

 

So, lesson to the learned:

First off, if you want to run phpmyadmin because of how convenient it makes your life, don’t install a global alias, you are just asking to get raped by every script kiddie in Russia.  Install a local alias on one domain and call it something like ‘managemysql’ or whatever floats your boat

Second: After you’ve done the first step go and delete the god damn POS .conf file that is created by phpmyadmin in /etc/apache2/conf.d and enjoy an infinitely more secure server.

 

 

My heart felt thanks go out to the miserable cunt of a sysadmin that I worked with for years that trained me in all of these secrets.  Thank you thank you thank you!

Tags: , , , , , , ,

How to extract Audio from a Video file in Linux

Yet another area where I rejoice for being a linux user as this shit is sooo much easier and faster in linux than it is in windows using a completely unnecessary GUI.  There are two ways to do this but I’ve always found that ffmpeg works best over mplayer.. However I’ll post both of them here regardless:

ffmpeg -i inputfile.avi -acodec copy -ab 128 outputfile.mp3 

As mentioned in a previous article you might run into some codec errors and that is why we have the -acodec copy option in there.  the -ab sets your audio bitrate we I beleive defaults to 64k if you don’t specify differently

The mplayer option which I haven’t played around with would be

mplayer -dumpaudio my_video_file.avi -dumpfile extracted_audio.mp3

 

Many thanks to DailyGyan for the tips in the first place:


Tags: , , , , , ,

Transmission doesn’t work in Debian

Well I’ve been a long time supporter of transmission but I finally had to throw in the towel today..  At first I thought it was my network issues but upon fixing the issues and loading up my much anticipated torrents from etn.fm i was still getting zero downloads.  Booooerns!  I ran some network tests and it always comes back with every port being blocked.  Now this is completely bupkis as it works fine in windows so out of curiosity I installed Vuze to see if it might just be transmission.

At first the vuze network tests came back with some NAT errors telling me that I needed to setup my portforwarding but while I was doing that I noticed that the torrent i had loaded in there had already started downloading and within 30 seconds I had a dozen or so peers and a download speed of 15 Mbits.

 

So this whole time I had been giving transmission the benefit of the doubt, blaming the router, blaming the wifi and the whole time it was Transmission that was sucking the big dick.  So thanks for the few good years transmission but it’s time for your broken ass to get the fuck out of Debian and make room for something that works.

Tags: , , , , , , ,

Horribly bad, god awful wireless network performance in Debian

This has been plaguing me ever since I switched from Ubuntu to Debian and to be honest the wireless performance wasn’t all that hot in Ubuntu either.  For the record this is on an AMD E350 which has a Atheros Communications Inc. AR9287 Wireless Network Adapter in it.  There has been a myriad of problems since day one..  Some wireless networks I just couldn’t connect to at all, although this was rare.  The most common issue here is that it was completely impossible to maintain a consistent download or upload.   It would connect to the site just fine, a video would start streaming at 20Mbit for the first 2-3 seconds and then it would drop down to 80kbs and then drop to 0.  Usuallyi I’d have to refresh the page and then everything would go tickity boo.. Not all the time mind you but I’d say about 40% of the time I wouldn’t be able to finish and upload or a download or at the very least it’d truck along at 15-30kbs on a 20Mbit connection.

Today I did some digging around and found a fwe things.  One thing I noticed in dmesg was this:

[ 42.256178] wlan0: deauthenticating from 38:60:77:84:3b:f1 by local choice (reason=3) .  While I don’t knwo if this is related it did spur me to do some more focused searches.  In the end I think I have a solution here that is working great as I just watched 9 streaming videos at a steady 500kbs without interruption.  It’s doesn’t even feel natural because it’s been so long since I’ve enjoyed uninterrupted video.  Anyways here’s what I did

 

Completely uninstalled network-manager.  I’ve read that simply shutting down the server isn’t enough, you need to take this fucker out all together.. I’ve been using WICD and disabling WIFI on the Network Manager but always kept it on just because it seemed that 1 out of 20 networks worked better with it.  Well I’ll cross that bridge when I get to it but from what I’ve heard getting rid of this alone is enough to solve most wifi issues

Second thing I did was to completely disable IPV6.  Now this is painful as I really want to be on the transition towards this protocol for many reasons but after doing a little research, seeing that it only has a .85% adoption rate I’m ok not using it for the time being.  So how to disable IPV6 you ask?  Well if I remember correctly I completely removed the module in the past so lsmod reveals no IPV6 related stuff but apparently this isn’t enough.  On top of that I commented out the lines in my /etc/host file that had to do with ipv6.

# The following lines are desirable for IPv6 capable hosts
#::1 ip6-localhost ip6-loopback
#fe00::0 ip6-localnet
#ff00::0 ip6-mcastprefix
#ff02::1 ip6-allnodes
#ff02::2 ip6-allrouters

The next thing I did was specify that IPV6 should be off in my /etc/modprobe.d/aliases.conf file like this:

alias net-pf-10 ipv6 off

You’ll probably have a line like this:

# alias net-pf-10 ipv6

and you’ll need to uncomment it and add an ‘off” to the end.  After that I restarted the machine and everything was dandy.. Hope that helps anyone else going through this crapola

Tags: , , , , ,

ffmpeg: Unsupported codec for output stream #0.0

Alrighty, so I was attempting to extract the audio from an .avi file today and was greeted with the following error:

Unsupported codec for output stream #0.0

At first I thought this was the result of my missing the libavcodec packages but upon closer inspection and a little forum reading I realized that the error I was seeing (#0.0 not #0.1).  #0.0 refers to VIDEO and not audio as I had previous thought and so installing the audio packages did nothing to resolve my issue.

So, how to solve this problem you ask? Well that’s as simple as adding a nice little switch and extra optino in there that looks a little bit like this:

-acodec copy

Solves the problem immediate.. From what I understand it just means that if the codec doesn’t exist to decode the video ffmpeg can use a copy of one instead.  Easy peasy lemonsqueezy

 

Oh and for anyone wanting to know how to extract audio from a video file it’s as simple as this:

ffmpeg -i inputfile.avi -acodec copy -ab 256 outputfile.avi

 

Tags: , , , ,

Page optimized by WP Minify WordPress Plugin