The Quick & Dirty:

  • 9+ years in the biz, 10 messing around
  • All the latest in HTML, CSS, JS & PHP (Sorry, no .net or Ruby skills yet)
  • Cross-browser compatible code from Photoshop or Illustrator files.. or napkins!
  • Custom Specialities in Wordpress theming & plugins, Twitter & jQuery
  • Subversion, server-log analysis, and blocking hack-attempts (of late).
  • Data/Project Geek. I ♥ timelines.

I’ve compiled some handy PHP functions I’ve had to whip up. More extensive code-samples are also available.

Wordpress-from-Photoshop/Illustrator

Wordpress-from-static HTML

Wordpress-from-Photoshop

3S: Server Setup Sucks

Servers are great because they are a reasonably closed system, not like building a website for the million of OS’ & browsers random users prefer. But servers suck, because one false move & it’s all falling apart. You can even “undo” everything & still be down. Here’s what I’ve had to relearn lately.

Resolving conflicts requires an svn command: https://ariejan.net/2007/07/04/how-to-resolve-subversion-conflicts/

Server Client/Local
cat /usr/bin/php-fastcgi:

#!/bin/bash
FASTCGI_USER=www-data
FASTCGI_GROUP=www-data
#ADDRESS=127.0.0.1
#PORT=9000
SOCKET=/tmp/php5-fpm.sock
#php-fastcgi.socket
PIDFILE=/var/run/php-fastcgi.pid
CHILDREN=6
PHP5=/usr/bin/php5-cgi
/usr/bin/spawn-fcgi -s $SOCKET -P $PIDFILE -C $CHILDREN -u $FASTCGI_USER -g $FASTCGI_GROUP -f $PHP5
#/usr/bin/spawn-fcgi -a $ADDRESS -p $PORT -P $PIDFILE -C $CHILDREN -u $FASTCGI_USER -g $FASTCGI_GROUP -f $PHP5
cat /etc/nginx/conf.d/server.conf:

## Parse all .php file in the /var/www directory
    location ~ .php$ {
        fastcgi_split_path_info ^(.+\.php)(.*)$;
##	fastcgi_pass	127.0.0.1:9000;
##        fastcgi_pass   backend;
	fastcgi_pass unix:/tmp/php5-fpm.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
        fastcgi_param  QUERY_STRING     $query_string;
        fastcgi_param  REQUEST_METHOD   $request_method;
        fastcgi_param  CONTENT_TYPE     $content_type;
        fastcgi_param  CONTENT_LENGTH   $content_length;
        fastcgi_intercept_errors        on;
        fastcgi_ignore_client_abort     off;
        fastcgi_connect_timeout 60;
        fastcgi_send_timeout 180;
        fastcgi_read_timeout 180;
        fastcgi_buffer_size 128k;
        fastcgi_buffers 4 256k;
        fastcgi_busy_buffers_size 256k;
        fastcgi_temp_file_write_size 256k;
    }
cat /etc/init.d/php*

#!/bin/bash
### BEGIN INIT INFO
# Provides:          php-fastcgi
# Required-Start:    networking
# Required-Stop:     networking
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start the PHP FastCGI daemon.
### END INIT INFO  
BIND=/tmp/php5-fpm.sock;
USER=www-data
PHP_FCGI_CHILDREN=2
PHP_FCGI_MAX_REQUESTS=5000  
PHP_CGI=/usr/bin/php-cgi
PHP_CGI_NAME=`basename $PHP_CGI`
PHP_CGI_ARGS="- USER=$USER PATH=/usr/bin PHP_FCGI_CHILDREN=$PHP_FCGI_CHILDREN PHP_FCGI_MAX_REQUESTS=$PHP_FCGI_MAX_REQUESTS $PHP_CGI -b $BIND"
RETVAL=0  
start() {
      echo -n "Starting PHP FastCGI: "
      start-stop-daemon --quiet --start --background --chuid "$USER" --exec /usr/bin/env -- $PHP_CGI_ARGS
      RETVAL=$?
      echo "$PHP_CGI_NAME."
}
stop() {
      echo -n "Stopping PHP FastCGI: "
      killall -q -w -u $USER $PHP_CGI
      RETVAL=$?
      echo "$PHP_CGI_NAME."
}  
case "$1" in
    start)
      start
  ;;
    stop)
      stop
  ;;
    restart)
      stop
      start
  ;;
    *)
      echo "Usage: php-fastcgi {start|stop|restart}"
      exit 1
  ;;
esac
exit $RETVAL
Public Key Private Key
~/.ssh/authorized_keys << servername.pub.key ~/.ssh/config
~/.ssh/servername.private.key
/etc/init.d/svnserve:

#! /bin/sh
### BEGIN INIT INFO
# Provides: svnserve
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start svnserve daemon at boot time
# Description: Enable svnserve by daemon.
### END INIT INFO

# Exit immediately if a command exits with a nonzero exit status.
set -e

# svnserve exists and is executable
test -x /usr/bin/svnserve || exit 0

# Directory Where the Repository is located, created with svnadmin create
REPOS_DIR="/srv/svn"

# The pid-file
PIDFILE="/var/run/svnserve.pid"

case "$1" in
start)
echo -n "Starting Subversion (SVN) Server"
start-stop-daemon --start --quiet \
--exec /usr/bin/svnserve --dr $REPOS_DIR
#--pid-file=$PIDFILE
PID=`pidof svnserve` || true
echo $PID > $PIDFILE
echo "."
;;
stop)
echo -n "Stopping Subversion (SVN) Server"
start-stop-daemon --stop --quiet --oknodo --pidfile $PIDFILE
if [ -f $PIDFILE ]
then
rm $PIDFILE
fi
echo "."
;;

*)
echo "Usage: /etc/init.d/svnserve {start|stop}"
exit 1
esac

exit 0
cat /srv/svn/reponame/post-commit

#!/bin/sh
REPOS="$1"
REV="$2"
/usr/bin/svn update /domains/domainname/public_html

 

 

Share and Enjoy

  • Facebook
  • Twitter
  • Delicious
  • LinkedIn
  • StumbleUpon
  • Add to favorites
  • Email
  • RSS
Posted in debian, Linux, Mac, Software, svn, Uncategorized Comments Off

Comments are closed.