Showing posts with label ubuntu. Show all posts
Showing posts with label ubuntu. Show all posts

Thursday, April 16, 2009

Ubuntu 9.04: Installing Lighttpd 1.5 from source with PHP + mod_cache

To install PHP:
sudo apt-get install php5-cgi

Installing Lighttpd 1.5
The latest version I could find on their site:
http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModCache
http://opensu.se/~darix/lighttpd/
http://blog.lighttpd.net/articles/tag/1.5.0

wget http://www.lighttpd.net/download/lighttpd-1.5.0-r1992.tar.gz
wget http://www.linux.com.cn/modcache/lighttpd-1.5.0.r2294.modcache.v.1.6.1.tar.gz


This is the patched version of lighttpd with mod_cache, extract this to a folder

tar zxvf lighttpd-1.5.#######.gz
cd lighttpd-1.5.0.cache


We need to install some required libraries first

sudo apt-get install libssl-dev zlib1g-dev libbz2-dev libattr1-dev libpcre3-dev libmysqlclient15-dev libfam-dev libldap2-dev libfcgi-dev libgdbm-dev libmemcache-dev liblua5.1-0-dev pkg-config uuid-dev libsqlite3-dev libxml2-dev libkrb5-dev libglib2.0-dev libaio-dev libfam0 memcached


type ./configure --help to see configuration options

This is what I used
./configure --program-prefix= --prefix=/usr --exec-prefix=/usr --bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc --datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib --libexecdir=/usr/libexec --localstatedir=/var --sharedstatedir=/usr/com --mandir=/usr/share/man --infodir=/usr/share/info --with-openssl --with-memcache --with-gdbm

make

sudo make install


after installing you should be able to type
lighttpd -V

and see some nice output from lighttpd

you can also type spawn-fcgi to make sure that installed as well

type sudo su

copy the sample config file
mkdir /etc/lighttpd
cp doc/lighttpd.conf /etc/lighttpd/

log folder
mkdir /var/log/lighttpd

we need to create a startup file in the /etc/init.d folder
Go here to download the startup script http://redmine.lighttpd.net/projects/lighttpd/wiki/ScriptsUbuntu
create a file called lighttpd in the /etc/init.d/ folder and then
chmod a+x /etc/init.d/lighttpd

Create a user to run lighttpd: if you have installed lighttpd 1.4 from apt or apache you can just use the www-data user again
adduser -m -d /var/www -s /sbin/nologin lighttpd

Modify the lighttpd file from /etc/init.d/ to match the user you want to run it as

chown www-data:www-data /var/log/lighttpd

then type
update-rc.d lighttpd defaults


Edit the lighttpd.conf file to enable php fastcgi

Make sure following modules are loaded:
server.modules += ( "mod_cache" "mod_proxy_core", "mod_proxy_backend_fastcgi" )

You can also enable other modules that you need, mod_cache has to be enable first!
cache.bases = ("/var/cache/lighttpd")
cache.enable = "enable"
cache.support-queries = "enable"
cache.debug = "enable"
cache.dynamic-mode = "enable"
Change
server.document-root = "/var/www/"
server.errorlog = "/var/log/lighttpd/error.log"
server.event-handler = "linux-sysepoll"
server.network-backend = "gthread-aio"
accesslog.filename = "/var/log/lighttpd/access.log"
compress.cache-dir = "/tmp/lighttpd/cache/compress/"
compress.filetype = ("text/plain", "text/html")
#### status module
status.status-url = "/server-status"
status.statistics-url = "/server-statistics"

