Tuesday, May 26, 2009

Set up lighthttpd and PHP in Debian Etch

This article is from VPS Media

This article will explain how to install and configure lighthttpd with PHP5 and MySQL. lighthttd is a web server designed to be fast, secure, flexible and standards-complient while being optimized for speed-critical environments.

Its low memory footprint, light CPU load and speed make it the perfect web server for an environment such as a 384MB VPS. lighthttpd supports the FastCGI interface, which we will use to enable PHP5 support. This article assumes you have already updated your system with the latest fixes and DO NOT have a web server, such as Apache, already installed on your VPS. We will be installing all required applications with the apt-get utility in Debian.

Install MySQL

We begin by installing MySQL 5.0:

# apt-get install mysql-server mysql-client

This should install and start up the MySQL server. Let’s give the MySQL root account a password, such as:

# mysqladmin -u root password yourpassword

Now we have to check on which address MySQL is listening with netstat:

# netstat -tap | grep mysql

The output should look similair to this:

tcp 0 0 localhost:mysql *:* LISTEN 1695/mysqld

Which means MySQL is listening on localhost only. But lets say you see output such as:

tcp 0 0 *:mysql *:* LISTEN 1695/mysqld

That means anyone can access your database and modify data, so you should set a password for your hostname. For example:

# mysqladmin -h server1.domain.com -u root password yourpassword

Replacing sever1.domain.com with your domain name.

Install lighthttpd

We can install lighthttpd with apt-get, like this:

# apt-get install lighttpd

After installation finishes, open your web browser and type in your VPS’ IP and you should see the placeholder page. Lighttpd’s default document root is /var/www on Debian, and the configuration file is /etc/lighttpd/lighttpd.conf.

Install PHP5

PHP works on lighthttpd using the FastCGI interface. Debian provides a FastCGI-enabled PHP5 package, which we can install like this:

# apt-get install php5-cgi

To enable PHP5 in lighttpd, we must modify two files (/etc/php5/cgi/php.ini & /etc/lighttpd/lighttpd.conf). First we open /etc/php5/cgi/php.ini:

# nano /etc/php5/cgi/php.ini

Add the following line right at the end of the file:

cgi.fix_pathinfo = 1

Then we open /etc/lighttpd/lighttpd.conf and add “mod_fastcgi”, to the server.modules stanza:

# nano /etc/lighttpd/lighttpd.conf

server.modules = (
“mod_access”,
“mod_alias”,
“mod_accesslog”,
“mod_fastcgi”,
# ”mod_rewrite”,
# ”mod_redirect”,
# ”mod_status”,
# ”mod_evhost”,
# ”mod_compress”,
# ”mod_usertrack”,
# ”mod_rrdtool”,
# ”mod_webdav”,
# ”mod_expire”,
# ”mod_flv_streaming”,
# ”mod_evasive”
)

and then right at the end of the file, we add the following stanza:

fastcgi.server = ( “.php” => ((
“bin-path” => “/usr/bin/php5-cgi”,
“socket” => “/tmp/php.socket”
)))

Next, we restart lighthttpd:

# /etc/init.d/lighttpd restart

Testing Your Installation

The document root of the default web site is /var/www. To test if PHP was installed properly, create a test.php file in your web folder, as such:

# nano /var/www/phpinfo.php

Place the following code inside:

Now point your browser to http://ip.address/phpinfo.php and you should see your PHP configuration. As you can see on the Server API line, PHP5 is working through FastCGI. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don’t have MySQL support in PHP5 yet.

Enable MySQL Support in PHP5

To get MySQL working with PHP5 all we have to do is install the php5-mysql package.

# apt-get install php5-mysql

Now restart lighthttpd:

# /etc/init.d/lighttpd restart

Reload the phpinfo.php file in your web browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module. That’s about it, congratulations on installing MySQL/lighthttpd/PHP5 on your VPS!

Monday, May 11, 2009

Spam, Spam, Not Spam - Seven tips for successful email marketing

by Stephan Spencer

Originally published in Unlimited

Email can be your company’s secret weapon, or it can end up biting you in the backside if it’s seen as junk email or spam. It all depends on the execution. So says Debbie Mayo-Smith, email marketing consultant and author of the new book Successful Email Marketing: Your Complete How-to Guide. She’s seen New Zealand companies make deadly email mistakes, like listing their entire customer list in the “cc” line or flooding recipients’ in boxes with thousands of copies of the same message.

