Saturday, August 28, 2010

Install and setup PHPList

PHPList is an open-source newsletter manager, free to download, install and use. Follow this link to know more...
Here I'm trying to document how to set up PHPlist on Ubuntu that should work for other distributions with little modifications.

Setup Apache, PHP & MySQL:

Install Apache2 and PHP5
 apt-get install apache2 php5
Following NEW packages will be installed
 apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libexpat1 libmagic1 libpq5 libxml2 php5 php5-common ucf
Install MySQL that must be 3.23 or higher
aptitude install mysql-server mysql-client libmysqlclient15-dev libapache2-mod-auth-mysql php5-mysql
The following NEW packages will be installed
apparmor apparmor-profiles libapache2-mod-auth-mysql libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient15-dev libmysqlclient15off libnet-daemon-perl libplrpc-perl libterm-readkey-perl mysql-client mysql-client-5.0 mysql-common mysql-server mysql-server-5.0 php5-mysql zlib1g-dev
You will be also prompted to enter an admin password

Get strong one.

To check whether these packages installed or not, just fire

 dpkg --get-selections
 dpkg -L php5|apache2|mysql-client-5.0
To check whereabouts of MySQL
root@moinhaidar:~# find / -type d -name "mysql"
It will give you sth like this...

Setup Database

Lets login to mysql we just installed
root@moinhaidar:~# mysql -uroot -p
Enter the password you fed while installation.
Now you should be on mysql command line as seen like this
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
Create a database for PHPList namely myphplist
mysql> create database myphplist;
Query OK, 1 row affected (0.00 sec)
Grant privileges
mysql> GRANT ALL PRIVILEGES ON myphplist.* TO 'root'@'localhost' IDENTIFIED BY 'password' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
Check that out
mysql> show databases;
| Database           |
| information_schema |
| myphplist          |
| mysql              |
3 rows in set (0.00 sec)
Now its time to look into PHP installation. Create file say test.php using your favorite editor having
Now fire root@moinhaidar:~# php test.php
Ooooo!!! You got an error like php not found! Okay lets install this package to get command line PHP.
 apt-get install php5-cli
So far so good!

Configuring PHP to Work With MYSQL

Again fire root@moinhaidar:~# php test.php and look for extension_dir something like below.
 extension_dir => /usr/lib/php5/20060613 => /usr/lib/php5/20060613
Now its time to find php.ini and get it configured...
 find / -name php.ini
Output should sth like this
Open /etc/php5/cli/php.ini and search for extension_dir this should be sth like this
; Directory in which the loadable extensions (modules) reside.
;extension_dir = 
Uncomment if commented and set extension_dir what you find with root@moinhaidar:~# php test.php like
extension_dir = "/usr/lib/php5/20060613"

Setup PHPList

Get the latest version of PHPList
Copy to appropriate loation, usually /var/www/ and untar/unzip whatever...
root@moinhaidar:~# mv phplist-2.11.5.tgz /var/www
root@moinhaidar:~# tar -xvzf phplist-2.11.5.tgz
root@moinhaidar:~# mv phplist-2.11.5 mylists
Now its time to configure ./mylist/config/config.php
[General settings for language and database]
$database_host = "localhost";
$database_name = "myphplist";
$database_user = "root";
$database_password = "dbpassword";
$installation_name = 'Whatever';

[Settings for handling bounces] $message_envelope = ''; $bounce_mailbox_user = 'noreply'; $bounce_protocol = 'mbox'; $bounce_mailbox = '/var/mail/noreply';
[Security related settings] $require_login = 1;
[Debugging and informational] define ("TEST",0); define('SEND_ONE_TESTMAIL',1);
Lets create new site namely phplist
root@moinhaidar:~# cp /etc/apache2/sites-available/default /etc/apache2/sites-available/phplist
Now "vi /etc/apache2/sites-available/phplist" and get it configure...
+ indicates new addition
* indicates modified
+ ServerName
* ServerAdmin
+ ServerAlias *
* DocumentRoot /var/www/mylists
#*Setting Off PHP safe mode in order to acheive bounce processing - site wise
php_admin_flag safe_mode Off

        Options FollowSymLinks
        AllowOverride None

        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
        + DirectoryIndex index.php index.html

Okay, Now enable mylists site and disable default one
sudo a2dissite default
sudo a2ensite lists
Now Check "vi /etc/apache2/sites-enabled/mylists", that should be same as sites-availabe one.
Installed IMAP module for PHP bcoz phpList bounce processing connects to your mail server via a PHP module called IMAP.
 apt-get install php5-imap


#Create a temp dir
Create tmp dir to ./var/www/mylists/ if not there.
#Change permission
root@moinhaidar:~# chmod -R 777 /var/www/mylists
#Restart server
root@moinhaidar:~# /etc/init.d/apache2 restart
Done Hit
Got uninitialized database?
Hit initialized database link. It will populate your database(myphplist).
Cross check the database
root@mail:~# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.0.51a-3ubuntu5.5 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use myphplist;
mysql> show tables;
| Tables_in_myphplist  |
| admin                |
| admin_attribute      |
| admin_task           |
Done! Go to and setup remaining thing and enjoy!

Basic Mail Server Setup

Install follwing package choosing options...
Option 1 - internet site : Mail will be get read/delivered directly via SMTP

Option 2 - : FQDN

root@moinhaidar:~# aptitude install postfix telnet mailx postfix-mysql
Configure /etc/postfix/ adding followings
myhostname =
myorigin = $mydomain
mydestination =  $mydomain, localhost.$mydomain, localhost
Edit /etc/mailname and /etc/hostname having
Edit /etc/hosts having     localhost localhost.localdomain
Reboot the system
sudo reboot
Add a user namely noreply

Setup Reverse DNS

Quick Test

Subject: test email from
test body of the email.
No confirmation is given that the email has been sent but the logs will show the details.

Check the receiving email address and I hope you got expected!!! :)

Monday, August 23, 2010

Open Social Ruby Wrapper 0.0.4 - NameError : uninitialized constant


NameError: uninitialized constant ActionController::AbstractRequest
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:440:in `load_missing_constant'
        from c:/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in `const_missing'
        from c:/ruby/lib/ruby/gems/1.8/gems/opensocial-0.0.4/lib/opensocial/auth/action_controller_request.rb:32
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from c:/ruby/lib/ruby/gems/1.8/gems/opensocial-0.0.4/lib/opensocial.rb:19
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
        from c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'


and resplace "proxies ActionController::AbstractRequest" with "proxies ActionController::Request" at Line 32
or more specifically
module OAuth::RequestProxy #:nodoc: all
  class ActionControllerRequest < OAuth::RequestProxy::Base
    # proxies ActionController::AbstractRequest
    if ActionController.const_defined?(:AbstractRequest)
      proxies ActionController::AbstractRequest
      proxies ActionController::Request

Saturday, August 21, 2010

OAuth Twitter API: Post message , status 401 Unauthorized

   First thing first check out the access level. If its read only, fix it read and wirte both.

   If its already read and write then most probably you are doing post having read and write access but authorization is still of read only. Follow this link to revoke the access and reauthorize it again.