Cpanel: change ssl port for apache

Friday, July 16th, 2010 | Linux | No Comments

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

Friday, June 25th, 2010 | Linux | No Comments

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

Thursday, June 24th, 2010 | Seo | No Comments

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

Thursday, May 20th, 2010 | CakePHP | No Comments

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

Tuesday, May 18th, 2010 | E-commerce | No Comments

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

Friday, April 30th, 2010 | Programming | No Comments

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;

Tags:

Project Management Open Source Software

Thursday, April 22nd, 2010 | Different Thoughts, Web development | No Comments

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

Tags:

Jquery Regex Validation

Wednesday, February 17th, 2010 | Web development | No Comments

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

Sunday, February 14th, 2010 | Google | No Comments

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.

Optimize your hosting server

Saturday, December 19th, 2009 | Linux | 1 Comment

A quick info of how you can optimize your hosting server if you are using a LAMP (Linux Apache Mysql PHP) environment.

I am keeping the info for reference, I will also try to update it but please not that’s not a complete list. Please comment if you have any opinions

1. use php as a fcgi module not as a dso module for apache
2. compile apache with mpm (Multi-Processing Module) worker that is capable to serve a large number of requests with less system resources than a process-based server.
3. use php eaccelerator it’s proven to be faster than apc and other cache systems
tweak it based on http://eaccelerator.net/wiki/Settings

that’s basically it :)

now some configuration parameters:
1. don’t use SymLinksIfOwnerMatch in your httpd.conf a lstat system call is made for each directory and it’s not cached
2. Tune MinSpareServers and MaxSpareServers so that Apache need not spawn more than 4 child processes per second (Apache can spawn a maximum of 32 child processes per second). When more than 4 children are spawned per second, a message will be logged in the ErrorLog.

to be continued…