RSS

Category Archives: Uncategorized

Rotating Apache logs with logrotate

It’s pretty easy to set this up on Linux as most distros come with rotatelog functionality.

All I had to do was to create a file /etc/logrotate.d/apache2 with this content:

/usr/local/apache/domlogs/www3.serbiancafe.com.short {
daily
missingok
rotate 5
ifempty
copytruncate
olddir /usr/local/apache/domlogs/oldlogs
}

/usr/local/apache/logs/*_log {
rotate 3
size 100M
copytruncate
}

If plain English:
First log is rotated on a daily basis regardless if the log is there or empty. Last 5 logs are kept in “olddir” directory. And, you don’t have to restart Apache when you use copytruncate directive.

Second group defines a rotation for all files ending with “_log”. They rotate three files when their size is over 100M.

More options can be found in logrotate man page

Advertisements
 
Leave a comment

Posted by on February 27, 2009 in Uncategorized

 

Coda books with custom images for Code Igniter, MySQL, PHP…

http://www.drastudio.com/past/2008/11/29/adding-more-coda-books/

 
1 Comment

Posted by on December 12, 2008 in Code Igniter, Uncategorized

 

Tags: , , ,

Common Linux server commands on a new box

Changing a time zone

Log in as root and type these commands:
mv /etc/localtime /etc/localtime-old
ln -sf /usr/share/zoneinfo/America/Toronto /etc/localtime

To be continued

 
Leave a comment

Posted by on June 5, 2008 in Uncategorized

 

Deleting too many files

When you try to delete a big number of files in a directory of thousands using:

rm *

You’ll get an error. Linux complains about “Argument list too long”. Issue this command from a directory where files are located to get rid of them:

find . -exec rm {} \;

If you want to delete a large number of cache files, without deleting them all, the best way is to delete the files that were not recently accessed. Say you want to keep the popular cache hits which were accessed in the last 5 days and remove older files, your command would be:

find . -atime +5 -exec rm {} \;

If you try to use a wildcard when using find, you’ll be limited to the maximum number of pages your argument list can accept, which is a kernel limit. So, to work around this, I created a subdirectory for each cache group so I can use a directory name as the first parameter of find. The following example deletes items from cache which were not accessed in more than 4 days. This Something like this:

find /www/site/ci/system/cache/khcache/ -atime +4 -exec rm {} \;

Previously, I was using a wildcarded ‘find’ which was failing:

find /www/site/ci/system/cache/khcache_* -atime +4 -exec rm {} \;

Don’t forget to fix your cache directory setting in your configuration files.

 
Leave a comment

Posted by on February 29, 2008 in Uncategorized

 

Leopard fixes

Mac OS X 10.5 Leopard is great, but as any other OS, it has it’s growing pains.

Here’s issues I encountered with it:

1. MailActOn doesn’t work with new Mail.app
UPDATE: The Leopard install has been released. Works great.

2. When starting Terminal.app I got this error message:

You are not authorized to run this application. The administrator has set your shell to an illegal value.”

I downloaded iTerm from http://iterm.sourceforge.net/ and issued a command:

sudo chsh -s /bin/bash my_username

That fixed it.

 
4 Comments

Posted by on October 28, 2007 in Mac OS, Uncategorized

 

Tags: , ,

Ubuntu 7.10 (Gutsy Gibbon) works great on Gateway 200ARC installed on external USB hard disk

New Ubuntu came out four days ago. It’s a reaaaaly great desktop, really! Not only does the new Ubuntu come with new stuff, enhanced wireless, etc it installed without a hitch on Gateway 200ARC diskless laptop. This Gateway model is notorious for faulty HDD cables. I ran Ubuntu on a USB stick on this same machine until the stick died due to overuse. But this time it seems everything just works.

Installation

I downloaded a “Ubuntu 7.10 Desktop i386” image and burnt a CD. Made sure that the disk was fine, by verifying the data on it. I put it in the drive and ran a Live CD which came with a desktop in what seemed like 5 minutes (seemed slow). I went straight to install and picked my Lacie 160GB USB drive. Clicked “OK” everywhere, including the last step, which was known to cause problems in previous versions. I poped the CD out, crossed my fingers and rebooted.

Never did the GRUB screen look so beautiful 🙂 When it rebooted I was told about some commercial drivers which supported my hardware. Yup, sure, whatever. I agreed by clicking my way through the whole installation.

What works out of the box?

– Keyboard and touchpad work.
– Graphics works even from the Live CD. The screen defaults to machine’s maximum of 1024×768 pixels.
– Ethernet works.
– Wireless works. I connect to a WPA-PSK network. Yaay!
– Modem works.
– External USB booting works from external Lacie drive.

Sorry, I can’t verify if sound drivers work. My sound card has been dead for years.

What doesn’t

Hibernate went to sleep fine, but it didn’t wake up. It froze during the boot. It may be due to external USB disk.

Summary

All in all, this is great news for all of you people with diskless Gateway 200 ARC laptops. No hassle, no hacking installation of Ubuntu 7.10 just works.

I haven’t tried the TV-OUT. Let me know if it does for you.

If you’re looking for a smaller distro to work with 200arc, try Slax.

 
7 Comments

Posted by on October 22, 2007 in Uncategorized

 

cPanel installation

I leased a new server from ThePlanet.com today. It came prebundled with cPanel. Boy is this cPanel messy. That interface is so complicated, I’d rather deal with Linux config files. Almost.

Anyhow. Confusion with web directory came up as soon as I installed it. I looked up /etc/httpd/httpd.conf and immediatelly changed the DocumentRoot to /home/site, because that’s how I set all my servers. Restarted httpd and nothing. Took some searching to find that DocumentRoot did not matter as I was supposed to change things on the bottom of the file:
NameVirtualHost my.ip.address:80<VirtualHost my.ip.address>
ServerName http://www.my.domain
#DocumentRoot /usr/local/apache/htdocs
DocumentRoot /home/site

Hmm. It worked.

cPanel allows you to add packages to Apache/PHP. That’s very useful. I immediately added GD, and mbstring. That’s located in WHM (WebHost Manager) under Software > Apache Update. Pick the version of PHP and packages you want to add compile and with a click of a buttom the script will download and compile them. Now, that was great!

sqlite

Open /etc/sysconfig/rhn/sources and add this line for a repository where appropriate.

yum dag http://apt.sw.be/redhat/el4/en/$ARCH/dag

I didn’t ‘up2date’ the whole system fearing that it may break cPanel. Instead I just issued:

up2date -i sqlite

Few moments later I tested the command ‘sqlite’ from the shell and sure enough I got the sqlite shell. Exit it with ‘.exit’ command! I had to search for it 🙂

But, that was only sqlite 2.8, so I decided to install the test version of 3.3. I found one at http://dag.wieers.com/rpm/packages/sqlite/

I downloaded it and installed issuing commands:
wget http://dag.wieers.com/rpm/packages/sqlite/sqlite-3.3.13-1.el4.test.i386.rpm
rpm -i sqlite-3.3.13-1.el4.test.i386.rpm

I have both a 2.3.17 (command ‘sqlite’) and 3.3.13 (command ‘sqlite3’)

php-sqlite

I’ll be using sqlite on as-need basis, so I decided to dynamically load it in my code.

pear install SQLite-1.0.3.tgz

This caused an error, something about PHP_AUTOCONF not being initialized. So, do it with this command:

export PHP_AUTOCONF=autoconf

Then finish it manually:

cd /tmp/pear/download/SQLite-1.0.3
phpize
./configure
make

Find what your PHP extensions directory is. It’s defined in php.ini file as extension_dir setting. My php.ini file is located in /usr/local/lib/php.ini. It turns out the extension directory is ‘/usr/local/lib/php/extensions/no-debug-non-zts-20020429/’.

Find the sqlite.so file on the filesystem and you can copy it to extensions directory:

cp sqlite.so /usr/local/lib/php/extensions/no-debug-non-zts-20020429/

MySQL 5

Newer cPanels come with MySQL 5 support. Open WHM and go to Server Configuration > Tweak Settings. Choose MySQL 5 and Save!

Once MySQL is upgraded you may test the version from the shell, by issuing command:

mysql -V

Next, we have to rebuild the php driver for mysql. In WHM, under Software, click Apache Update, click ‘Load previous config’, optionally select modules to load and click ‘Start Build’! Pretty easy, if you follow this step by step.

Dissallow root login

Open /etc/ssh/sshd_config in your editor of choice and find a line PermitRootLogin and set it to ‘no’.

 
Leave a comment

Posted by on September 21, 2007 in Uncategorized

 
 
%d bloggers like this: