sudo rpm -Uhv http://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
sudo yum --enablerepo=rpmforge install clamd
Dependencies Resolved
=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
clamd i386 0.95.2-4.el5.rf rpmforge 213 k
Installing for dependencies:
clamav i386 0.95.2-4.el5.rf rpmforge 2.7 M
clamav-db i386 0.95.2-4.el5.rf rpmforge 21 M
Transaction Summary
=============================================================================
Install 3 Package(s)
Update 0 Package(s)
Remove 0 Package(s)
Total download size: 24 M
Is this ok [y/N]: y
Downloading Packages:
(1/3): clamd-0.95.2-4.el5 100% |=========================| 213 kB 00:01
(2/3): clamav-0.95.2-4.el 100% |=========================| 2.7 MB 00:04
(3/3): clamav-db-0.95.2-4 100% |=========================| 21 MB 00:26
sudo /sbin/chkconfig clamd on
sudo /sbin/service clamd start
sudo freshclam
0 2 * * * /usr/bin/freshclam -quiet
#0 3 * * * clamscan -r /var/www/html
Reference: http://d.hatena.ne.jp/littlebuddha/20080430/1209543993
Monday, September 21, 2009
Friday, September 18, 2009
Using Wine on Ubuntu
Category:
Ubuntu
— SkyHi @ Friday, September 18, 2009
What is Wine?
Wine is a program that offers a compatibility layer allowing Linux users to run some Windows-native applications inside of Linux. Wine is not the ideal. Ideally, you should find native Linux applications. You can use Ubuntu's software package manager to search for easily installable native Linux apps, or you can explore OSalt or Linux App Finder to find alternatives for specific Windows programs.
Not all Windows applications run in Wine. And some that do require extra configuration in order to work. You may want to consult the Wine HQ app database to see if the Windows application you're thinking of installing through Wine will work well with Wine or not. Platinum-rated applications will work with no extra configuration. The example on this page is a platinum-rated application.
Installing Wine
The installation of Wine is the same as for most software. These screenshots give you a basic overview of the steps. If you're unfamiliar with how software package management works in Ubuntu, you can find more details about it here.
Using Wine
Right-click the setup.exe for the Windows program you want to install. In this case, I went to the Sumatra PDF website and downloaded the installer file called SumatraPDF-0.9.3-install.exe and right-clicked it.
In the context menu that appears, select Open with "Wine Windows Program Loader"
Do the usual next-next-next you'd normally do with a Windows program installer.
To launch the installed Windows program, go to Applications > Wine > Programs and then find the menu item for the Windows program you just installed.
The program should launch and be ready for use!
Please note
I purposely used Sumatra PDF as an example, because it is a platinum-rated Windows application, and this is just an orientation to the basics of how to use Wine. If you are planning to install a Windows program that is gold-rated, silver-rated, or bronze-rated, be prepared to do some extra configuration, and try to look for a Wine tutorial specific to that application. Or, better yet, find a native Linux alternative instead of using a Windows program
Wine is a program that offers a compatibility layer allowing Linux users to run some Windows-native applications inside of Linux. Wine is not the ideal. Ideally, you should find native Linux applications. You can use Ubuntu's software package manager to search for easily installable native Linux apps, or you can explore OSalt or Linux App Finder to find alternatives for specific Windows programs.
Not all Windows applications run in Wine. And some that do require extra configuration in order to work. You may want to consult the Wine HQ app database to see if the Windows application you're thinking of installing through Wine will work well with Wine or not. Platinum-rated applications will work with no extra configuration. The example on this page is a platinum-rated application.
Installing Wine
The installation of Wine is the same as for most software. These screenshots give you a basic overview of the steps. If you're unfamiliar with how software package management works in Ubuntu, you can find more details about it here.
Using Wine
Right-click the setup.exe for the Windows program you want to install. In this case, I went to the Sumatra PDF website and downloaded the installer file called SumatraPDF-0.9.3-install.exe and right-clicked it.
In the context menu that appears, select Open with "Wine Windows Program Loader"
Do the usual next-next-next you'd normally do with a Windows program installer.
To launch the installed Windows program, go to Applications > Wine > Programs and then find the menu item for the Windows program you just installed.
The program should launch and be ready for use!
Please note
I purposely used Sumatra PDF as an example, because it is a platinum-rated Windows application, and this is just an orientation to the basics of how to use Wine. If you are planning to install a Windows program that is gold-rated, silver-rated, or bronze-rated, be prepared to do some extra configuration, and try to look for a Wine tutorial specific to that application. Or, better yet, find a native Linux alternative instead of using a Windows program
pdf viewer with text highlighting.html
Category:
Ubuntu
— SkyHi @ Friday, September 18, 2009
Unfortunately xpdf, evince, acroread etc. cannot highlight text or add comments to PDFs. PDFedit cannot select text properly for many PDFs.
However, there is a nice and free alternative, but you need wine to run it: PDF-Xchange-Viewer [http://www.docu-track.com/download/PDFXVwer.zip]. There's also a thread on this on the SuSE forum.
Update: Apparently with newer wine versions you don't need the script below anymore, since opening files out of the PDF-Xchange-Viewer works directly. Also see the comments below on this.
After installing the viewer, the following script handles file opening:
However, there is a nice and free alternative, but you need wine to run it: PDF-Xchange-Viewer [http://www.docu-track.com/download/PDFXVwer.zip]. There's also a thread on this on the SuSE forum.
Update: Apparently with newer wine versions you don't need the script below anymore, since opening files out of the PDF-Xchange-Viewer works directly. Also see the comments below on this.
After installing the viewer, the following script handles file opening:
Secure Bind Template
Category:
Bind DNS
— SkyHi @ Friday, September 18, 2009
named.conf
The ordering of our views is very important. The named daemon accepts the first match. Because our external view permits all clients, our internal clients also match this view. For this reason we place our internal view first (permitting only our approved internal hosts) and our external view second (permitting all comers).
// @(#)named.conf 02 OCT 2001 Rob Thomas noc@cymru.com
// Set up our ACLs
// In BIND 8, ACL names with quotes were treated as different from
// the same name without quotes. In BIND 9, both are treated as
// the same.
acl "xfer" {
none; // Allow no transfers. If we have other
// name servers, place them here.
};
acl "trusted" {
// Place our internal and DMZ subnets in here so that
// intranet and DMZ clients may send DNS queries. This
// also prevents outside hosts from using our name server
// as a resolver for other domains.
8.8.8.0/24;
localhost;
};
logging {
channel default_syslog {
// Send most of the named messages to syslog.
syslog local2;
severity debug;
};
channel audit_log {
// Send the security related messages to a separate file.
file "/var/named/bind/named.log";
severity debug;
print-time yes;
};
category default { default_syslog; };
category general { default_syslog; };
category security { audit_log; default_syslog; };
category config { default_syslog; };
category resolver { audit_log; };
category xfer-in { audit_log; };
category xfer-out { audit_log; };
category notify { audit_log; };
category client { audit_log; };
category network { audit_log; };
category update { audit_log; };
category queries { audit_log; };
category lame-servers { audit_log; };
};
// Set options for security
options {
directory "/var/named";
pid-file "/var/named/named.pid";
statistics-file "/var/named/named.stats";
memstatistics-file "/var/named/named.memstats";
dump-file "/var/adm/named.dump";
zone-statistics yes;
// Prevent DoS attacks by generating bogus zone transfer
// requests. This will result in slower updates to the
// slave servers (e.g. they will await the poll interval
// before checking for updates).
notify no;
// Generate more efficient zone transfers. This will place
// multiple DNS records in a DNS message, instead of one per
// DNS message.
transfer-format many-answers;
// Set the maximum zone transfer time to something more
// reasonable. In this case, we state that any zone transfer
// that takes longer than 60 minutes is unlikely to ever
// complete. WARNING: If you have very large zone files,
// adjust this to fit your requirements.
max-transfer-time-in 60;
// We have no dynamic interfaces, so BIND shouldn't need to
// poll for interface state {UP|DOWN}.
interface-interval 0;
allow-transfer {
// Zone tranfers limited to members of the
// "xfer" ACL.
xfer;
};
allow-query {
// Accept queries from our "trusted" ACL. We will
// allow anyone to query our master zones below.
// This prevents us from becoming a free DNS server
// to the masses.
trusted;
};
allow-query-cache {
// Accept queries of our cache from our "trusted" ACL.
trusted;
};
};
view "internal-in" in {
// Our internal (trusted) view. We permit the internal networks
// to freely access this view. We perform recursion for our
// internal hosts, and retrieve data from the cache for them.
match-clients { trusted; };
recursion yes;
additional-from-auth yes;
additional-from-cache yes;
zone "." in {
// Link in the root server hint file.
type hint;
file "db.cache";
};
zone "0.0.127.in-addr.arpa" in {
// Allow queries for the 127/8 network, but not zone transfers.
// Every name server, both slave and master, will be a master
// for this zone.
type master;
file "master/db.127.0.0";
allow-query {
any;
};
allow-transfer {
none;
};
};
zone "internal.ournetwork.com" in {
// Our internal A RR zone. There may be several of these.
type master;
file "master/db.internal";
};
zone "7.7.7.in-addr.arpa" in {
// Our internal PTR RR zone. Again, there may be several of these.
type master;
file "master/db.7.7.7";
};
};
// Create a view for external DNS clients.
view "external-in" in {
// Our external (untrusted) view. We permit any client to access
// portions of this view. We do not perform recursion or cache
// access for hosts using this view.
match-clients { any; };
recursion no;
additional-from-auth no;
additional-from-cache no;
// Link in our zones
zone "." in {
type hint;
file "db.cache";
};
zone "ournetwork.net" in {
type master;
file "master/db.ournetwork";
allow-query {
any;
};
};
zone "8.8.8.in-addr.arpa" in {
type master;
file "master/db.8.8.8";
allow-query {
any;
};
};
};
// Create a view for all clients perusing the CHAOS class.
// We allow internal hosts to query our version number.
// This is a good idea from a support point of view.
view "external-chaos" chaos {
match-clients { any; };
recursion no;
zone "." {
type hint;
file "/dev/null";
};
zone "bind" {
type master;
file "master/db.bind";
allow-query {
trusted;
};
allow-transfer {
none;
};
};
};
Reference: http://www.cymru.com/Documents/secure-bind-template.html
The ordering of our views is very important. The named daemon accepts the first match. Because our external view permits all clients, our internal clients also match this view. For this reason we place our internal view first (permitting only our approved internal hosts) and our external view second (permitting all comers).
// @(#)named.conf 02 OCT 2001 Rob Thomas noc@cymru.com
// Set up our ACLs
// In BIND 8, ACL names with quotes were treated as different from
// the same name without quotes. In BIND 9, both are treated as
// the same.
acl "xfer" {
none; // Allow no transfers. If we have other
// name servers, place them here.
};
acl "trusted" {
// Place our internal and DMZ subnets in here so that
// intranet and DMZ clients may send DNS queries. This
// also prevents outside hosts from using our name server
// as a resolver for other domains.
8.8.8.0/24;
localhost;
};
logging {
channel default_syslog {
// Send most of the named messages to syslog.
syslog local2;
severity debug;
};
channel audit_log {
// Send the security related messages to a separate file.
file "/var/named/bind/named.log";
severity debug;
print-time yes;
};
category default { default_syslog; };
category general { default_syslog; };
category security { audit_log; default_syslog; };
category config { default_syslog; };
category resolver { audit_log; };
category xfer-in { audit_log; };
category xfer-out { audit_log; };
category notify { audit_log; };
category client { audit_log; };
category network { audit_log; };
category update { audit_log; };
category queries { audit_log; };
category lame-servers { audit_log; };
};
// Set options for security
options {
directory "/var/named";
pid-file "/var/named/named.pid";
statistics-file "/var/named/named.stats";
memstatistics-file "/var/named/named.memstats";
dump-file "/var/adm/named.dump";
zone-statistics yes;
// Prevent DoS attacks by generating bogus zone transfer
// requests. This will result in slower updates to the
// slave servers (e.g. they will await the poll interval
// before checking for updates).
notify no;
// Generate more efficient zone transfers. This will place
// multiple DNS records in a DNS message, instead of one per
// DNS message.
transfer-format many-answers;
// Set the maximum zone transfer time to something more
// reasonable. In this case, we state that any zone transfer
// that takes longer than 60 minutes is unlikely to ever
// complete. WARNING: If you have very large zone files,
// adjust this to fit your requirements.
max-transfer-time-in 60;
// We have no dynamic interfaces, so BIND shouldn't need to
// poll for interface state {UP|DOWN}.
interface-interval 0;
allow-transfer {
// Zone tranfers limited to members of the
// "xfer" ACL.
xfer;
};
allow-query {
// Accept queries from our "trusted" ACL. We will
// allow anyone to query our master zones below.
// This prevents us from becoming a free DNS server
// to the masses.
trusted;
};
allow-query-cache {
// Accept queries of our cache from our "trusted" ACL.
trusted;
};
};
view "internal-in" in {
// Our internal (trusted) view. We permit the internal networks
// to freely access this view. We perform recursion for our
// internal hosts, and retrieve data from the cache for them.
match-clients { trusted; };
recursion yes;
additional-from-auth yes;
additional-from-cache yes;
zone "." in {
// Link in the root server hint file.
type hint;
file "db.cache";
};
zone "0.0.127.in-addr.arpa" in {
// Allow queries for the 127/8 network, but not zone transfers.
// Every name server, both slave and master, will be a master
// for this zone.
type master;
file "master/db.127.0.0";
allow-query {
any;
};
allow-transfer {
none;
};
};
zone "internal.ournetwork.com" in {
// Our internal A RR zone. There may be several of these.
type master;
file "master/db.internal";
};
zone "7.7.7.in-addr.arpa" in {
// Our internal PTR RR zone. Again, there may be several of these.
type master;
file "master/db.7.7.7";
};
};
// Create a view for external DNS clients.
view "external-in" in {
// Our external (untrusted) view. We permit any client to access
// portions of this view. We do not perform recursion or cache
// access for hosts using this view.
match-clients { any; };
recursion no;
additional-from-auth no;
additional-from-cache no;
// Link in our zones
zone "." in {
type hint;
file "db.cache";
};
zone "ournetwork.net" in {
type master;
file "master/db.ournetwork";
allow-query {
any;
};
};
zone "8.8.8.in-addr.arpa" in {
type master;
file "master/db.8.8.8";
allow-query {
any;
};
};
};
// Create a view for all clients perusing the CHAOS class.
// We allow internal hosts to query our version number.
// This is a good idea from a support point of view.
view "external-chaos" chaos {
match-clients { any; };
recursion no;
zone "." {
type hint;
file "/dev/null";
};
zone "bind" {
type master;
file "master/db.bind";
allow-query {
trusted;
};
allow-transfer {
none;
};
};
};
Reference: http://www.cymru.com/Documents/secure-bind-template.html
mySQL slow query log rotation
Category:
MySQL
— SkyHi @ Friday, September 18, 2009
One of the issues facing log rotation in mySQL is that mySQL doesn’t seem to have the ability to perform a “reload”.
Meaning standard methods of rotating logs using logrotate leave mySQL logging an error in the syslog saying that the log file could not be found, and refusing to to any logging until the server is restarted, not fun if like me you manage high availability solutions and restarting a service is never the best option.
As such I have written this log rotate script, this does however make some assumptions.
1. Your mysql user is “mysql”
2. Your mysql slow query log is /var/log/mysql-slow.log
The script is written to perform the following actions:
1. Rotate weekly
2. Retain 3 rotations (3 files + live log)
3. Compress on rotate (gzip)
4. Create new logfile with 660 permissions chowned to mysql:mysql
5. Run: mysqladmin flush-logs
Please be aware that the flush logs command will also rotate any binary logging currently in place, please ensure this will not adversely affect your deployment prior to use
Please ensure you carry out your own testing prior to deploying this script into a live environment.
http://svn.saiweb.co.uk/branches/linux-the-sysadmin-script/branches/logrotate.d/mysql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#
# mySQL slow log rotation script by D.Busby
# place this script in /etc/logrotate.d/ or your appropriate logrotate dir.
# http://creativecommons.org/licenses/by-sa/2.0/uk/ CC BY-SA
#
# NOTE: if you are reliant on binlogs i.e. for replication, 'flush logs' closes the current binlog and moves to the next itteration of log files
# You should test this does not cause an issue with your deployment before using this script
#
/var/log/mysql-slow.log {
weekly
rotate 3
compress
missingok
notifempty
sharedscripts
create 660 mysql mysql
postrotate
/usr/bin/mysqladmin flush-logs
endscript
}
Tags: log rotation, mySQL, slow query
Reference: http://www.saiweb.co.uk/mysql/mysql-slow-query-log-rotation
Meaning standard methods of rotating logs using logrotate leave mySQL logging an error in the syslog saying that the log file could not be found, and refusing to to any logging until the server is restarted, not fun if like me you manage high availability solutions and restarting a service is never the best option.
As such I have written this log rotate script, this does however make some assumptions.
1. Your mysql user is “mysql”
2. Your mysql slow query log is /var/log/mysql-slow.log
The script is written to perform the following actions:
1. Rotate weekly
2. Retain 3 rotations (3 files + live log)
3. Compress on rotate (gzip)
4. Create new logfile with 660 permissions chowned to mysql:mysql
5. Run: mysqladmin flush-logs
Please be aware that the flush logs command will also rotate any binary logging currently in place, please ensure this will not adversely affect your deployment prior to use
Please ensure you carry out your own testing prior to deploying this script into a live environment.
http://svn.saiweb.co.uk/branches/linux-the-sysadmin-script/branches/logrotate.d/mysql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#
# mySQL slow log rotation script by D.Busby
# place this script in /etc/logrotate.d/ or your appropriate logrotate dir.
# http://creativecommons.org/licenses/by-sa/2.0/uk/ CC BY-SA
#
# NOTE: if you are reliant on binlogs i.e. for replication, 'flush logs' closes the current binlog and moves to the next itteration of log files
# You should test this does not cause an issue with your deployment before using this script
#
/var/log/mysql-slow.log {
weekly
rotate 3
compress
missingok
notifempty
sharedscripts
create 660 mysql mysql
postrotate
/usr/bin/mysqladmin flush-logs
endscript
}
Tags: log rotation, mySQL, slow query
Reference: http://www.saiweb.co.uk/mysql/mysql-slow-query-log-rotation
To enable slow query logging of mysql
Category:
MySQL
— SkyHi @ Friday, September 18, 2009
MySQL has built-in functionality that allows you to log SQL queries to a file , You can enable the full SQL queries logs to a file or only slow running queries log. It is easy for us to troubleshoot/ debug the sql statement if SQL queries log enable , The slow query log is used to find queries that take a long time to execute and are therefore candidates for optimization.
To enable you just need to add some lines to your my.cnf file, and restart. Add the following:
To enable slow Query Log only
log-slow-queries = /var/log/mysql/mysql-slow.log
touch /var/log/mysql/mysql-slow.log
chown mysql:mysql /var/log/mysql/mysql-slow.log
long_query_time = 1
service mysqld restart
After enabling slow query, mysqld writes a statement to the slow query log file and it consists of all SQL statements that took more than long_query_time seconds to execute. The time to acquire the initial table locks is not counted as execution time. mysqld only log after SQL statements has been executed and after all locks have been released, so log order might be different from execution order. The minimum and default values of long_query_time are 1 and 10, respectively.
To enable full Log Query
[mysqld]
log=/var/log/mysqldquery.log
touch /var/log/mysqlquery.log
chown mysql:mysql /var/log/mysqlquery.log
chmod 640 /var/log/mysqlquery.log
service mysqld restart
The above will log all queries to the log file.
To enable you just need to add some lines to your my.cnf file, and restart. Add the following:
To enable slow Query Log only
log-slow-queries = /var/log/mysql/mysql-slow.log
touch /var/log/mysql/mysql-slow.log
chown mysql:mysql /var/log/mysql/mysql-slow.log
long_query_time = 1
service mysqld restart
After enabling slow query, mysqld writes a statement to the slow query log file and it consists of all SQL statements that took more than long_query_time seconds to execute. The time to acquire the initial table locks is not counted as execution time. mysqld only log after SQL statements has been executed and after all locks have been released, so log order might be different from execution order. The minimum and default values of long_query_time are 1 and 10, respectively.
To enable full Log Query
[mysqld]
log=/var/log/mysqldquery.log
touch /var/log/mysqlquery.log
chown mysql:mysql /var/log/mysqlquery.log
chmod 640 /var/log/mysqlquery.log
service mysqld restart
The above will log all queries to the log file.
mod_rewrite
Category:
mod_rewrite,
SEO
— SkyHi @ Friday, September 18, 2009
Apache 1
###rewrite www.... OR not www to new URL
RewriteEngine On
RewriteCond %{HTTP_HOST} www\.dramxcole\.com [NC]
RewriteRule . http://www.bcdramxcole.ca/coege/ [NC]
RewriteCond %{HTTP_HOST} dramxcole\.com [NC]
RewriteRule . http://www.bcdramxcole.ca/coege/ [NC]
RewriteCond %{HTTP_HOST} www\.residcatee\.ca [NC]
RewriteRule . http://www.bcdramxcole.ca/coege/ [NC]
RewriteCond %{HTTP_HOST} residcatee\.ca [NC]
RewriteRule . http://www.bcdramxcole.ca/coege/ [NC]
###rewrite different Domains to one specific URL
RewriteEngine on
RewriteCond %{HTTP_HOST} okokmedi\.ca [NC]
RewriteRule ^(.*)$ http://www.okokmedi.com$1 [L,R=301]
#
RewriteCond %{HTTP_HOST} stratabc\.ca [NC]
RewriteRule ^(.*)$ http://www.okokmedi.com$1 [L,R=301]
#
RewriteCond %{HTTP_HOST} okmedirecord\.ca [NC]
RewriteRule ^(.*)$ http://www.okokmedi.com$1 [L,R=301]
#
RewriteCond %{HTTP_HOST} okmediinfo\.ca [NC]
RewriteRule ^(.*)$ http://www.okokmedi.com$1 [L,R=301]
RewriteEngine on
RedirectPermanent / "http://www.panmose.com/fen/Over.htm"
###rewrite www.... OR not www to new URL
RewriteEngine On
RewriteCond %{HTTP_HOST} www\.dramxcole\.com [NC]
RewriteRule . http://www.bcdramxcole.ca/coege/ [NC]
RewriteCond %{HTTP_HOST} dramxcole\.com [NC]
RewriteRule . http://www.bcdramxcole.ca/coege/ [NC]
RewriteCond %{HTTP_HOST} www\.residcatee\.ca [NC]
RewriteRule . http://www.bcdramxcole.ca/coege/ [NC]
RewriteCond %{HTTP_HOST} residcatee\.ca [NC]
RewriteRule . http://www.bcdramxcole.ca/coege/ [NC]
###rewrite different Domains to one specific URL
RewriteEngine on
RewriteCond %{HTTP_HOST} okokmedi\.ca [NC]
RewriteRule ^(.*)$ http://www.okokmedi.com$1 [L,R=301]
#
RewriteCond %{HTTP_HOST} stratabc\.ca [NC]
RewriteRule ^(.*)$ http://www.okokmedi.com$1 [L,R=301]
#
RewriteCond %{HTTP_HOST} okmedirecord\.ca [NC]
RewriteRule ^(.*)$ http://www.okokmedi.com$1 [L,R=301]
#
RewriteCond %{HTTP_HOST} okmediinfo\.ca [NC]
RewriteRule ^(.*)$ http://www.okokmedi.com$1 [L,R=301]
RewriteEngine on
RedirectPermanent / "http://www.panmose.com/fen/Over.htm"
Subscribe to:
Posts (Atom)
