Linux

Linux tricks and hints, news, source code, software…

Effective DOS attacks against web application platforms

0

Interesting video:

Ubuntu 10.04 Lucid Lynx in Eee PC 1101HA

0

There’s new Ubuntu version and of course some drivers don’t work properly in the Netbook….

To fix the Video card:

UPDATE:
Finally something that works good, and official.

wget http://dl.dropbox.com/u/1338581/Gma500/scripts/poulsbo.sh && sh ./poulsbo.sh

(more…)

Delete SVN files in Linux

0

I use SVN kind of a lot, and when I need to pack the files to distribute them is not nice to leave the SVN files..Here a really simple way of deleting those anoying files:

find . -name '.svn' -type d | xargs rm -rf

This searches for all directories which have svn related files. This is a useful command, but might not work as expected if there are hundreds of thousands files on the server. In this case the following command may be useful:

find . -name .svn -prune -exec rm -rf {} \;

Source devarticles.in

Cache up to 30 times faster

2

Is not bullshit I swear! Absolutely possible, but you need to be using a VPS or a dedicated server to do this.

This is really handy if you are not using a cache system such as APC or xcache, and you store your cached files in folders.

For this we will use TMPFS

Tmpfs is like a ramdisk, but different. Like a ramdisk, tmpfs can use your RAM, but it can also use your swap devices for storage. And while a traditional ramdisk is a block device and requires a mkfs command of some kind before you can actually use it, tmpfs is a filesystem, not a block device; you just mount it, and it’s there. All in all, this makes tmpfs the niftiest RAM-based filesystem I’ve had the opportunity to meet.

Example to use it in your WordPress:
(check the right paths)

Edit /etc/fstab/ and we add the file system

tmpfs /home/neo22s/wp-content/cache tmpfs defaults,size=2g,noexec,nosuid,uid=648,gid=648,mode=1755 0 0

Add a new line at /etc/rc.local in order to execute it on system start up:

ionice -c3 -n7 nice -n 19 rsync -ahv --stats --delete /_b/tmpfs/cache/ /home/neo22s/wp-content/cache/ 1>/dev/null

New crontab job (using crontab-e), to execute

*/5 * * * * /usr/bin/ionice -c3 -n7 /bin/nice -n 19 /usr/bin/rsync -ah --stats --delete /home/neo22s/wp-content/cache/ /_b/tmpfs/cache/ 1>/dev/null

Done!

Currently I’m not using this method since I have xcache that make my life easier working with w3 total cache plugin, great solution.

Of course you can use TMPFS for many other things, check askapache, where you can find loads of info and examples a great work.

How to redirect your RSS Feed to Feedburner

0

This is a really simple yet handly tip to redirect your feed to Feedburner.

Edit, or create an .htaccess file in your htdocs root, and add this lines:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_USER_AGENT} !FeedBurner
RewriteRule ^rss/$ http://feeds.feedburner.com/yourURL [R,L]
</IfModule>

Now any request to yoursite.com/feed will be redirected to the custom feedburner feed ;)

Be aware that only works in apache.

Site in Maintenance using .htaccess

2

Redirect your visitor to maintenance page is a must when you are upgrading your site. Now you can redirect your user to maintenance page easily by using .htaccess file. I guess you do not want your visitor to see an error page or 404 page during your server upgrade. So just follow the steps below to create a .htaccess file to redirect your visitor to maintenance page during upgrade:

1- Create a file and name it .htaccess with the content below:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.html$ 
RewriteRule $ /maintenance.html [R=302,L]

(more…)

.htaccess for Dreamhost users

9

If any of you it’s currently using Dreamhost as Hosting provider, since yesterday they had made some modificataions deprecating “Options +FollowSymlinks”.

This means your site will return an 500 Error.

After talking to the support for more than 1 hour they admitted they have made changes in the policies and now we should use “Options +SymLinksIfOwnerMatch” instead.

Pretty bad communication from them and making this changes without noticing them.

If you are affected by this issue, please your .htaccess for Open Classifieds should look like this to get to work:

ErrorDocument 404 /
Options +SymLinksIfOwnerMatch
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^category/(.+) index.php?category=$1
RewriteRule ^offer/(.+) index.php?category=$1&type=0
RewriteRule ^need/(.+) index.php?category=$1&type=1
RewriteRule ^type/(.+) index.php?type=$1
RewriteRule ^publish-a-new-ad-for-free/ new/index.php
RewriteRule ^contact/ contact/index.php
RewriteRule ^privacy-policy/ privacy/index.php
RewriteRule ^sitemap/ sitemap/index.php
RewriteRule ^advanced-search/ search/index.php
RewriteRule ^map/ map/index.php
RewriteRule ^(.+)/(.+)/(.+)/(.+)$ item.php?item=$1&type=$2&category=$3&title=$4
</IfModule>

Remember that needs to be in your language.

This would be fixed for Open Classifieds 1.6.1 that is coming soon with few improvements to make your life easier.

