Upgrading php on DirectAdmin Servers
Fri, 09/07/2007 - 15:26 — sandipDownload the source tar.gz file from php.net and place it in "/usr/local/directadmin/custom
Edit the "/usr/local/directadmin/custom
Then run:
# cd /usr/local/directadmin/customa pache/
# ./build clean
# ./build update
# ./build all
Restart apache when finished.
Sending files as mail attachments via the shell
Thu, 09/06/2007 - 15:01 — sandipThis article shows how to send e-mails from a shell script, including file attachments. It lists different ways (uuencode, MIME), and explains the advantages and disadvantages of each.
There are other great articles and tips on shell scripts at the site!!
Drupal-4.7.7 Upgrade Notes...
Fri, 08/31/2007 - 15:59 — sandipI run the site on the open-source Drupal CMS and recently updated to the latest 4.7.7 version. The site has quite a few customizations and is not a standard install.
The html document root is a symbolic link to the actual drupal gunzipped folder and all other relevant custom modules are also just symbolically linked from the modules folder to keep the updates as simple as possible.
I also use the "bluemarine" theme which has been customized and named as "linuxweblog", so updates don't necessarily override my custom theme.
Pre-Update Preparation:
-
Backup database and site files.
Login to website as the administrator.
Disable the "Tag Cloud" block as it has some custom php.
Update:
-
`cd /var/www/`
Download from http://drupal.org/project/rele
Untar the gzip package.
`rm html` -- remove the symbolic link.
`ln -s drupal-* html` -- link to the newly extracted folder.
`cd html`
Edit the "sites/default/settings.php" file
-
Add the correct database, username and password to $db_url
Edit the $base_url without trailing slash to http://www.linuxweblog.com
Post-Update Customizations
-
`cp -a themes/bluemarine themes/linuxweblog
Copy or merge node.tpl.php, page.tpl.php and style.css to the linuxweblog theme folder.
Merge .htaccess file and bring over the old customizations.
`cp -a ../drupal-old-*/{robots.txt,fa
`ln -s ../site_files/ site_files` -- create the symbolic links to where the cache and other static files are placed.
`ln -s site_files/cache/ cache` -- create the link to the cache.
`ln -s ../../drupal_contribs modules/custom_mods` -- create the link to the custom modules.
Enable the "Tag Cloud" block.
Re-apply the google search hack to the "search.module" .
Security:
-
`cd /var/www/`
Chown -R user:group drupal-*
Set the directory permissions: `find . -type d -exec chmod 755 {} \;`
Set the file permissions: `find . -type f -exec chmod 644 {} \;`
`chmod 640 sites/default/settings.php`
`chgrp apache sites/default/settings.php`
Turning off safe_mode and open_basedir in Plesk
Thu, 08/30/2007 - 22:17 — sandipCreate a "vhost.conf" file in "/var/www/vhosts/<DOMAIN.TL
<Directory /var/www/vhosts/<DOMAIN.TLD >/httpdocs>
php_admin_value safe_mode off
php_admin_value open_basedir none
</Directory>
Rebuild the domain configs for the particular host via:
/usr/local/psa/admin/sbin/webs rvmng -u --vhost-name=<DOMAIN.TLD> ;
or rebuild all via:
# /usr/local/psa/admin/sbin/webs rvmng -a
cleanup ftp backups with bash shell script
Wed, 08/29/2007 - 22:54 — sandipHere's a small bash code snippet to clean up ftp backups maintained by date. Specifically, if using the SysBK to backup to an external server with just ftp access.
It should be run daily via cron and cleans up folders older than 14 days.
#!/bin/bash
# clean_bak.sh
# Cleans up old backup folders from the remote server.
USR=<user>
PSWD=<password>
HOST=<ftp.domain.tld>< br />BAK_PATH=</path/to/backup s>
LFTP=/usr/bin/lftp
RM_DATE=`/bin/date +%m-%d-%y -d '15 days ago'`
$LFTP << EOF
set ftp:ssl-force true
connect $HOST
user $USR $PSWD
rm -r -f $BAK_PATH/${RM_DATE}
du -h -d 1 $BAK_PATH
quit
EOF
exit 0
The du option will output the space currently being used by the backups.
NOTE: For security reasons, you should use ftps protocol to connect to the remote backup server if possible, and can force it via:
set ftp:ssl-force true
This can also be put in the "~/.lftprc" or "~/.lftp/rc" file.
GalleryRemote on Ubuntu Edgy 6.10
Sun, 08/26/2007 - 22:54 — sandipGallery Remote install kept erroing out with:
Preparing to install...
Extracting the installation resources from the installer archive...
Configuring the installer for this system's environment...
nawk: error while loading shared libraries: libdl.so.2: cannot open shared object file: No such file or directory
dirname: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/bin/ls: error while loading shared libraries: librt.so.1: cannot open shared object file: No such file or directory
basename: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
dirname: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
basename: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
hostname: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
Launching installer...
grep: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
/usr/local/java/bin/java: error while loading shared libraries: libpthread.so.0: cannot open shared object file: No such file or directory
The way around the error was to comment out the assumed kernel.
$ cp GalleryRemote.1.5.Linux.NoVM.b in GalleryRemote.1.5.Linux.NoVM.b in.bak
$ cat GalleryRemote.1.5.Linux.NoVM.b in.bak | \
sed "s/export LD_ASSUME_KERNEL/#xport LD_ASSUME_KERNEL/" > GalleryRemote.1.5.Linux.NoVM.b in
Once installed Gallery Remote would not run and I had run the same hack for the Gallery_Remote launcher script as well.
$ cp Gallery_Remote Gallery_Remote.bak
$ cat Gallery_Remote.bak | \
sed "s/export LD_ASSUME_KERNEL/#xport LD_ASSUME_KERNEL/" > Gallery_Remote
services that are not necessary on a web server
Tue, 08/21/2007 - 15:45 — sandipThese are some services I would normally turn off on web servers.
NOTE: usage may vary.
- gpm -- mouse
- mdmonitor -- monitor raid devices
- netfs -- nfs, samba etc...
- autofs -- automount, nfs, cd etc...
- kudzu -- detect new hardware
- restorecond -- monitor selinux file context
- mcstrans -- mandatory access control selinux translation
- messagebus -- routes messages between applications
- haldaemon -- maintains database of devices connected
There may be more, but if you've cleaned up your rpm packages, it would probably not exist.
rpm packages not necessary for a web server
Tue, 08/21/2007 - 15:37 — sandipBelow is a list of rpm packages that are not necessary on a web server. Use it as a reference starting point for cleaning up servers. You may also want to make sure not to run services not required by the server.
NOTE: usage may vary and removal should be in the order listed:
-
redhat-lsb cups system-config-printer-libs system-config-printer paps -- printer support
-
system-config-soundcard -- gui for sound setup
-
system-config-securitylevel-tu
i -- gui for setting up security
-
nfs-utils system-config-nfs nfs-utils-lib -- nfs server
- portmap -- manage RPC connections
- ypbind yp-tools -- NIS client binding
-
htmlview -- view webpages via gui
-
system-config-services system-config-samba pinfo system-config-users system-config-date -- gui configs
-
samba samba-client samba-common -- samba support
- oprofile oprofile-devel oprofile-gui qt
- vnc
-
libglade2 libgnomecanvas usermode-gtk libbonoboui libgnomeui libglade-java pygtk2-libglade system-config-httpd system-config-network gnome-mount libgnome-java gnome-python2-bonobo gnome-python2-canvas gnome-python2 authconfig-gtk system-config-lvm authconfig-gtk pirut gnome-vfs2 gnome-python2-gnomevfs gnome-python2-gconf libgnome libgsf librsvg2 librsvg2
ImageMagick -
gnome-mime-data gnome-keyring notify-python
- GConf2 notification-daemon bluez-gnome libgconf-java libnotify bluez-utils
- libgtk-java libvte-java
- pygtk2 system-config-language system-config-rootpassword
- vte
- libwnck
- glib-java cairo-java frysk
- libwmf
- gtk2
-
cups-libs
-
ghostscript ghostscript-fonts
- avahi avahi-glib
- wpa_supplicant NetworkManager
- system-config-rootpassword
-
system-config-language
- system-config-keyboard
- system-config-network-tui firstboot-tui
-
system-config-securitylevel-tu
i -
dhcpv6_client dhcdbd dhclient -- dhcp support
- irda-utils -- Infra Red communications
- isdn4k-utils -- ISDN
- apmd -- laptop power management
- cpuspeed -- dynamically changing cpu speed
- bluez-libs -- bluetooth
- irqbalance -- irq load balancing on multi-cpus (remove only in single cpu situation)
- rsh -- unsecure remote access
- talk -- internet talk protocol
- foomatic -- printer driver database
- finger -- finger client
- eject -- eject removable media
-
cvs -- concurrent version control
- rcs -- revision control system
- dosfstools mkbootdisk -- bootdisk
- redhat-menus desktop-file-utils startup-notification -- desktop
- ppp rp-pppoe wvdial -- dialup
- esound -- sound daemon
- pcmciautils -- PCMCIA Cardbus
- pcsc-lite coolkey ifd-egate ccid
- OpenIPMI net-snmp-libs
- ImageMagick-devel -- ImageMagick development package xorg-x11-devel -- X server development package
- acpid -- power management (remove if you don't shutdown using power button)
Check your server for rootkits with Chkrootkit
Thu, 08/09/2007 - 16:25 — sandipchkrootkit is a tool to locally check your system for signs of a compromise via rootkits. It contains a shell script that checks system binaries for rootkit modification, signs of LKM trojans, interface modes and lastlog, wtmp, utmp deletions.
Install via:
# cd /usr/local
# wget ftp://ftp.pangeia.com.br/pub/s eg/pac/chkrootkit.tar.gz
# tar xvzf chkrootkit.tar.gz
# rm chkrootkit.tar.gz
# ln -s chkrootkit-x.xx chkrootkit
# cd chkrootkit
# make sense
Make sure to check the md5sum of the download as well.
Put the below into "/etc/cron.daily/chkrootkit.sh
#!/bin/bash
# chkrootkit.sh
cd /usr/local/chkrootkit/
./chkrootkit 2>&1 |grep "INFECTED\|Vulnerable&quo t;| grep -v "Checking \`bindshell'... INFECTED (PORTS: 465)"
The cron script will only output an email if it detects anything suspicious.
Note, that bindshell port 465 infection is a false alarm as in my case EXIM uses port 465 for secure connections. So, you could similarly grep out any such false alarm and adjust the cron script.
Changing Timezones
Fri, 07/27/2007 - 11:42 — sandip# rm /etc/localtime
# ln -s /usr/share/zoneinfo/US/Eastern /etc/localtime
# hwclock --systohc