Centos add additional repositories
yum install yum-priorities
edit all .repo files from /etc/yum.repos.d/ and add bellow:
[base], [addons], [updates], [extras], [centosplus]
priority=1
bellow [contrib]
priority=2
download RPMforge and check the file
rpm –import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -K rpmforge-release-0.5.1-1.el5.rf.*.rpm
install and check the installation
rpm -i rpmforge-release-0.5.1-1.el5.rf.*.rpm
yum check-update
done
Cpanel: change ssl port for apache
The title it’s choosen to have cpanel word in it because changing ssl port from 443 to something else directly in http.conf will bring trouble when you create a new account for instance (cpanel rebuilds http.conf automatically)
so keeping things short go to /var/cpanel and:
sudo vi cpanel.config
change apache_ssl_port=0.0.0.0:443 to apache_ssl_port=0.0.0.0:new_port
then:
sudo /usr/local/cpanel/whostmgr/bin/whostmgr2 --updatetweaksettings
protect server from high load
Bellow is a bash script that will save you a lot of energy and headaches when your server gets a high load. For instance if some of your clients / websites is going in an infinite loop because of a php programming bug it’s not worth waiting until your server crashes, you can use the script bellow to restart apache and all the php-cgi processes. (I use fastcgi on my server)
#!/bin/bash
MAXLOAD=”5″
L05=”$(uptime | gawk -F”load average: ” ‘{ print $2 }’ | gawk -F”, ” ‘{ print $1 }’)”
if [ $(echo "$L05 > $MAXLOAD"|bc) -eq 1 ]
then
unlink /tmp/message.txt
MESAJ=”/tmp/message.txt”
echo “I have restarted apache and all php-cgi processes” >> $MESAJ
/bin/mail -s “load mare $L05″ “mail@mymailserver.com” < $MESAJ
kill -9 `ps -ef |grep php-cgi |grep -v grep | awk ‘{print $2}’`
/etc/init.d/httpd restart
fi
quick onsite SEO techniques to avoid duplicate content
1. redirect index.php to your main page
RewriteBase /
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index\.php\ HTTP/
RewriteRule ^index\.php$ http://www.yoursite.com/ [R=301,L]
2. use canonical tag properly, so for http://www.yoursite.com/my-list-of-products?orderby=name&orderway=desc you should have:
3. redirect non-www to www version
RewriteCond %{HTTP_HOST} ^yoursite.com [NC]
RewriteRule ^(.*)$ http://www.yoursite.com/$1 [L,R=301]
cakephp page title in view cake1.3
In order to change page title in cakephp inside a view just use the code bellow
$this->set('title_for_layout', 'my cakephp page title');
Redirect all pages from an old subdomain to the new one
place a new htaccess file in your old website directory with the following contents
RewriteEngine on
Redirect 301 / http://yournewwebsite.com/
remove comparison links from magento
Copy app/code/core/Mage/Catalog/Helper/Product/Compare.php
to app/code/local/Mage/Catalog/Helper/Product/ (create missing directories)
Edit
app/code/local/Mage/Catalog/Helper/Product/Compare.php
after:
public function getAddUrl($product)
{
add:
return false;
Project Management Open Source Software
There is almost an year since working with qdpm, http://qdpm.net/, which is a great tool for project management, however I wanted something more complete and if possible that had svn support for the projects.
update: qdpm supports gantt charts from version 5.5
Here is what I found:
1. Clockingi.com, http://www.clockingit.com/ has nice graphical reports, gantt charts and svn support
2. Codeni, http://www.codendi.com from XEROX, supports svn/cvs repository browsing and gantt charts, seems a complex and mature product
3. Collabtive, http://collabtive.o-dyn.de/, it’s a simple, lightweight project management too, useful for a very small team or a freelancer
4. project-open, http://www.project-open.org/
5. endeavour, http://endeavour-mgmt.sourceforge.net, you can check it’s features here: http://endeavour-mgmt.sourceforge.net/features1.html
6. Redmine, http://www.redmine.org/, gantt charts, integrations with SVN, CVS, Mercurial, etc.. written in Ruby on Rails
Jquery Regex Validation
A quick post about validating anything you want using regex. I used it in a project that created forms on the fly, so validations like email, numbers and so on wasn’t so simple (I couldn’t do it by just adding the validation as a class: class=”email”)
so first step is adding what we need before the </head>:
<script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.validate.pack.js">
now just after the above code we add our regex method:
<script type="text/javascript">
$.validator.addMethod(
"regex",
function(value, element, regexp) {
var check = false;
var re = new RegExp(regexp);
return this.optional(element) || re.test(value);
},
"Please check your input"
);
</script>
and the final thing is ading the validation we need – you can use php to add them from the database for instance:
<script type="text/javascript">
$(document).ready(function(){
$("#myFieldId").rules("add", {regex: "^(0|[1-9][0-9]*|[1-9][0-9]{0,2}(,[0-9]{3,3})*)$"});
})
</script>
How google can penalize your website because of adsense
Lesson learned – sometimes google can penalize your website because incorrect use of adsense.
This storry started a while back when I begun adding adsense on one of my websites where I suspected it is not allowed (it’s a website on which people can upload school content and such).
Everything was fine for a while – about 4 months, I got a little amount of money too when suddenly the website dropped from the search engines. I thought it was because of duplicate content or because of the too many pages the site had, which was strange but I had no clue.
So I kept my website simple removing all pages that were not important, I even removed the adsense from some of the pages including first page because anyway I was not making any money anymore.
After 8 months guess who was back?… my website
– I was happy for 1 month until I received another payment from adsense (cumulated with another website) – just after payment was confirmed the website was down again from the search engines, so now I suspected the cause: I removed all adsense from the website, after 2 more months my website was back again!!!
In conclusion I think google has a swith for it’s personnel, including the google adsense staff who can shot your website into his legs bringing it down for a while.