cache.bases = ("/var/cache/lighttpd")
cache.enable = "enable"
cache.support-queries = "enable"
cache.debug = "enable"
cache.dynamic-mode = "enable"
cache.refresh-pattern = (
"/$" => "5 update-on-refresh no-expire-header", # update homepage every 5 minutes and on refresh requests without setting expire headers
"\.(?i)(flv)$" => "0 fetchall-for-range-request flv-streaming", # to work with mod_flv_streaming for flv files
"\.(?i)(js|css|xml)$" => "240", # update js/css/xml every 4 hours and on refresh requests
"\.(?i)(htm|html|shtml)$" => "30", # update html/htm/shtml every 30 minutes and on refresh requests
"\.(?i)(jpg|bmp|jpeg|gif|png)$" => "2880", # update graphics files every 2 days
"\.(?i)(rar|zip|wmv|avi|mp3|ape|rm|mpeg|mpg|wma|asf|rmvb|flv)$" => "0 fetchall-for-range-request", # cache media file forever
".(?i)php$" => "5", # update php request every 5 minutes
"." => "30 update-on-refresh" # default to update every 30 minutes and on refresh requests
)


Make sure /var/cache/lighttpd is writeable by lighttpd and it exists.

Configure fastcgi PGP module by appending following configuration directives:

$HTTP["url"] =~ "\.php$" {
proxy-core.balancer = "round-robin"
proxy-core.allow-x-sendfile = "enable"
# proxy-core.check-local = "enable"
proxy-core.protocol = "fastcgi"
proxy-core.backends = ( "unix:/tmp/php-fastcgi.sock" )
proxy-core.max-pool-size = 16
proxy-core.worked-with-modcache = "enable"
}


Make sure to leave the # in front of proxy-core.check-local = "enable" otherwise lighttpd won't start, don't know why.

Also don't forget to add proxy-core.worked-with-modcache = "enable" otherwise mod_cache won't do anything.

Save the config file and start lighttpd

sudo /etc/init.d/lighttpd start

If everything goes well you should see something like this
* Starting lighttpd [ OK ]
* Starting spawn-fcgi spawn-fcgi.c.206: child spawned successfully: PID: 15245
[ OK ]

inside the /var/www folder create index.php file and add something to it

test by browsing http://localhost/index.php
You should see php configuration options here


How to uninstall
go back to the lighttpd source
sudo make uninstall


References:
http://redmine.lighttpd.net/projects/lighttpd/wiki/InstallFromSource
http://www.cyberciti.biz/tips/rhel-lighttpd-15-installation-configuration-howto.html
http://www.cyberciti.biz/tips/howto-increase-lighttpd-performance-with-linux-aio.html
http://www.cyberciti.biz/tips/freebsd-linux-lighttpd-1-5-fastcgi-configuration.html
http://www.linux.com.cn/modcache/
http://redmine.lighttpd.net/wiki/lighttpd/Docs:ModCache#Installation

Saturday, April 11, 2009

Traffic Shaping with Lighttpd + PHP

Here's how I manage traffic on my web site that's served over a basic cable connection. The site has a forum and an area for register members to download stuff from. Having a very limited upload capacity I have to make sure members don't suck everything and make the forum unresponsive.

So here's how my lighttpd.conf file is setup:

# this limits the amount of connection a user can make to the server
evasive.max-conns-per-ip = 10

# then on my site configuration I use a combination of connection.kbytes-per-secon and evasive.max-conns-per-ip to throttle user connections to the download script
$HTTP["host"] =~ "sitegeisha\.dyndns\.dk" {
connection.kbytes-per-second = 64
$HTTP["url"] =~ "dl\.php" {
connection.kbytes-per-second = 32
evasive.max-conns-per-ip = 3
}
}

This configuration allows me to limit the number of simultaneous downloads they can make, if they go over 3 they get a 403 error message.

Tuesday, November 11, 2008

Youtube Cache with Squid + Lighttpd on Ubuntu

This summary is not available. Please click here to view the post.

Tuesday, October 14, 2008

Lighttpd - light and fast web server

I've used IIS, then Apache on windows, then switched to LAMP and now I'm on LLMP and couldn't be much happier! Lighttpd lives up to its name, it is fast and easy on server resources. Learning it wasn't so bad, I actually found plenty of resources on the web and the configuration is actually much simpler than apache, also I didn't have to rely on webmin to configure it now.

Here's how I configured Lighttpd to run on Ubuntu 8.10 Intrepid Ibex with xcache, memcache and mysql.

To be continued...

Monday, September 29, 2008

Best recovery tool for Linux is on Windows

hamasaki@Ayumi:~$ sudo reiserfsck --check /dev/sdd
reiserfsck 3.6.19 (2003 www.namesys.com)

************************************************** ***********
** If you are using the latest reiserfsprogs and it fails **
** please email bug reports to reiserfs-list@namesys.com, **
** providing as much information as possible -- your **
** hardware, kernel, patches, settings, all reiserfsck **
** messages (including version), the reiserfsck logfile, **
** check the syslog file for any related information. **
** If you would like advice on using this program, support **
** is available for $25 at www.namesys.com/support.html. **
************************************************** ***********

Will read-only check consistency of the filesystem on /dev/sdd
Will put log info to 'stdout'

Do you want to run this program?[N/Yes] (note need to type Yes if you do):Yes
###########
reiserfsck --check started at Sun Sep 28 22:12:00 2008
###########
Replaying journal..
No transactions found
Checking internal tree..

Bad root block 0. (--rebuild-tree did not complete)

Aborted (core dumped)


WTF does that mean? Well for one it means I can no longer access about 80 gb of data, HANS REISER just murdered my data!!! LOL.... hmmm well back to my data, is it gone now?

Tried to mount the drive... dmesg output when I tried to mount the drive

[12159.408846] ReiserFS: sdd: found reiserfs format "3.6" with standard journal
[12159.408901] ReiserFS: sdd: using ordered data mode
[12159.414282] ReiserFS: sdd: journal params: device sdd, size 8192, journal first block 18, max trans len 1024, max batch 900, max commit age 30, max trans age 30
[12159.415307] ReiserFS: sdd: checking transaction log (sdd)
[12159.998070] ReiserFS: warning: is_tree_node: node level 47354 does not match to the expected one -1
[12159.998089] ReiserFS: sdd: warning: vs-5150: search_by_key: invalid format found in block 0. Fsck?
[12159.998100] ReiserFS: sdd: warning: vs-13070: reiserfs_read_locked_inode: i/o failure occurred trying to find stat data of [1 2 0x0 SD]
[12159.998117] ReiserFS: sdd: Using r5 hash to sort names
[12159.998136] ReiserFS: sdd: warning: xattrs/ACLs enabled and couldn't find/create .reiserfs_priv. Failing mount.
[12202.777292] ReiserFS: sdd: found reiserfs format "3.6" with standard journal
[12202.779625] ReiserFS: sdd: using ordered data mode
[12202.785827] ReiserFS: sdd: journal params: device sdd, size 8192, journal first block 18, max trans len 1024, max batch 900, max commit age 30, max trans age 30
[12202.791682] ReiserFS: sdd: checking transaction log (sdd)
[12203.382859] ReiserFS: warning: is_tree_node: node level 47354 does not match to the expected one -1
[12203.382883] ReiserFS: sdd: warning: vs-5150: search_by_key: invalid format found in block 0. Fsck?
[12203.382895] ReiserFS: sdd: warning: vs-13070: reiserfs_read_locked_inode: i/o failure occurred trying to find stat data of [1 2 0x0 SD]
[12203.382919] ReiserFS: sdd: Using r5 hash to sort names
[12203.392484] ReiserFS: sdd: warning: xattrs/ACLs enabled and couldn't find/create .reiserfs_priv. Failing mount.


It's amazing, the best tool for recovering reiserfs is made for windows!


http://www.ufsexplorer.com/

UFS Explorer just saved me, I was able to make an image of the failed drive, on my other pc with windows xp, I installed UFS Explorer. Then opened the image file that was shared on ubuntu over the network.

UFS Explorer scanned for the superblock and displayed all the folders I needed with the filenames intact and everything on that drive.I was then able to right click on each of them and copy it to a spare drive on the windows pc. It was so easy I now regret wasting so much time on those command line tools where you have to read several man pages just to get started.

I even asked for help on ubuntuforums, no luck. http://ubuntuforums.org/showthread.php?t=932922

