Install ProjectSend on Ubuntu 20.04 with Nginx (LEMP Stack)

This tutorial will be showing you how to install ProjectSend on Ubuntu 20.04 LTS with Nginx web server.

What’s ProjectSend?

ProjectSend is a free open-source self-hosted file-sharing solution. ProjectSend Features:

  • Real-time statistics
  • Create client groups
  • self-registration and social login
  • Custom E-mail templates

Prerequisites

ProjectSend is written in PHP programing language. To follow this tutorial, you first need to install LEMP stack on Ubuntu 20.04. If you haven’t already done so, please check out the following tutorial.

You can install ProjectSend on your home server or a VPS (virtual private server). You also need a domain name, so later on your will be able to enable HTTPS to encrypt the HTTP traffic. I registered my domain name from NameCheap because the price is low and they give whois privacy protection free for life. ProjectSend can be installed without a domain name, but it really doesn’t make sense if you don’t encrypt the HTTP connection to prevent snooping. I recommend buying a domain name, if you really want to tinker with server software and use them to the fullest potential.

Now let’s install ProjectSend.

Step 1: Download ProjectSend on Ubuntu 20.04

Log into your Ubuntu 20.04 server. Then download the ProjectSend zip archive onto your server. The latest stable version is r1295 at time of this writing. You may need to change the version number. Go to https://www.projectsend.org/#download to see the latest version.

Download ProjectSend ubuntu

You can run the following command to download it on your server.

wget -O projectsend.zip https://www.projectsend.org/download/387/

Once downloaded, extract the archive with unzip.

sudo apt install unzip

sudo mkdir -p /usr/share/nginx/projectsend/

sudo unzip projectsend.zip -d /usr/share/nginx/projectsend/

The -d option specifies the target directory. ProjectSend web files will be extracted to /usr/share/nginx/projectsend/. Then we need to change the owner of this directory to www-data so that the web server (Nginx) can write to this directory.

sudo chown www-data:www-data /usr/share/nginx/projectsend/ -R

Step 2: Create a Database and User for ProjectSend in MariaDB Database Server

Log into MariaDB database server with the following command. Since MariaDB is now using unix_socket plugin to authentication user login, there’s no need to enter MariaDB root password. We just need to prefix the mysql command with sudo.

sudo mysql

Then create a database for ProjectSend. This tutorial name the database projectsend. You can use whatever name you like.

create database projectsend;

Create the database user. Again, you can use your preferred name for this user. Replace your-password with your preferred password.

create user projectsenduser@localhost identified by 'your-password';

Grant this user all privileges on the projectsend database.

grant all privileges on projectsend.* to projectsenduser@localhost;

Flush privileges and exit.

flush privileges;

exit;

Step 3: Configure ProjectSend

Go to the includes directory.

cd /usr/share/nginx/projectsend/includes/

Copy the sample configuration file and rename it to sys.config.php.

sudo cp sys.config.sample.php sys.config.php

Now edit the new config file with a command-line text editor like Nano.

sudo nano sys.config.php

Find the following lines and replace the red texts with the database name, username and password you created in step 2.

/** Database name */
define('DB_NAME', 'database');

/** Database host (in most cases it's localhost) */
define('DB_HOST', 'localhost');

/** Database username (must be assigned to the database) */
define('DB_USER', 'username');

/** Database password */
define('DB_PASSWORD', 'password');

Save and close the file. To save the file in Nano text editor, press Ctrl+O, then press Enter to confirm. Next, press Ctrl+X to exit.

Step 4: Create a Nginx Config File for ProjectSend

Create a projectsend.conf file in /etc/nginx/conf.d/ directory, with a command-line text editor like Nano.

sudo nano /etc/nginx/conf.d/projectsend.conf

Copy and paste the following text into the file. Replace projectsend.example.com with your own preferred sub-domain. Don’t forget to create DNS A record for this sub-domain in your DNS zone editor. If you don’t have a real domain name, I recommend going to NameCheap to buy one. The price is low and they give whois privacy protection free for life.

server {
    listen 80;
    listen [::]:80;
    server_name projectsend.example.com;

    # Add headers to serve security related headers
    add_header X-Content-Type-Options nosniff;
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Robots-Tag none;
    add_header X-Download-Options noopen;
    add_header X-Permitted-Cross-Domain-Policies none;
    add_header Referrer-Policy no-referrer;

    # Path to the root of your installation
    root /usr/share/nginx/projectsend/;
    index index.php index.html;

    access_log /var/log/nginx/projectsend.access;
    error_log /var/log/nginx/projectsend.error;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    location ~ /.well-known/acme-challenge {
      allow all;
    }

    # set max upload size
    client_max_body_size 512M;
    fastcgi_buffers 64 4K;

    # Disable gzip to avoid the removal of the ETag header
    gzip off;

    # Uncomment if your server is build with the ngx_pagespeed module
    # This module is currently not supported.
    #pagespeed off;

    error_page 403 /core/templates/403.php;
    error_page 404 /core/templates/404.php;

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

    location ~ \.php$ {
       include fastcgi_params;
       fastcgi_split_path_info ^(.+\.php)(/.*)$;
       try_files $fastcgi_script_name =404;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       fastcgi_param PATH_INFO $fastcgi_path_info;
       #Avoid sending the security headers twice
       fastcgi_param modHeadersAvailable true;
       fastcgi_param front_controller_active true;
       fastcgi_pass unix:/run/php/php7.4-fpm.sock;
       fastcgi_intercept_errors on;
       fastcgi_request_buffering off;
    }

   location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
        try_files $uri /index.php$uri$is_args$args;
        # Optional: Don't log access to other assets
        access_log off;
   }
}

Save and close the file. (To save a file in Nano text editor, press Ctrl+O, then press Enter to confirm. To exit, press Ctrl+X.)

Then test Nginx configuration.

sudo nginx -t

If the test is successful, reload Nginx for the changes to take effect.

sudo systemctl reload nginx

Step 5: Install and Enable PHP Modules

Run the following commands to install PHP modules required or recommended by ProjectSend.

sudo apt install imagemagick php-imagick php7.4-common php7.4-mysql php7.4-fpm php7.4-gd php7.4-json php7.4-curl  php7.4-zip php7.4-xml php7.4-mbstring php7.4-bz2 php7.4-intl php7.4-bcmath php7.4-gmp

Step 6: Enable HTTPS

Now you can access the ProjectSend web install wizard in your web browser by entering the domain name for your ProjectSend installation.

projectsend.example.com/install/index.php

If the web page can’t load, you probably need to open port 80 in firewall.

sudo iptables -I INPUT -p tcp --dport 80 -j ACCEPT

And port 443 as well.

sudo iptables -I INPUT -p tcp --dport 443 -j ACCEPT

Before entering any sensitive information, we should enable secure HTTPS connection on ProjectSend. We can obtain a free TLS certificate from Let’s Encrypt. Install Let’s Encrypt client (certbot) from Ubuntu 20.04 repository.

sudo apt install certbot python3-certbot-nginx

Python3-certbot-nginx is the Nginx plugin. Next, run the following command to obtain a free TLS certificate using the Nginx plugin.

sudo certbot --nginx --agree-tos --redirect --hsts --staple-ocsp --email [email protected] -d projectsend.example.com

Where:

  • –nginx: Use the Nginx authenticator and installer
  • –agree-tos: Agree to Let’s Encrypt terms of service
  • –redirect: Enforce HTTPS by adding 301 redirect.
  • –hsts: Enable HTTP Strict Transport Security. This defends against SSL/TLS stripping attack.
  • –staple-ocsp: Enable OCSP Stapling.
  • –email: Email used for registration and recovery contact.
  • -d flag is followed by a list of domain names, separated by comma. You can add up to 100 domain names.

You will be asked if you want to receive emails from EFF(Electronic Frontier Foundation). After choosing Y or N, your TLS certificate will be automatically obtained and configured for you, which is indicated by the message below.

ubuntu-20.04-projectsend-certbot-letsencrypt-https

Step 7: Finish the Installation in your Web Browser