I’m getting pretty annoyed by this hosting, since I use a Privvate Server and this things should never happen (as this other one http://j.mp/d8WVXY).

More or support for Open Classifieds in the forum.

Ubuntu 9.10 Karmic Koala in Eee PC 1101HA

9

Since I bought my beloved Eee PC 1101HA (wonderful screen and battery life), I’ve been using Ubuntu 9.04, yesterday I’ve decided to upgrade to Karmic Koala.
eee pc 1101ha Ubuntu 9.10 Karmic Koala in Eee PC 1101HA

When I’ve installed 9.04, I had problem with the network (wifi and ethernet drivers), and the display drivers. That was all, the rest was great.

When I did the upgrade, the display once more was not working properly but the worst was the speed connection, awful.

Then I’ve decided to do a fresh clean installation: (more…)

Spotify links in Chrome on Gnome/Ubuntu

16

I like spotify a lot, but was bothering to me a lot that I couldn’t open the links in Chrome…

After trying few solutions (for KDE, gnome ), I finally managed to make it work:

First you need to install Spotify in linux

At the console we create this script:

echo '#!/bin/sh' > ~/.browser2spotify
echo 'wine  "$HOME/.wine/drive_c/Program Files/Spotify/spotify.exe" /uri "$@"' >> ~/.browser2spotify
chmod 755 ~/.browser2spotify

Then we change few options from gnome to know what to do with the url’s:

gconftool-2 -t string -s /desktop/gnome/url-handlers/spotify/command "/home/${USER}/.browser2spotify %s"
gconftool-2 -s /desktop/gnome/url-handlers/spotify/needs_terminal false -t bool
gconftool-2 -s /desktop/gnome/url-handlers/spotify/enabled true -t bool

Remember to replace the user name in the folder.

That’s all!

To see if it works, try to open this any from this list:

Top 100 2009 PlayList
(more…)

Free SMS Notification for high server load

9

I’ve found in foros.ovh this interesting script that notifies high server load to you using an SMS.

All of this works thanks Google Calendar and his API.

Steps:

  • First of all you need a google account and then sign in google calendar.
  • Then go to your google calendar -> settings (right top bar) -> mobile setup
  • Follow the instructions to add you phone number.
  • After this Settings->Calendar Settings and in any of them click on Notifications.
  • Create an Event reminders, SMS 0 Minutes.

With this, now every time we create a new event in google calendar just on the time (because of that 0 minutes) we will receive an SMS to our phone.

Try it, come on!

The Script:

To make this script work you need to have Zend Gdata (http://framework.zend.com/download/gdata/) downloaded or you can download the script + Zend Gdata here.

// Config
define('EMAIL','[email protected]');//gmail account used in google calendar
define('PASS','xxx');//your gmail password
define('SERVER_NAME','your_servername');//just as reference server name
//level of avg load http://php.net/manual/en/function.sys-getloadavg.php
define('LEVEL_EMAIL',3);//load average to notify by email
define('LEVEL_SMS',5);//load average to notify by sms
// End Config
 
//Loading Zend_Gdata libraries
ini_set('include_path', 'ZendGdata/library');
require_once 'Zend/Loader.php';
Zend_Loader::loadClass('Zend_Gdata');
Zend_Loader::loadClass('Zend_Gdata_AuthSub');
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
Zend_Loader::loadClass('Zend_Gdata_Calendar');
//End Loading Zend_Gdata libraries
 
// Function to create a new Google Calendar event
function createQuickAddEvent ($client, $quickAddText) {
  $gdataCal = new Zend_Gdata_Calendar($client);
  $event = $gdataCal->newEventEntry();
  $event->content = $gdataCal->newContent($quickAddText);
  $event->quickAdd = $gdataCal->newQuickAdd('true');
  $newEvent = $gdataCal->insertEvent($event);
}
// End Function to create a new Google Calendar event
 
 
//load average
if (function_exists(sys_getloadavg)){
	$load=sys_getloadavg();
	$load=$load[0];
}
else{
	$content = file_get_contents("/proc/loadavg");
	$loadavg = explode(" ", $content);
	$load = $loadavg[0] + 0;
}
//end load average
 
 
//NOTIFICATIONS
 
// Email - Send email notification
if($load >= LEVEL_EMAIL){
    mail(EMAIL, "Alarm high server load (".$load.") ".SERVER_NAME, "");
}
 
//SMS - Add Event in Google Calendar
if($load >= LEVEL_SMS){
    $text = "Alarm high server load (".$load.") ".SERVER_NAME;
    $service = Zend_Gdata_Calendar::AUTH_SERVICE_NAME; // service name Google Calendar
    $client = Zend_Gdata_ClientLogin::getHttpClient(EMAIL,PASS,$service);
 
    // Hour and minute with 2 minutes delayment
    $hour= date("H");
    $minute= date("i")+2;
 
    // Creates the event in Google Calendar
    createQuickAddEvent($client, $text." ".$hour.":".$minute);
}    
//END NOTIFICATIONS

Now just put the script in you cron for example every 15 minutes,

*/15 * * * * /root/scripts/SMS_High_Server_Load/sms-load.php >/dev/null 2>&1

Other ideas, using this system is to send SMS when your site is down with this script.

Page 1 of 3123
Go to Top