Php List Tutorial

Install and setup PHPList

PHPList is an open-source newsletter manager, free to download, install and use. Follow this link to know more...
http://www.phplist.com/details
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
1apt-get install apache2 php5
Following NEW packages will be installed
1apache2 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
1aptitude install mysql-server mysql-client libmysqlclient15-dev libapache2-mod-auth-mysql php5-mysql
The following NEW packages will be installed
1apparmor 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
1dpkg --get-selections
2dpkg -L php5|apache2|mysql-client-5.0
To check whereabouts of MySQL
1root@moinhaidar:~# find / -type d -name "mysql"
It will give you sth like this...
1/var/lib/mysql
2/var/lib/mysql/mysql
3/var/log/mysql
4/usr/lib/mysql
5/usr/lib/perl5/DBD/mysql
6/usr/lib/perl5/auto/DBD/mysql
7/usr/include/mysql
8/usr/share/mysql
9/etc/mysql

Setup Database

Lets login to mysql we just installed
1root@moinhaidar:~# mysql -uroot -p
Enter the password you fed while installation.
Now you should be on mysql command line as seen like this
1Welcome to the MySQL monitor.  Commands end with ; or \g.
2Your MySQL connection id is 1
3Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
4mysql>
Create a database for PHPList namely myphplist
1mysql> create database myphplist;
2Query OK1 row affected (0.00 sec)
Grant privileges
1mysql> GRANT ALL PRIVILEGES ON myphplist.* TO 'root'@'localhost' IDENTIFIEDBY 'password' WITH GRANT OPTION;
2Query OK0 rows affected (0.00 sec)
Check that out
1mysql> show databases;
2+--------------------+
3| Database           |
4+--------------------+
5| information_schema |
6| myphplist          |
7| mysql              |
8+--------------------+
93 rows in set (0.00 sec)
Now its time to look into PHP installation. Create file say test.php using your favorite editor having
1<?php
2 phpinfo();
3?>
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.
1apt-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.
1extension_dir => /usr/lib/php5/20060613 => /usr/lib/php5/20060613
Now its time to find php.ini and get it configured...
1find / -name php.ini
Output should sth like this
1/etc/php5/cli/php.ini
2/etc/php5/apache2/php.ini
Open /etc/php5/cli/php.ini and search for extension_dir this should be sth like this
1; Directory in which the loadable extensions (modules) reside.
2;extension_dir =
Uncomment if commented and set extension_dir what you find with root@moinhaidar:~# php test.php like
1extension_dir = "/usr/lib/php5/20060613"

Setup PHPList

Get the latest version of PHPList
Copy to appropriate loation, usually /var/www/ and untar/unzip whatever...
1root@moinhaidar:~# mv phplist-2.11.5.tgz /var/www
2root@moinhaidar:~# tar -xvzf phplist-2.11.5.tgz
3root@moinhaidar:~# mv phplist-2.11.5 mylists
Now its time to configure ./mylist/config/config.php
01[General settings for language and database]
02$database_host "localhost";
03$database_name "myphplist";
04$database_user "root";
05$database_password "dbpassword";
06$installation_name 'Whatever';
07 
08 
09[Settings for handling bounces]
10$message_envelope 'noreply@yourdomain.com';
11$bounce_mailbox_user 'noreply';
12$bounce_protocol 'mbox';
13$bounce_mailbox '/var/mail/noreply';
14 
15 
16[Security related settings]
17$require_login 1;
18 
19 
20[Debugging and informational]
21define ("TEST",0);
22define('SEND_ONE_TESTMAIL',1);
Lets create new site namely phplist
1root@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
01+ ServerName yourdomain.com
02* ServerAdmin admin@yourdomain.com
03+ ServerAlias *.yourdomain.com yourdomain.com
04* DocumentRoot /var/www/mylists
05#*Setting Off PHP safe mode in order to acheive bounce processing - site wise
06php_admin_flag safe_mode Off
07<directory>
08        Options FollowSymLinks
09        AllowOverride None
10</directory>
11<directory var="" www="" mylists="">
12        Options Indexes FollowSymLinks MultiViews
13        AllowOverride None
14        Order allow,deny
15        allow from all
16        + DirectoryIndex index.php index.html
17</directory>
Okay, Now enable mylists site and disable default one
1sudo a2dissite default
2sudo 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.
1apt-get install php5-imap

Checklist

#Create a temp dir
Create tmp dir to ./var/www/mylists/ if not there.
root@moinhaidar:~#
#Change permission
root@moinhaidar:~# chmod -R 777 /var/www/mylists
#Restart server
root@moinhaidar:~# /etc/init.d/apache2 restart
Done Hit http://yourdomain.com/admin/
Got uninitialized database?
Hit initialized database link. It will populate your database(myphplist).
Cross check the database
01root@mail:~# mysql -uroot -p
02Enter password:
03Welcome to the MySQL monitor.  Commands end with ; or \g.
04Your MySQL connection id is 15
05Server version: 5.0.51a-3ubuntu5.5 (Ubuntu)
06Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
07mysql> use myphplist;
08mysql> show tables;
09+----------------------+
10| Tables_in_myphplist  |
11+----------------------+
12| admin                |
13| admin_attribute      |
14| admin_task           |
Done! Go to http://yourdomain.com/admin/?page=setup 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 - mail.youdomain.com : FQDN
1root@moinhaidar:~# aptitude install postfix telnet mailx postfix-mysql
Configure /etc/postfix/main.cf adding followings
1myhostname = mail.yourdomain.com
2myorigin = $mydomain
3mydestination =  $mydomain, localhost.$mydomain, localhost
Edit /etc/mailname and /etc/hostname having
1mail.yourdomain.com
Edit /etc/hosts having
1127.0.0.1     localhost localhost.localdomain
2server-ip    mail.yourdomain.com
Reboot the system
1sudo reboot
Add a user namely noreply
Setup Reverse DNS
Quick Test
1mail email@yourdomain.com
2Subject: test email from yourdomain.com
3test body of the email.
4.
5Cc:
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!!! :)
Sumber : http://moinhaidar.blogspot.com/2010/08/install-and-setup-phplist.html