Now you can access the ProjectSend web install wizard using HTTPS connection.

https://projectsend.example.com/install/index.php

To complete the installation, you need to give it a site name and create an admin account.

projectsend-ubuntu-20.04-install-guide-nginx

Click the Install button, you will be able to log into the ProjectSend Web interface.

set-up-projectsend-ubuntu-nginx

How to Set up ProjectSend Email Notification

If your ProjectSend instance will be used by more than one person, it’s important that your ProjectSend server can send transactional emails, such as password-resetting email. Go to Options -> E-mail Notifications. You will find the email server settings. There are four send modes:

  • PHP mail (basic)
  • SMTP
  • Gmail
  • Sendmail

You can choose the sendmail mode if your ProjectSend host has an SMTP server running. Leave other fields blank.

projectsend sendmail

If you would like to use an SMTP server running on another host, then choose SMTP mode and enter the SMTP server address and login credentials like below. Choose STARTTLS for encryption.

projectsend email sending options

For how to set up an email server, please check out the following tutorial. Note that I highly recommend running iRedMail mail server on a fresh clean OS. Installing iRedMail on an OS that has other web applications can fail, and likely break existing applications.

Step 8: Increase PHP Memory Limit

The default PHP memory limit is 128MB. ProjectSend recommends 512MB for better performance. To change PHP memory limit, edit the php.ini file.

sudo nano /etc/php/7.4/fpm/php.ini

Find the following line. (line 409)

memory_limit = 128M

Change the value.

memory_limit = 512M

Save and close the file. Alternatively, you can run the following command to change the value without manually opening the file.

sudo sed -i 's/memory_limit = 128M/memory_limit = 512M/g' /etc/php/7.4/fpm/php.ini

Then reload PHP-FPM service for the changes to take effect.

sudo systemctl reload php7.4-fpm

Step 9: Increase Upload File Size Limit

The default maximum upload file size limit set by Nginx is 1MB. To allow uploading large files to your ProjectSend server, edit the Nginx configuration file for ProjectSend.

sudo nano /etc/nginx/conf.d/projectsend.conf

We have already set the maximum file size in this file, as indicated by

client_max_body_size 512M;

You can change it if you prefer, like 1G.

client_max_body_size 1024M;

Save and close the file. Then reload Nginx for the changes to take effect.

sudo systemctl reload nginx

PHP also sets a limit of upload file size. The default maximum file size for uploading is 2MB. To increase the upload size limit, edit the PHP configuration file.

sudo nano /etc/php/7.4/fpm/php.ini

Find the following line (line 846).

upload_max_filesize = 2M

Change the value like below:

upload_max_filesize = 1024M

Save and close the file. Alternatively, you can run the following command to change the value without manually opening the file.

sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 1024M/g' /etc/php/7.4/fpm/php.ini

Then restart PHP-FPM.

sudo systemctl restart php7.4-fpm

Adding Local DNS Entry

It’s recommended to edit the /etc/hosts file on your ProjectSend server and add the following entry, so that ProjectSend itself won’t have to query the public DNS, which can improve the overall stability. If your ProjectSend server can’t resolve the projectsend.example.com hostname, then you may encounter a 504 gateway time out error.

127.0.0.1   localhost projectsend.example.com

An IP address in the /etc/hosts file can have multiple hostnames, so if you have other applications installed on the same box, you can also add other hostnames or sub-domains on the same line like this:

127.0.0.1   localhost focal ubuntu projectsend.example.com nextcloud.example.com

Troubleshooting Tips

If you encounter errors, you can check one of the following log files to find out what’s wrong.

  • Nginx error log: /var/log/nginx/error.log
  • Nginx error log for the ProjectSend virtual host: /var/log/nginx/projectsend.error

Wrapping Up

I hope this tutorial helped you install ProjectSend on Ubuntu 20.04 server with Nginx. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial
[Total: 6 Average: 5]

2 Responses to “Install ProjectSend on Ubuntu 20.04 with Nginx (LEMP Stack)

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community (https://community.linuxbabe.com) for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here