But the book also contains examples of New Zealand companies getting good results from email marketing campaigns. For example, a Bank of New Zealand email campaign soliciting credit card applications got a 9% response rate (the same as a direct marketing campaign sent at the same time), but the email campaign used only 15% of the budget . At the other end of the size scale, Mayo-Smith’s local garage significantly increased warrant-of-fitness turnover just by asking customers for their email addresses and then sending out reminder emails. There are some ground rules for good email marketing. Try these:

  • Get permission. Don’t buy or rent lists of email addresses. Include simple unsubscribe instructions, then abide by users’ wishes if they opt-out.
  • Work at your subject line. It should have a good call to action or value proposition. Use the subject line to satisfy the recipients’ needs and appeal to their interests. Consider including their first name.
  • Make it easy: easy to unsubscribe, to offer feedback or to place an order by phone, email or online. Make sure if recipients hit “Reply”, it doesn’t come straight back to them marked “Undeliverable”.
  • Distance yourself from spammers, weasels selling weight loss and Nigerian scam merchants. Put your name or your company’s name in the ‘From’ line, not ‘Here it is’ or ‘jm169’. Sign your email with a real person’s name. Address it to the person you want to receive it, not to ‘undisclosed recipients’.
  • Write compelling copy. Make the email short and sweet so that it can be scanned easily. Make judicious use of links, including one to your privacy policy page (you do have one, don’t you?) where you reassure subscribers you won’t share their details with third parties. Make the message look good: a poorly designed email begets poor results.
  • Track everything: click-through rates, unsubscribe rates, bounce rates, “open” rates (meaning that they viewed your email) and, most importantly, conversion rates, where you’ve successfully converted recipients into customers.
  • Test, test, test! Test the offer, the “Subject” line, the “From” line, the message copy, the layout, the message length, the timing and the contact frequency. Set up a control group and experimental groups, where you vary just one element per group. Pay particular attention to the contact frequency, particularly if it’s a regular mailing like an email newsletter.

Stephan Spencer is founder/president of Netconcepts, a Madison, WI-based Web marketing agency that offers search optimization services.

Thursday, May 7, 2009

.htaccess url rewriting examples

If you are looking for the examples of URL rewriting then this post might be useful for you. In this post, I’ve given five useful examples of URL rewriting using .htacess. If you don’t know something about url rewriting then please check my older post about url rewriting using .htaccess.

Now let’s look at the examples

1)Rewriting product.php?id=12 to product-12.html

It is a simple redirection in which .php extension is hidden from the browser’s address bar and dynamic url (containing “?” character) is converted into a static URL.

RewriteEngine on
RewriteRule ^product-([0-9]+)\.html$ product.php?id=$1

2) Rewriting product.php?id=12 to product/ipod-nano/12.html

SEO expert always suggest to display the main keyword in the URL. In the following URL rewriting technique you can display the name of the product in URL.

RewriteEngine on
RewriteRule ^product/([a-zA-Z0-9_-]+)/([0-9]+)\.html$ product.php?id=$2

3) Redirecting non www URL to www URL

If you type yahoo.com in browser it will be redirected to www.yahoo.com. If you want to do same with your website then put the following code to .htaccess file. What is benefit of this kind of redirection?? Please check the post about SEO friendly redirect (301) redirect in php and .htaccess.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^optimaxwebsolutions\.com$
RewriteRule (.*) http://www.optimaxwebsolutions.com/$1 [R=301,L]

4) Rewriting yoursite.com/user.php?username=xyz to yoursite.com/xyz

Have you checked zorpia.com.If you type http://zorpia.com/roshanbh233 in browser you can see my profile over there. If you want to do the same kind of redirection i.e http://yoursite.com/xyz to http://yoursite.com/user.php?username=xyz then you can add the following code to the .htaccess file.

RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ user.php?username=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ user.php?username=$1

5) Redirecting the domain to a new subfolder of inside public_html.

Suppose the you’ve redeveloped your site and all the new development reside inside the “new” folder of inside root folder.Then the new development of the website can be accessed like “test.com/new”. Now moving these files to the root folder can be a hectic process so you can create the following code inside the .htaccess file and place it under the root folder of the website. In result, www.test.com point out to the files inside “new” folder.

RewriteEngine On
RewriteCond %{HTTP_HOST} ^test\.com$ [OR]
RewriteCond %{HTTP_HOST} ^www\.test\.com$
RewriteCond %{REQUEST_URI} !^/new/
RewriteRule (.*) /new/$1