Free Image Hosting at www.ImageShack.us

QuickPost Quickpost this image to Myspace, Digg, Facebook, and others!

Tuesday, August 12, 2008

Network-wide Adblock on Ubuntu + OpenDNS adblocking

Based on the article found here: http://notes.ozmonet.com/index.php?title=Network-Wide_Adblock

This method will work for both Internet Explorer and Google Chrome.
You must have lighttpd or apache installed to serve up replacement images or pages.

Install squid: sudo apt-get install squid

Configure: /etc/squid/squid.conf

http_port 3128
hierarchy_stoplist cgi-bin ?
acl QUERY urlpath_regex cgi-bin \?
cache deny QUERY
acl apache rep_header Server ^Apache
broken_vary_encoding allow apache
access_log /var/log/squid/access.log squid
log_ip_on_direct off
url_rewrite_children 5
url_rewrite_concurrency 0
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
acl all src 0.0.0.0/0.0.0.0
acl our_networks src 192.168.219.0/24
cache deny all
http_access allow our_networks
http_reply_access allow all
icp_access allow all
visible_hostname SERVERNAME
coredump_dir /var/spool/squid
Install squidguard: sudo apt-get install squidguard

Download and configure adblock for use with squidguard

wget http://easylist.adblockplus.org/adblock_rick752.txt
create a sefile with this inside it:

/@@.*/d;
/^!.*/d;
/^\[.*\]$/d;
s#http://##g;
s,[.?=&/|],\\&,g;
s#*#.*#g;
s,\$.*$,, g;

Create the expression list: cat adblock_rick752.txt | sed -f sedfile > expressions

In your squidguard folder /var/lib/squidguard/db, create a folder for adblock and copy the expressions file inside it.

sudo chmod proxy.proxy -R adblock

Edit your /etc/squid/squid.conf, add this at the end
redirect_program /usr/bin/squidGuard -d -c /etc/squid/squidGuard.conf

Edit your /etc/squid/squidGuard.conf file
dbhome /var/lib/squidguard/db
logdir /var/log/squid

src my_network {
ip 192.168.219.0/24
}

dest adblock {
expressionlist adblock/expressions
redirect http://localhost/lol.jpg
}
acl {
my_network {
pass !adblock any
}
default {
pass none
redirect http://localhost/lol.jpg
}
}
Restart Squid and then configure your browsers to use the ip address of the server running squid, mine was http://192.168.219.111:3128, fire up your browser and surf ad riddled sites to test it.

Sign-up for OpenDNS, not only do they provide you with speedy DNS queries they also feature ad blocking. The good thing about OpenDNS is that you only have to configure your router and it enables all the features on every computer on your network.

Their DNS servers are down below:
208.67.222.222
208.67.220.220

If you need help configuring your computer or router please check their site.
https://www.opendns.com/homenetwork/start/

Once you are done setting up your router login to their dashboard and go to settings \ Content Filtering. I enabled filtering for adware, parked domains and phishing.

Well that about covers it, enjoy add free surfing!

Sunday, August 10, 2008

Can't watch the Olympics on Linux!!!

Went to nbcolympics.com to watch my favorite events on the olympics and it wouldn't let me, so finally had to grab my laptop and see what the requirements were.

I knew I had flash properly configured on my LinuxMint pc but it required something else!!! Microsoft Silverlight!

Damn, what a fine way to muscle your way into people's computers, "wanna watch it online gotta install our fucking Silverlight".

Free Image Hosting at www.ImageShack.us

QuickPost Quickpost this image to Myspace, Digg, Facebook, and others!

Friday, July 25, 2008

Foxconn deliberately sabotaging their BIOS to destroy Linux ACPI

Foxconn deliberately sabotaging their BIOS to destroy Linux ACPI - Ubuntu Forums

Why linux has a hard time becoming mainstream, fucking companies like Foxonn sucking microdicks cock!!! I've glad to have never chosen any product from them, and I'd like all SG members to know, for those who use linux, never to buy from this fucking company. They are now on digg, slashdot and reddit. Hope they like the internet mob.

