Skip to content

Instantly share code, notes, and snippets.

@ibqn
Last active July 14, 2019 14:10
Show Gist options
  • Save ibqn/859045713ab4a30bf0266d708f86d5a7 to your computer and use it in GitHub Desktop.
Save ibqn/859045713ab4a30bf0266d708f86d5a7 to your computer and use it in GitHub Desktop.
Install RainLoop Webmail on Ubuntu 18.04 or Raspbian

Install RainLoop Webmail

Download the latest RainLoop Webmail community version

wget http://www.rainloop.net/repository/webmail/rainloop-community-latest.zip

Create a new directory for our RainLoop webmail installation

sudo mkdir -p /var/www/rainloop

Extract the files from the archive and upload them to the RainLoop web root directory

sudo unzip rainloop-community-latest.zip -d /var/www/rainloop

Configure proper permission for files and directories of the RainLoop Set the read/write permissions for all RainLoop application directories to 755 (drwxr-xr-x)

sudo find /var/www/rainloop/ -type d -exec chmod 755 {} \;

Set the read/write permissions for all RainLoop application files to 644 (-rw-r--r--)

sudo find /var/www/rainloop/ -type f -exec chmod 644 {} \;

Change the ownership of the RainLoop Web root directory to www-data.

sudo chown -R www-data:www-data /var/www/rainloop/

Install latest versions of PHP and Nginx

Ubuntu

PHP 7.3 is the latest stable release of PHP. Say thanks to Ondřej Surý for maintaining PPA of most the popular PHP versions on launchpad. If you want to install a specific version of PHP, then this article can be helpful for you. This article will help you to install PHP 7.3, 7.2, 7.1 & PHP 7.0 on Ubuntu 18.04.

sudo apt install software-properties-common
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt-get install -y php7.3

Next, run the commands below to install PHP 7.3-FPM and related modules.

sudo apt install php7.3-fpm php7.3-common php7.3-curl php7.3-mbstring php7.3-xmlrpc php7.3-mysql php7.3-gd php7.3-xml php7.3-json php7.3-cli

After installing PHP 7.3, run the commands below to open PHP default config file.

sudoedit /etc/php/7.3/fpm/php.ini

Then make the changes on the following lines below in the file and save. The value below is great settings to apply in your environments.

file_uploads = On
allow_url_fopen = On
short_open_tag = On
memory_limit = 256M
cgi.fix_pathinfo = 0
upload_max_filesize = 100M
max_execution_time = 360

Rasbpian

To install this newer PHP version however, we must tap into the testing branch of Raspbian, commonly known by the codename buster. We must credit a new buster.list file used by Aptitude (apt-get)

sudoedit /etc/apt/sources.list.d/10-buster.list

and add this line:

deb http://mirrordirector.raspbian.org/raspbian/ buster main contrib non-free rpi

Now, by adding this and referencing -t buster in our apt-get commands, it wil use the newer versions of files available in the buster release which is not considered 100% stable. To facilitate this we need to create a buster preferences file

sudoedit /etc/apt/preferences.d/10-buster

And paste in the follwing:

Package: *
Pin: release n=stretch
Pin-Priority: 900

Package: *
Pin: release n=buster
Pin-Priority: 750

Save this file and update:

sudo apt update

You can see which release versions are available with which priority by using sudo apt-cache policy. You can also see specific versions of packages with

sudo apt-cache policy <package_name>

Now you are ready to install PHP 7.3 from the buster release including all the common PHP packages:

sudo apt-get install -t buster php7.3 php7.3-curl php7.3-gd php7.3-fpm php7.3-cli php7.3-opcache php7.3-mbstring php7.3-xml php7.3-zip

Once fully installed (accept any defaults when prompted), we should now tweak our PHP 7.3 FPM pool to be better optimized:

sudoedit /etc/php/7.3/fpm/conf.d/90-pi-custom.ini

And add:

cgi.fix_pathinfo=0

upload_max_filesize=64m
post_max_size=64m
max_execution_time=600

Verify PHP 7.3 installation complete

Finally reload php

sudo service php7.3-fpm reload

After this has been completed, you can quickly test to make sure things have been installed by simply typing:

php -v 

To test PHP 7.3 settings with Nginx, create a phpinfo.php file in Nginx root directory by running the commands below

sudoedit /var/www/html/phpinfo.php

Then type the content below and save the file.

<?php phpinfo(); ?>

Configure a Server Block for RainLoop

Create the virtual host file by executing the following command:

sudoedit /etc/nginx/sites-available/rainloop

Then paste the content below

server {
    listen 80;
    listen [::]:80;
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    ssl_certificate /etc/letsencrypt/live/mail.zyfron.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/mail.zyfron.com/privkey.pem;

    server_name mail.zyfron.com;

    root /var/www/rainloop;

    access_log /var/log/rainloop/access.log;
    error_log /var/log/rainloop/error.log;

    index index.php;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_keep_conn on;
        fastcgi_pass unix:/var/run/php/php7.3-fpm.sock;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    } 

    location ~ /\.ht {
        deny all;
    }

    location ^~ /data {
       deny all;
    }
}

Enable rainloop configuration for nginx

sudo ln -s /etc/nginx/sites-available/rainloop /etc/nginx/sites-enabled/rainloop

Verify that this configuretion is valid

sudo nginx -t

Restart nginx

sudo systemctl reload nginx

Accessing RainLoop Webmail

To access admin panel, use URL of the following kind: http://product_installation_URL/?admin

Default login is "admin", password is "12345".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment