Author Topic: Win2003,PHP5,IIS6,mySQL,hMailServer,phpWebAdmin,RoundCube  (Read 46930 times)

Offline armega

  • Newbie
  • *
  • Posts: 2
Win2003,PHP5,IIS6,mySQL,hMailServer,phpWebAdmin,RoundCube
« on: August 07, 2007, 09:42:02 PM »
This tutorial will walk you through setting up PHP5, IIS6, mySQL, hMailServer (with phpWebAdmin), and RoundCube on your webserver.

Note: The following tutorial will take me a few days to write to make sure I did not forget anything. Opinions are welcome and if you see a mistake on my part please do point it out. I hope this might help some people out, though I think it might as I have already received a few requests to shed some light on the install process.

Assumptions: In the following tutorial I assume that you have two hosts set up. For this example I will use 'mydomain.com' and 'clientsdomain.com'.

Step One: Download all the required files
(a) IIS6 - Comes with Windows 2003 Server
(b) mySQL - http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.45-win32.zip/from/http://mysql.mirror.redwire.net/
(c) mySQL GUI Tools - http://dev.mysql.com/get/Downloads/MySQLGUITools/mysql-gui-tools-5.0-r12-win32.msi/from/http://mysql.mirrors.hoobly.com/
(d) hMailServer (with phpWebAdmin) - http://hmailserver.com/?page=background_download_file&mirrorid=1&downloadid=138
(e) RoundMail - http://sourceforge.net/project/downloading.php?group_id=139281&use_mirror=easynews&filename=roundcubemail-0.1-rc1.1.tar.gz&47212361
(f) PHP5.2.3 - http://us3.php.net/get/php-5.2.3-win32-installer.msi/from/us.php.net/mirror

Step Two: Add the 'Application Server' role to your 2003 server
(a) This can be done by clicking Start->Manage Your Server->Add or Remove Role

Step Three: Set up PHP5.2.3
(a) Click the installation file to install it and follow the step by step instructions. I have been using PHP for years and this is by far the best setup file they have made that automates allot of the task you would otherwise need to do.
(b) You basically need to make sure you choose just a few options to get the install right. You need to make sure you use IIS ISAPI install option, and when you get to extensions make sure you add the mySQL extension.