Thursday, July 17, 2008

CIFS VFS: No response for cmd 50

Automatically mounting and unmounting Samba/Windows shares with CIFS - Lone Wolves - Web, game, and open source development
Finally a solution to this annoying shutdown problem, if Ubuntu is to become mainstream this kind of kinks in the system should be ironed out, before they start thinking of another stinking new version!!!

Linux Mint 5 Elyssa R1 (Revision 1) released

Linux Mint 5 Elyssa R1 (Revision 1) released
This article was posted on: 12/06/2008

A security issue was fixed in Linux Mint 5 Elyssa. All ISO images were rebuilt and the fix was made available in the repositories.


I've started using Linux Mint for my media center pc and I love it :) Hopefully I'll be able to replace the main server with this one.

Sunday, May 4, 2008

Useful find and replace stuff


Find files containing text:



grep -i -n 'foo' *

Find files containing text and replace them with something else:



sed -i 's/foo/bar/g' *

Thursday, April 24, 2008

Ubuntu Kiosk + Opera = FTW!

Recently I've been tasked by the company that I work with to create kiosk terminals. We had some old Dell's lying around, they have a 400mhz processor, 128mb ram, 10gb hard drive. They would basically just show the company website but prevent them from going anywhere else.

Now I thought this would be a good chance to show them Ubuntu and Firefox, I'm an evangelist for those two. However what happens next is a trip into the twilight zone, I ended up having to use Opera.

It seems there are no good firefox extension that turns it into a kiosk, I tried searching on its add-on database. While there are some, most of them only works in Windoze!!! WTF!!! Mozilla wtf!!!! Open Source, ever heard of it???

Damn I was so pissed off, add the fact that the wireless usb adapters are a pain to configure in Ubuntu. I started to think that maybe I'm going on the wrong path. After googling for a miracle I finally found one post in a forum suggesting why not try opera... I've used opera before, in fact before Firefox I was a huge opera fan.

Sure enough, damn it was so easy with Opera, opera -kioskmode -nomenu -nosysmenu etc.
http://www.opera.com/support/mastering/kiosk/

Check that link for the full list of options, everything worked so sweet in opera and it was fast too. I finished all the kiosk stations in a day, and wasted 2-3 days trying to get firefox to work.

To sum it up, I installed Ubuntu using the server iso. Create a kiosk user with limited system access. Then installed xorg, xscreensaver, opera, msttcorefonts. Got the wireless adapters working using wpa_supplicant and ndiswrapper.

I created a script to start X and then when opera closes it will logout the user, this script is then called from .bashrc

kiosk.sh

#! /bin/bash
startx
clear
exit


.xinitrc
xscreensaver &
exec opera -kioskmode -noexit -nomenu -nosysmenu etc...


Removed the other terminals and left 2 running, didn't have any graphical login manager, and didn't need any window manager. They run fast and sweet on those old Dell suckers, I bet they are thankful that I saved them from the junkyard.

As for firefox, I'm so disappointed... really I am!

This post from ubuntuforums helped me install programs when the ubuntu servers were being leeched to death after the release of 8.04 it was posted by izut.

Re: How to Create Local Repository on Hard Disk

I'll describe a few steps I made to construct my personal repository. My current setup is:

- Ubuntu 'Warty' installed with Internet access (at work)
- Ubuntu 'Warty' installed without Internet access (at home)

Using the usual Ubuntu repositories, I updated the system and installed some packages I wanted (ruby, apache, mysql, etc). You don't need to install that on the host system, just use the apt-get's download only option. All files downloaded from repositories are in the /var/cache/apt/archives directory in the host system. I did these steps:

1. Created /opt/repo directory (could be the home directory)
2. Created the directory /opt/repo/binary (copied from Debian specs)
3. Copied all debs from my update from /var/cache/apt/archives to /opt/repo/binary
4. Executed dpkg-scanpackages like this:
# pwd
/opt/repo
# dpkg-scanpackages binary /dev/null | gzip -9c > binary/Packages.gz
5. Burned a CD with its contents

