====== Roundcube Webmail ======
[[https://roundcube.net/|Roundcube]] is a well proven webmail client written in PHP.
**Note:** i installed roundcube on my //external// server, together with the mail server, and not on the home server. The unusual approach you might note here are due to that noticeable differences.
===== Prerequisites =====
Since i don't want to oberate the external server with containers, i will show you how to install Roundcube on bare metal. It's relatively easy anyway.
You need PHP and NGINX installed. PHP requires some extensions like PDO and zip, also Roundcube requires aspell to be installed for syntax checking, which is controlled by L10N variable in /etc/portage/make.conf:
echo app-eselect/eselect-php fpm >> /etc/portage/package.use/php
echo dev-lang/php fpm sqlite zip spell intl pdo curl exif gd xmlreader writer >> /etc/portage/package.use/php
echo 'L10N="it de fr en"' >> /etc/portage/make.conf
emerge -vp php aspell
# The following is optional, if you haven't yet created a web user:
# useradd --shell /sbin/nologin web
Since i use NGINX, the fpm flag needs also to be enabled.
If you haven't yet done so, ensure your php-fpm is running as user web by checking the rows:
user = web
group = web
in file **/etc/php/fpm-php8.2/fpm.d/www.conf**
===== Installation =====
Let's follow [[https://github.com/roundcube/roundcubemail/wiki/Installation|this]] installation guide, and let's personalize it a bit.
Since i want to share PHP between Rouncube and other public services, due to the limited resources of the external server, i will not create a dedicated user, which would require also to run multiple PHP copies.
The webmail will be installed under **/home/web/roundcube**. Run the following commands ar user root:
mkdir /home/web/roundcube
mkdir /var/log/roundcube
chown web:web /var/log/roundcube
Download the latest **complete** package from [[https://roundcube.net/download/]] and decompress it. Since this is the **complete** package, there is no need to install dependencies using composer.
Set proper permissions and create the folder to store the SQLite database (mysql or postgres are overkill for small needs):
cd /home/web/roundcube
mkdir db temp
chown web:web db temp
wget https://github.com/roundcube/roundcubemail/releases/download/X.Y.X/roundcubemail-X.Y.Z-complete.tar.gz
tar xvf roundcubemail-X.Y.Z-complete.tar.gz
ln -s roundcubemail-X.Y.Z-complete.tar.gz roundcubemail
Done! Now setup the NGINX webserver.
===== NGINX setup =====
Assuming that PHP-FPM is on port 9000, the following configuration should be enough:
server {
server_name webmail.mydomain.com;
listen 443 ssl;
index index.php;
root /home/web/roundcube/roundcubemail;
access_log /var/log/nginx/webmail.mydomain.com_access_log main;
error_log /var/log/nginx/webmail.mydomain.com_error_log info;
# The following lines should be uncommented after initial setup is complete!
# location ~ /(config/|temp/|logs/|installer) {
# deny all;
# alias /home/web/roundcube/roundcubemail;
# }
location ~ /.*\.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $request_filename;
fastcgi_pass 127.0.0.1:9000;
}
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/mydomain.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/mydomain.com/privkey.pem;
}
Restart your NGINX and configure Roundcube.
===== Configuration =====
Point your browser to **https://webmail.mydomain.com/installer** and follow the onscreen instructions
Double check the **temp** and **logs** paths, you need to change the path to point to the folders you created in the previous step.
When asked for database, use this as file path **/home/web/roundcube/db/roundcube.db**.
Save the settings by copying the produced config file as **/home/web/roundcube/roundcubemail-/config/config.inc.php**.
Here is an example which works with Stalwart:
$config['db_dsnw'] = 'sqlite:////home/web/roundcube/db/roundcube.db?mode=0646';
$config['imap_host'] = 'ssl://mail.mydomain.com';
$config['smtp_host'] = 'ssl://mail.mydomain.com';
$config['smtp_auth_type'] = "PLAIN";
$config['support_url'] = '';
$config['log_dir'] = '/var/log/roundcube';
$config['temp_dir'] = '/home/web/roundcube//temp/';
$config['des_key'] = '<>';
$config['plugins'] = ['acl', 'archive', 'attachment_reminder', 'emoticons', 'enigma', 'filesystem_attachments', 'jqueryui', 'managesieve', 'markasjunk', 'new_user_dialog', 'newmail_notifier', 'subscriptions_option', 'userinfo', 'vcard_attachments', 'zipdownload'];
$config['language'] = 'en_US';
$config['enable_spellcheck'] = true;
$config['spellcheck_engine'] = 'pspell';
$config['mime_param_folding'] = 0;
At this point the installation is complete.
===== CardDav Plugin =====
To enable integration with your CardDav addressbook,
Download latest tarball from [[https://github.com/mstilkerich/rcmcarddav/releases|here]] and decompress it into rouncube //plugins// folder, then enable it by adding **carddav** to the //$config['plugins']// defined above.
**Note:** it is critical that you LOGOUT from Roundcube before enabling the plugin, and LOGIN again after. This is because this will create the needed table. If you don't, you will get an internal error.
===== Autostart =====
Roundcube only depends on PHP-FPM and NGINX, ensure they are both autostarting:
rc-update add php-fpm default
rc-update add nginx default