Step Four: Set up IIS6
(a) You will need to create one domain called 'mail.mydomain.com', so right click Web Sites->New->Web Site.
(b) Call it 'mail.mydomain.com', and assign the ip to it you wish to use for all web mail websites. (Hint: mail.mydomain.com and mail.clientsdomain.com will both point and access this IP) In this case I will use 10.56.24.1 as a demo IP. Use port 80, and for the Host Header type 'mail.mydomain.com'.
(c) Ok for the Path you want to choose a directory that you want to use for the WEBMAIL only templates to sit in. For this example I use 'C:\web\webmail' and leave Allow anonymous access checked. (Hint: In case anyone cares to imagine how I have my web server setup, I have a directory on the root of C:\ called 'web' and in that I have three folders called 'webmail', 'websites', and 'logs')
(d) Allow only Read permissions and finish the wizard.
(e) Now that you have your site set up, lets configure it. Right click on it and go to properties.
(f) Under the 'Web Site' tab you should see your IP (10.56.24.1). Click the advanced button next to it. This will be where you set multi hosts for your server to answer to. Currently there should be only one at this point. 10.56.24.1 port 80 and a host header of mail.mydomain.com. Click the add button and chose the same IP for the IP address (10.56.24.1), port 80 and host mail.clientsdomain.com. Then after that click OK.
(g) Go to the Home Directory tab and at the bottom change Execute permissions from 'None' to 'Scripts only'.
(h) Go to the Documents tab and click Add (to add a default content pag(e) and type 'index.php'. (Hint: I usually bump the index.php to the top of my list)
(i) Now last for setting up the site, dealing with DNS records... You should have an A type dns record for mydomain.com that points to your webmail IP (10.56.24.1) and that has a host of 'mail.mydomain.com'. There should be a CNAME type dns record for clientsdomain.com that points to 'mail.mydomain.com' and has a host of 'mail.clientsdomain.com'. (Hint: Basically a redirect for the clients domain nam(e)

Step Five: Setup mySQL
(a) This is strait forward for the most part believe it or not... Just run the setup file and follow the instructions after you extract it. First off use the custom setup so you can choose various options and click next. Here you can change the path of the install directory if you want then click next. Then click install to start the installation and click next twice. Make sure the check box is clicked to configure mySQL and click finished. Now onto configuring mySQL. Choose Detailed Configuration. Next use Server Machine. Next choose Multifunctional Database. Ok here you can choose the path where your database information is stored then click next. Choose Decision Support (DSS)/OLAP. (Note: This is not a limit but just what the server by default reserves) Click next using port 3306 and strict mode and then next again using standard character set. Ok the next screen you want to make sure all three check boxes are checked and the service name is something like mySQL5. Next give the server a root password and DO NOT set an anonymous account up! I also leave the enable remote access unchecked as well. Next hit execute. Then click finished and mySQL has been setup.
(b) Now you want to set up a mySQL GUI for you to easily modify the databases in mySQL. You do this by installing mySQL GUI tools. This installs mySQL Administrator which is used to view the SQL server in a GUI and make changes to it as you would MSSQL.

Step Six: Install hMailServer
(a) On to the good stuff! I have never been so impressed with zero dollar software. This is a GREAT simple and easy to use server that has the ability to adapt to your needs with the help of a little PHP code. Installing hMailServer is fairly simple for a first time user. It also helps that the developers happen to write up a quick tutorial to get you started (this is where most of my steps come from). That tutorial can be found at http://www.hmailserver.com/documentation/?page=howto_install. Start out by running the install file and going through the process. Ok when you get to the point to choose a database you want to choose a mySQL database setup from a server you already have. It seemed to walk me through and create the tables it needed for me... Though it said otherwise in there tutorial it did it all! :) Don't forget to set a good password for the administration console during instillation!
(b) Run the administration program and set up the main domain (mydomain.com) and user. Next create the clientsdomain.com and a testusr user or something to test with.
(c) Settings->Protocols->SMTP->Delivery Of e-Mail->Host name: make sure this is set to your hostname. (ex: mail.mydomain.com)
(d) Settings->Protocols->SMTP->Advanced->Bind To Local Address: make sure this is set to the address you wish to send mail out of (ex: 10.56.24.1).
(e) Now that should get your email server setup... At this point make sure you can send and receive emails on mydomain.com and clientsdomain.com

Step Seven: Setup RoundCube
(a) A beautiful webmail that is at the least anything but just webmail. It has style, design, adaptivity, simplicity, and all of that for the big price tag of $0. We shale start out by extracting the downloaded archive to your C:\web\webmail directory.
(b) First things first... We need to set up a database for roundcube. You do this by opening up mySQL Administrator and type in user root and your root password that you gave when installing mySQL. Next click on 'Catalogs' (bottom left) and you should see the databases (AKA Schema) bottom left listbox. Right click in the white area of that listbox and click 'Create New Schema'. Name it 'roundcubemail'. Next click on 'User Administration' in the top left listbox and it should list all the user in the bottom left listbox. Right click in the bottom left listbox white area and make sure that 'Show hosts in userlist' is CHECKED. Right click in there again and click 'Add new user'. On the right hand side a new user information box will show. In the MySQL User field type 'roundcube', then type in a password for roundcube to use. (Hint: Make it something like fhFdf534aa or something else hard to remember. You will only need to remember this password for a short time and I would not use an admin password because it will be in plain text.) Remember this password by writing it down for a second on a piece of paper or in notepad (This is temporary). Click apply changes. Next you need to right click on the new roundcube user (bottom left listbox) and click 'Add host from which the user can connect' then type 'localhost'. Then click 'Apply changes'. Next right click on the new roundcube user again and click 'Remove host from which the user can connect'. (Hint: MAKE SURE you right clicked on roundcube and not localhost!) Then the % (Anyhost) will be deleted so click OK. Then Apply Changes again.
(c) Next you want to copy the C:\web\webmail\config\db.inc.php.dist and main.inc.php.dist files to the same directory without the .dist on the end. (ex: C:\web\webmail\config\db.inc.php)
(d) Ok now to edit the database config file. Open C:\web\webmail\config\db.inc.php and edit it such as the following example...
$rcmail_config = array();
$rcmail_config['db_dsnw'] = 'mysql://roundcube:fhFdf534aa@localhost/roundcubemail';
$rcmail_config['db_dsnr'] = '';
$rcmail_config['db_backend'] = 'db';
$rcmail_config['db_max_length'] = 512000; // 500K
$rcmail_config['db_persistent'] = TRUE;
$rcmail_config['db_table_users'] = 'users';
$rcmail_config['db_table_identities'] = 'identities';
$rcmail_config['db_table_contacts'] = 'contacts';
$rcmail_config['db_table_session'] = 'session';
$rcmail_config['db_table_cache'] = 'cache';
$rcmail_config['db_table_messages'] = 'messages';
?>
(e) OK now edit the roundcube config file. Open C:\web\webmail\config\main.inc.php and edit it such as the following example...
$rcmail_config = array();
$rcmail_config['debug_level'] = 1;
$rcmail_config['enable_caching'] = FALSE;
$rcmail_config['message_cache_lifetime'] = '10d';
$rcmail_config['auto_create_user'] = TRUE;
$rcmail_config['default_host'] = 'mail.xeonics.net';
$rcmail_config['default_port'] = 143;
$rcmail_config['username_domain'] = str_replace("mail.", "", $_SERVER['HTTP_HOST']);
$rcmail_config['mail_domain'] = str_replace("mail.", "", $_SERVER['HTTP_HOST']);
$rcmail_config['virtuser_file'] = '';
$rcmail_config['virtuser_query'] = '';
$rcmail_config['smtp_server'] = 'mail.xeonics.net';
$rcmail_config['smtp_port'] = 25;
$rcmail_config['smtp_user'] = '%u';
$rcmail_config['smtp_pass'] = '%p';
$rcmail_config['smtp_auth_type'] = '';
$rcmail_config['smtp_log'] = TRUE;
$rcmail_config['list_cols'] = array('subject', 'from', 'date', 'size');
$rcmail_config['skin_path'] = 'skins/default/';
$rcmail_config['temp_dir'] = 'temp/';
$rcmail_config['log_dir'] = 'logs/';
$rcmail_config['session_lifetime'] = 10;
$rcmail_config['ip_check'] = false;
$rcmail_config['double_auth'] = false;
$rcmail_config['des_key'] = 'rcmail-!24ByteDESkey*Str';
$rcmail_config['locale_string'] = 'en';
$rcmail_config['date_short'] = 'D n:ia';
$rcmail_config['date_long'] = 'm/d/Y n:ia';
$rcmail_config['date_today'] = 'n:ia';
$rcmail_config['useragent'] = 'RoundCube Webmail/0.1-rc1';
$rcmail_config['product_name'] = 'MyDomain Webmail';
$rcmail_config['imap_root'] = '';
$rcmail_config['drafts_mbox'] = 'Drafts';
$rcmail_config['junk_mbox'] = 'Spam';
$rcmail_config['sent_mbox'] = 'Sent';
$rcmail_config['trash_mbox'] = 'Trash';
$rcmail_config['default_imap_folders'] = array('INBOX', 'Drafts', 'Sent', 'Spam', 'Trash');
$rcmail_config['protect_default_folders'] = TRUE;
$rcmail_config['skip_deleted'] = FALSE;
$rcmail_config['read_when_deleted'] = TRUE;
$rcmail_config['flag_for_deletion'] = TRUE;
$rcmail_config['enable_spellcheck'] = TRUE;
$rcmail_config['spellcheck_uri'] = '';
$rcmail_config['spellcheck_languages'] = NULL;
$rcmail_config['generic_message_footer'] = '';
$rcmail_config['mail_header_delimiter'] = NULL;
$rcmail_config['dont_override'] = array();
$rcmail_config['javascript_config'] = array('read_when_deleted', 'flag_for_deletion');
$rcmail_config['include_host_config'] = FALSE;
$rcmail_config['pagesize'] = 40;
$rcmail_config['timezone'] = 1;
$rcmail_config['dst_active'] = TRUE;
$rcmail_config['prefer_html'] = TRUE;
$rcmail_config['prettydate'] = TRUE;
$rcmail_config['message_sort_col'] = 'date';
$rcmail_config['message_sort_order'] = 'DESC';
$rcmail_config['draft_autosave'] = 300;
?>
(e) Notice the $rcmail_config['username_domain'] and $rcmail_config['mail_domain'] variables. They are set depending on the host from which the user is coming from. (Ex: the host would be mydomain.com if the user browses to mail.mydomain.com and the host would be clientsdomain.com if the user browses to mail.clientsdomain.com)

Step Eight: Setting up phpWebAdmin
(a) Copy the C:\Program Files\hMailServer\PHPWebAdmin folder to C:\web\webmail\admin (Hint: the new path should NOT be C:\web\webmail\admin\PHPWebAdmin).
(b) Create two folders 'C:\web\webmail\admin\temp' and 'C:\web\webmail\admin\template_c'
(c) Copy config-dist.php to config.php then open up config.php
(d) Edit the config.php file to look like the following example...
$hmail_config['rootpath']      = "C:/web/webmail/admin/";
$hmail_config['rooturl']      = "http://".$_SERVER['HTTP_HOST']."/admin/";
$hmail_config['includepath']      = $hmail_config['rootpath']."include/";
$hmail_config['temppath']      = $hmail_config['rootpath']."temp/";
$hmail_config['pluginpath']       = $hmail_config['rootpath']."plugins/";
$hmail_config['defaultlanguage']   = "english";
$hmail_config['defaulttheme']    = "default";
?>
(e) Notice the $hmail_config['rooturl'] variable. This will make sure that the root url is changed according to the domain the user browses to such as the way it does in the roundcube setup.
(f) OK the last thing I did so that when someone goes to the admin web page they only enter there user name and not the entire email address. This makes the experience seem a little more personalized to the user. Open C:\web\webmail\admin\background_login.php so you can edit it. You will add a line right under the line that sets the username variable.
ORIGINAL CLIP START

$username   = hmailGetVar("username","");
$password = hmailGetVar("password","");
ORIGINAL CLIP END
NEW CLIP START

$username   = hmailGetVar("username","");
if (strstr($username, "@") == "") { $username = $username."@".str_replace("mail.", "", $_SERVER['HTTP_HOST']); }
$password = hmailGetVar("password","");
NEW CLIP END

NOTES FROM AUTHOR: There are a few other things that I did (user rights etc) on the windows box itself that I can't remember off hand to get various things working... Hopefully someone will require help on these issues so I may address them on this post.

Offline armega

  • Newbie
  • *
  • Posts: 2
Re: Win2003,PHP5,IIS6,mySQL,hMailServer,phpWebAdmin,RoundCube
« Reply #1 on: August 07, 2007, 09:43:02 PM »
Please do comment and let me know if this tutorial has been useful to you. I will be spending a little time on doing this and I just hope I can provide at least a little help to the community to show my respect for what the developers at both hMailServer and RoundCube have done.

Just for reference my original post is at...
http://www.hmailserver.com/forum/viewtopic.php?t=10103

Just so everyone knows... I'm not going to update this post anymore just because there is double the work updating the roundcube and hmailserver post each time someone asks me to fix something or requests more information on cretin aspects of the install guide. I will leave this posted here but if you need more help please venture over to my other post on hmailserver and comment/ask questions there.

Offline SKaero

  • Administrator
  • Hero Member
  • *****
  • Posts: 5,879
    • SKaero - Custom Roundcube development
Re: Win2003,PHP5,IIS6,mySQL,hMailServer,phpWebAdmin,RoundCube
« Reply #2 on: August 07, 2007, 10:34:58 PM »
Thanks for posting! I am sure this will help some people who are installing roundcube.