For use that in my standalone host, I did this:
# apt-cdrom add
...

I think it's all.

Cya.

Tuesday, December 4, 2007

Grub ERROR 17

WTF does that mean!!! Damn I can't boot back into my server :( all the files are still there, but the OS is shot, anyone got any suggestions on how to fix this?

Probably will have to reinstall ubuntu again, damn it!!!!

Note: fixed this by re-ordering the hard drives in the bios

Wednesday, October 31, 2007

Moving the forum and galleria

Last night I "moved" the forum and the galleria to another server, well I didn't exactly move it, I just basically transferred all the database to the new server and mapped the drives from the old server to the new one. I'll have to physically move the drive later tonight.

What's amazing is that it worked out great! Far better than I expected, I really am impressed with Ubuntu(Linux) I'm never ever going back to using windows as a server ever again. Now if I could only transfer all the movies on my other ubuntu pc to this one, that would bring the pc running at home down to two.

So the site would be down again tonight but only for a little bit, and I expect no problem in moving the hard drives to the new server.


Powered by ScribeFire.

Tuesday, October 2, 2007

Upgrading to Gutsy


Ubuntu 7.10 Beta Release | Ubuntu
"Introduction to Ubuntu 7.10 Beta The Ubuntu developers are hurrying to bring you the absolute latest and greatest software that the open source and free software communities have to offer. This is the Ubuntu 7.10 beta release, which brings a host of excellent new features. Note: This is still a beta release. Do not install it on production machines. The final stable version will be released in October 2007."
It's supposed to be released this month but I just can't help but give it a try, so far my past experiences with ubuntu was good, but this new release really just frustrated me. I could never get compiz fusion to work and had some problems with slow networking too.

I'm doing the upgrade instead of a clean install, but I'm also downloading their DVD installer/livecd just in case my upgrade gets messed up and I end up with a wrecked system.



Powered by ScribeFire.

Saturday, September 15, 2007

Fucking penguin


Compiz Fusion » Welcome
Compiz Fusion is the result of a merge between the well-known Beryl composite window manager and Compiz Extras, a community set of improvements to the Compiz composite window manager. Compiz Fusion aims to provide an easy and fun-to-use windowed environment, allowing use of the graphics hardware to render each individual window and the entire screen, to provide some impressive effects, speed and usefulness. The first Compiz Fusion developer release was Compiz Fusion 0.5.2 on August 13th 2007, shortly after Compiz 0.5.2 was released.
I just find it funny that Linux and its many variants are focusing so much on bling rather than actually much needed user function. I've used Ubuntu and Redhat for our servers at work, I even use it for my webserver at home. But one thing that really annoys me is the lack of webcam support and the fact that almost 90% of the time all this bling doesn't even work!

Vista at least performed well on my ATI All-in-wonder 9600 but Ubuntu fucking crapped out!!!! They say its the driver blame it on ATI blah blah, interestingly I tried Sabayon and on the fucking livecd it actually had the uber spinning desktop cube, but after I installed and it, the damn thing said something about direct rendering etc. fuck fuck fuck!!! What the fuck is wrong with this fuck, I spent like my entire evening trying to get this fuck working and nothing!

Linux ready for desktop, yeah probably by the time we send a guy to saturn or something.




Powered by ScribeFire.

Friday, February 9, 2007

So what's going on why is Site Geisha down you ask? Well currently migrating the entire site to my Ubuntu server.

The move went smoothly in fact I've also rewritten the galleria code and optimized the download code. I tested PHPBB3 Beta 5, but sadly the authentication script I use no longer works with it. So I guess we're stuck with PHPBB2 for awhile until PHPBB3 gets out of beta or until I can reconfigure the script.

Screenshot (7K)

Apache2 works so much better than IIS, with mod_deflate enabled I can conserve my bandwidth too. Also to save disk space full thumbnail previews are no longer available, only the first row of pics get a thumbnail.

Any suggestions/comments don't hesistate to email me, your admin ^_^ who's working solo to get SG back for all of you.