Author Archives: Dave - Page 7

GIT

I hate setting up new repo’s…

If you have a local repo that you would like to share, on the remote server create a new directory (with correct permissions).

then, cd into the dir

and type

git --bare init

or

git --bare init --shared=group

on the local machine you can now push your copy up, like this. (make sure you are in the directory)

git remote add origin username@remote.server.com:/file/directory/
git add .
git commit -m "commit change"
git push origin master

NFS Port Mapping IPTABLEs Setup

Great post instructing how to lock down an NFS server

http://nxlinuxadmin.blogspot.com/2010/05/iptables-for-nfs-server.html

Postgresql 9.0 Centos Install and Config

Download repo

wget http://yum.pgrpms.org/reporpms/9.0/pgdg-centos-9.0-2.noarch.rpm

Install repo

rpm -i pgdg-centos-9.0-2.noarch.rpm

Install Postgres

yum install postgresql90-server

Initialise DB

service postgresql-9.0 initdb

Start Service

service postgresql-9.0 start

Turn levels on

chkconfig --levels 235 postgresql-9.0 on

Edit conf file

nano /var/lib/pgsql/9.0/data/pg_hba.conf

Change IDENT to TRUST at bottom of file (all fields)

Edit postgresql.conf

Change listen 'localhost'
to
listen '*'

If using phppgadmin, you need to edit config.inc.php and set security to false to use the web interface.

To restore a DB

# psql -U -d -f

php-wkhtmltox

wkhtmltox is a great piece of kit to convert webpages to PDF format.

It is – however – an absolute Pita to install, as there are minimal resources on the net for installing this onto a Linux Server.

The first step is to download both the static library

libwxhtmltox

and the wkhtmltox static binary

wkhtmltopdf

Both of these can be downloaded from the Google Code repository found HERE Download the correct files for your server (i386 or amd64).

The will be packed in the unusal bunzip2 format, to exact type

bunzip2 #filename#

Then tar the file out with

tar xvf #filename#

copy the wkhtmltox directory to /usr/local/include
copy the lib/libwkhtmltox.so to /usr/local/lib/

unpack wkhtmltopdf and copy to a dir which is symlinked so you can use the CLI version from anywhere in your shell.

To add the PHP-extension requires a little more trickery.

Firstly download the source from HERE

unpack and run these commands


phpize
./configure
make test
make install

If the make test fails, it usually will mean that php was unable to load the library, so you need to add the following .

Go to

/etc/ld.so.conf.d/

and edit (or create if it doesn’t exist)

usr-local-lib.conf

add the following path

/usr/local/lib

then in your php.ini file add

extension=phpwkhtmltox.so

restart your web server, and check your phpinfo() to make sure the phpwkhtmltox extension has been loaded.

If you are installing on 32bit Centos 5.x you may have a very hard time trying to figure out why the phpize/configure fails. It usually means that you don’t have fontconfig installed, or it is an older version.

If you want to produce PDF’s from a site that is SSL enabled, you will fail… miserably… WKHTML 0.11 breaks UNLESS openssl-devel package has been installed… I lost 4 years of my life and now have a head full of grey hair. Hopefully this little tid bit of information helps some other poor soul.

You may also find that the rendered PDF’s have garbled boxes, you will need these fonts installed – on Centos

yum install urw-fonts

DNS Cache Flush Mac OS X


dscacheutil -flushcache

Resize XEN VM disk and Swap Disk

master:~# fdisk /dev/xvda

Command (m for help): p
Command (m for help): d

Partition number (1-4):<enter partition number>

Command (m for help): n
Command action
e extended
p primary partition (1-4): p
Partition number (1-4): <enter partition number>
First cylinder (32-6527, default 32):
Last cylinder or +size or +sizeM or +sizeK (32-6527, default 6527):

Command (m for help): t
Partition number (1-4): <enter partition number>
Hex code (type L to list codes): 8e
Command (m for help): p
Command (m for help): w

The partition table has been altered!
master:~# reboot

when it has rebooted, you just have to resize the filesystem with..

master:~# resize2fs /dev/xvda1
master:~# reboot

Resize the SWAP Disk like this:

<run through the regular resize for a disk and reboot>

master:~# swapoff

master:~# cfdisk /dev/swap-partion

master:~# mkswap -c /dev/swap-partition

master:~# swapon -a


 

Xcode 4 Source Control Woes

I spent an age trying to work out why i couldn’t check out my code from a SVN REPO.

So turns out Xcode will not allow you to download from a SVN source that uses a untrusted SSL certificate.

You would get an error similar to: The certificate is not issued by a trusted authority. Use the
fingerprint to validate the certificate manually!

So how to work around this?

Open up a terminal window, and begin a manual attempt at downloading the SVN repo with something like this..


svn co https://........

you will then be prompted to reject, accept or permanently trust this certificate..

Hope this helps some poor soul..

Disk speed VPS, how fast?


dd if=/dev/zero of=test bs=64k count=512 oflag=dsync

The number one bottle neck for a VPS is Disk I/O. The easy way to find out the quality of your VPS’s disc I/O is by issuing the above command which will copy a 32mb file, outputting the time taken and average transfer speed…

PCRE unicode support CENTOS

Centos PCRE repo is 6.6, and cannot be YUM REMOVED without removing hundred of dependancies…

I needed to install PCRE with unicode support which meant compiling my own package.

First you need to install all the correct libs


yum install gcc-c++

then download latest pcre from

http://www.pcre.org/

unpack and configure


./configure --prefix=/usr
--docdir=/usr/share/doc/pcre-8.10
--enable-utf8
--enable-unicode-properties


make


make check


make install

the libraries will be installed to /usr/lib and you will need to add a new path for your DSO loader create a file called pcre.conf in the directory


/etc/ld.so.conf.d

and insert the path


/usr/lib

save and close and update the cache by running


ldconfig

restart your web server and check phpinfo that your PCRE module has been updated to 8.11 (or latest).

Logrotate

Rotating your log files will save you a bunch of space from bloated web logs growing out of control. Logrotate is easily customisable to suit any needs.

To force logrotate to rotate out of schedule use the f flag, and to make it output to screen, use V for verbose ie.

/usr/sbin/logrotate -vf /etc/logrotate.conf

Below is an excerpt for Logrotate configured with lighttpd. you will need to reload your specific web server with its own reload command.


nano /etc/logrotate.conf
# rotate log files weekly
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
minsize 1M
create 0664 root utmp
rotate 1
}

# system-specific logs may be also be configured here.

/srv/www/mywebsite.com/logs/*log {
rotate 14
daily
compress
create 0664 lighttpd lighttpd
delaycompress
sharedscripts
postrotate
/sbin/service lighttpd reload > /dev/null 2>/dev/null || true
endscript
}