Pages

Subscribe:

Saturday, February 6, 2016

Best Practices in Lamp Environment

Here you will find a list of standards to reference.
  • Redirect-Only VHost
VHost example
  1 . Use Apache's RewriteRule instead of Redirect
  2 .     example:
  3 .     
  4 .         ServerAdmin [email protected]
  5 .         ServerName site-to-be-redirected.com
  6 .         ServerAlias www.site-to-be-redirected.com
  7 .         ExpiresActive On
  8 .         ExpiresDefault "access plus 1 minute"
  9 .         RewriteEngine On
 10 .         RewriteRule ^/(.*) http://www.othersite.com/path/$1
 11 .         RewriteCond %{REQUEST_METHOD} ^TRACE
 12 .         RewriteRule .* - [F]
 13 .     


  • How to setup Apache DocRoot to allow multiple users to have write access using a common group
Directory Permissions
  1 . Pick the common group - example developer
  2 . Add each user's login to the group in /etc/group
  3 . Set each user's umask to 0002 by putting "umask 0002" at the bottom of their .bashrc file
  4 . cd DocRoot
  5 . chgrp -R * developer
  6 . find . -type d -exec g+ws {} \;

  • Setup Apache DocRoot so that multiple developers can edit and use svn without permission denied
Directory Permissions
  1 . All developers must be in the same group - developer used here as example
  2 . cd to the top level directory where developers create or checkout files
  3 . Find all directories and set the group to developer
  4 .     $ find . -type d -exec chgrp developer {} \;
  5 .     $ chgrp developer .
  6 . Find all directories and set permissions 2775 - group writable and group sticky bit
  7 .     $ find . -type d -exec chmod 2775 {} \;
  8 .     $ chmod 2775 .
  9 . Find all files and set permissions 664 - group writeable
 10 .     $ find . -type f -exec chmod 664 {} \;
 11 . Edit /etc/bashrc on each server in farm so that a user logging in with a user id != group id will still get umask 0002
 12 .     find the line in /etc/bashrc that says "umask 022" and change it to "umask 002"

  • PECL memcached installation on CentOS 5
PECL memcached
  1 . Prerequistites
  2 . --Download libmemcached version 1.0.10 (minimum version required as of 8/29/2012)
  3 .   wget https://..../1.0/1.0.10/+download/libmemcached-1.0.10.tar.gz
  4 . 
  5 . --Install gcc44 and gcc44-c++ packages
  6 . --Note: To compile libmemached version 1.0.10 you need gcc44 and g++44
  7 .   yum install gcc44-c++ will get you both
  8 . 
  9 . --Download PECL memcached (as of this writing version 2.1.0 is what you will get)
 10 . pecl download memcached
 11 . 
 12 . --First compile and install libmemcached
 13 .   tar zxvf libmemcached-1.0.10.tar.gz
 14 .   cd libmemcached-1.0.10
 15 .   CC=gcc44 CXX=g++44 ./configure
 16 .   make
 17 .   make install
 18 .   cd ..
 19 . 
 20 . ******************
 21 . Start of Note: If you see some/following error during installing libmemcached,
 22 . 
 23 . Error example"
 24 . 
 25 . """"CXX    example/memcached_light.o
 26 . example/memcached_light.cc:40:19: error: event.h: No such file or directory
 27 . example/memcached_light.cc:62: error: field âeventâ has incomplete type
 28 . example/memcached_light.cc:611: error: âevent_addâ was not declared in this scope
 29 . example/memcached_light.cc:629: error: âevent_base_loopâ was not declared in this scope
 30 . make[1]: *** [example/memcached_light.o] Error 1
 31 . make[1]: Leaving directory `/tmp/test/libmemcached-1.0.10'
 32 . make: *** [all] Error 2
 33 . """"
 34 . 
 35 . then install libevent from source as,
 36 . 
 37 .     wget http://www.monkey.org/~provos/libevent-1.4.8-stable.tar.gz
 38 .     tar xfz libevent-1.4.8-stable.tar.gz
 39 .     cd libevent-1.4.8-stable
 40 .     ./configure --prefix=/usr
 41 .     make
 42 .     make install
 43 . End of Note:
 44 . ***********************
 45 . --Next compile and install PECL memcached
 46 .   tar zxvf memcached-2.1.0.tgz
 47 .   cd memcached-2.1.0
 48 .   phpize
 49 .   ./configure --with-libmemcached-dir=/usr/local
 50 .   make
 51 .   scp modules/memcached.so /usr/lib/php/extensions
 52 .   cd ..
 53 .   
 54 . --Enable memcached.so in /etc/php.ini
 55 .   add extension="memcached.so" to php.ini
 56 .   
 57 . --test and restart apache
 58 .   /usr/local/apache2/bin/apachectl -t
 59 .   /usr/local/apache2/bin/apachectl restart
 60 .   
 61 . NOTE: at this point apache may not have restarted! Check and restart again.

2 comments: