<\/span><\/h2>\nWe can install Nginx from the Debian package repository.<\/p>\n
Stop the Apache2 service, and remove the package from your system:<\/p>\n
sudo service apache2 stop\r\nsudo apt-get remove apache2\r\nsudo apt-get autoremove<\/pre>\nRun the following commands to install Nginx on the server:<\/p>\n
sudo apt-get update\r\nsudo apt-get install nginx<\/pre>\nEnable Nginx to start on server boot:<\/p>\n
systemctl enable nginx<\/pre>\n<\/span>Step 3: Install PHP and PHP extensions Required by RainLoop<\/span><\/h2>\nFor RainLoop, we’ll be installing PHP 7.0. With this command, we will install PHP 7.0 as well as download and install all of the required PHP extensions:<\/p>\n
sudo apt-get install php7.0 php7.0-common php7.0-curl php7.0-xml php7.0-fpm php7.0-json php7.0-dev php7.0-mysql<\/pre>\nOpen the \/etc\/php\/7.0\/fpm\/pool.d\/www.conf configuration file and make sure that ‘listen = \/run\/php\/php7.0-fpm.sock’ is not commented out.<\/p>\n
<\/span>Step 4: Create Nginx server block<\/span><\/h2>\nCreate a new Nginx server block for the domain\/subdomain name that we will be using to access the RainLoop webmail application. For this tutorial, we will be using ‘webmail.domain.com<\/code>‘.<\/p>\nnano \/etc\/nginx\/sites-available\/rainloop.conf<\/pre>\nserver {\r\n listen 80;\r\n\r\n server_name webmail.domain.com<\/code><\/span>;\r\n root \/var\/www;\r\n\r\n index index.php;\r\n \r\n access_log \/var\/log\/nginx\/rainloop_access.log;\r\n error_log \/var\/log\/nginx\/rainloop_error.log;\r\n\r\n location \/ {\r\n try_files $uri $uri\/ \/index.php?$query_string;\r\n }\r\n\r\n location ~ \\.php$ {\r\n fastcgi_index index.php;\r\n fastcgi_split_path_info ^(.+\\.php)(.*)$;\r\n fastcgi_keep_conn on;\r\n fastcgi_pass unix:\/var\/run\/php\/php7.0-fpm.sock;\r\n include \/etc\/nginx\/fastcgi_params;\r\n fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;\r\n }\r\n location ~ \/\\.ht {\r\n deny all;\r\n }\r\n\r\n location ^~ \/data {\r\n deny all;\r\n }\r\n}<\/pre>\nDo not forget to replace webmail.domain.com<\/code><\/span> with your actual domain\/subdomain name. Save and close the file. To enable the server block in Nginx, you need to create a symbolic link to the\u00a0sites-enabled<\/code> directory. Use the following command to create a symbolic link:<\/p>\nsudo ln -s \/etc\/nginx\/sites-available\/rainloop.conf \/etc\/nginx\/sites-enabled\/rainloop.conf<\/pre>\nCheck if there are errors with the newly created Nginx configuration:<\/p>\n
sudo nginx -t\r\nnginx: the configuration file \/etc\/nginx\/nginx.conf syntax is ok\r\nnginx: configuration file \/etc\/nginx\/nginx.conf test is successful\r\n<\/pre>\nIf the syntax is OK and there are no errors, we can restart Nginx.<\/p>\n
sudo systemctl restart nginx.service<\/pre>\n