Ricerca nel sito web

Come installare Invoice Ninja su Ubuntu 20.04


Su questa pagina

  1. Prerequisiti
  2. Per iniziare
  3. Installa il server LAMP
  4. Configura database MariaDB
  5. Installa Invoice Ninja
  6. Configura Apache per Invoice Ninja
  7. Accedi a Invoice Ninja
  8. Secure Invoice Ninja con Lets Encrypt SSL
  9. Conclusione

Invoice Ninja è un'app di fatturazione online gratuita e open source per liberi professionisti e aziende che ti aiuta ad accettare pagamenti, tenere traccia delle spese, creare proposte e attività temporali. È un'applicazione di fatturazione self-hosted molto simile alle applicazioni di fatturazione commerciale come Freshbooks. Ti consente di creare la tua fattura personalizzata e di inviarla online in un secondo.

Invoice Ninja è molto utile per le piccole o medie imprese. Se stai cercando un software di fatturazione sicuro e facile da usare, Invoice Ninja è l'opzione migliore per te.

In questo tutorial, ti mostreremo come installare Invoice Ninja con Apache e Lets Encrypt SSL sul server Ubuntu 20.04.

Prerequisiti

  • Un server che esegue Ubuntu 20.04.
  • Un nome di dominio valido indicato con l'IP del tuo server.
  • Una password di root è configurata sul server.

Iniziare

Innanzitutto, si consiglia di aggiornare i pacchetti di sistema all'ultima versione. Eseguire il seguente comando per aggiornare tutti i pacchetti:

apt-get update -y

Una volta aggiornati tutti i pacchetti, installa le altre dipendenze richieste con il seguente comando:

apt-get install software-properties-common apt-transport-https ca-certificates gnupg2 -y

Una volta installate tutte le dipendenze, puoi procedere al passaggio successivo.

Installa LAMP Server

Successivamente, dovrai installare Apache, MariaDB e PHP sul tuo sistema. Innanzitutto, installa i pacchetti Apache e MariaDB con il seguente comando:

apt-get install apache2 mariadb-server -y

Dopo aver installato entrambi i pacchetti, dovrai installare PHP versione 7.2 e altre estensioni nel tuo sistema.

Per impostazione predefinita, Ubuntu 20.04 viene fornito con PHP versione 7.4. Quindi dovrai aggiungere il repository Ondrej al tuo sistema.

Puoi aggiungere il repository PHP Ondrej con il seguente comando:

add-apt-repository ppa:ondrej/php

Una volta aggiunto il repository, installa PHP e altre estensioni con il seguente comando:

apt-get install php7.2 libapache2-mod-php7.2 php-imagick php7.2-fpm php7.2-mysql php7.2-common php7.2-gd php7.2-json php7.2-curl php7.2-zip php7.2-xml php7.2-mbstring php7.2-bz2 php7.2-intl php7.2-gmp unzip -y

Dopo aver installato tutti i pacchetti, verifica la versione di PHP installata con il seguente comando:

php -v

Dovresti vedere il seguente output:

PHP 7.2.34-8+ubuntu20.04.1+deb.sury.org+1 (cli) (built: Oct 31 2020 16:57:33) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.34-8+ubuntu20.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies

Configura database MariaDB

Successivamente, dovrai creare un database e un utente per Invoice Ninja. Innanzitutto, accedi alla console MariaDB con il seguente comando:

mysql

Una volta effettuato l'accesso, creare un database e un utente con il seguente comando:

MariaDB [(none)]> create database invoicedb;
MariaDB [(none)]> create user identified by 'password';

Quindi, concedi tutti i privilegi a billedb con il seguente comando:

MariaDB [(none)]> grant all privileges on invoicedb.* to ;

Successivamente, svuota i privilegi ed esci dalla console MariaDB con il seguente comando:

MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;

Al termine, puoi procedere al passaggio successivo.

Installa Fattura Ninja

Innanzitutto, scarica l'ultima versione di Invoice Ninja dal suo sito Web ufficiale:

wget -O invoice-ninja.zip https://download.invoiceninja.com/

Una volta completato il download, decomprimere il file scaricato nella directory principale di Apache utilizzando il seguente comando:

unzip invoice-ninja.zip -d /var/www/html/

Quindi, imposta le autorizzazioni e la proprietà appropriate con il seguente comando:

chown -R www-data:www-data /var/www/html/ninja
chmod -R 755 /var/www/html/ninja

Una volta terminato, puoi procedere al passaggio successivo.

Configura Apache per Invoice Ninja

Successivamente, dovrai creare un file di configurazione dell'host virtuale Apache per Invoice Ninja. Puoi crearlo con il seguente comando:

nano /etc/apache2/sites-available/ninja.conf

Aggiungi le seguenti righe:

<VirtualHost *:80>
    ServerName invoice.example.com
    DocumentRoot /var/www/html/ninja/public
    <Directory /var/www/html/ninja/public>
       DirectoryIndex index.php
       Options +FollowSymLinks
       AllowOverride All
       Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/invoice-ninja.error.log
    CustomLog ${APACHE_LOG_DIR}/invoice-ninja.access.log combined

    Include /etc/apache2/conf-available/php7.2-fpm.conf
</VirtualHost>

Salva e chiudi il file, quindi abilita il file dell'host virtuale con il seguente comando:

a2ensite ninja.conf

Successivamente, abilita i moduli Apache richiesti utilizzando il seguente comando:

a2enmod mpm_event proxy_fcgi setenvif
a2enmod rewrite

Infine, riavvia il servizio Apache per applicare le modifiche:

systemctl restart apache2

Ora puoi verificare lo stato di Apache usando il seguente comando:

systemctl status apache2

Dovresti ottenere il seguente output:

? apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2020-12-27 07:15:15 UTC; 11s ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 25097 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
   Main PID: 25113 (apache2)
      Tasks: 55 (limit: 2353)
     Memory: 5.3M
     CGroup: /system.slice/apache2.service
             ??25113 /usr/sbin/apache2 -k start
             ??25114 /usr/sbin/apache2 -k start
             ??25115 /usr/sbin/apache2 -k start

Dec 27 07:15:15 ubuntu systemd[1]: Starting The Apache HTTP Server..

A questo punto, Apache è configurato per servire Invoice Ninja. Ora puoi procedere al passaggio successivo.

Accedi a Fattura Ninja

Ora apri il tuo browser web e accedi a Invoice Ninja utilizzando l'URL http://invoice.example.com. Verrai reindirizzato alla seguente pagina:

Fornisci l'URL del tuo sito web, i dettagli del database, il nome utente dell'amministratore, la password e fai clic sul pulsante Invia. Verrai reindirizzato alla schermata di accesso di Invoice Ninja:

Fornisci il nome utente e la password dell'amministratore e fai clic sul pulsante LOGIN. Dovresti vedere la dashboard di Invoice Ninja nella seguente schermata:

Secure Invoice Ninja con Lets Encrypt SSL

È sempre una buona idea proteggere il tuo sito web con Lets Encrypt SSL. Dovrai installare il client Certbot per installare e gestire SSL. Puoi installarlo con il seguente comando:

apt-get install python3-certbot-apache -y

Una volta installato Certbot, esegui il seguente comando per proteggere il tuo sito web con Lets Encrypt SSL:

certbot --apache -d invoice.example.com

Ti verrà chiesto di fornire la tua email e di accettare i termini di servizio come mostrato di seguito:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator standalone, Installer None
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: Y
Plugins selected: Authenticator apache, Installer apache
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for invoice.example.com
Enabled Apache rewrite module
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/invoice-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/invoice-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/invoice-le-ssl.conf

Successivamente, seleziona se reindirizzare o meno il traffico HTTP su HTTPS come mostrato di seguito:

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2

Digita 2 e premi Invio per installare Lets Encrypt SSL per il tuo sito web:

Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/invoice.conf to ssl vhost in /etc/apache2/sites-available/invoice-le-ssl.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://invoice.example.com

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=invoice.example.com
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/invoice.example.com/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/invoice.example.com/privkey.pem
   Your cert will expire on 2020-10-23. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Ora puoi accedere al tuo sito web in modo sicuro utilizzando l'URL https://invoice.example.com.

Conclusione

Congratulazioni! hai installato e configurato correttamente Invoice Ninja con Lets Encrypt SSL sul server Ubuntu 20.04. Ora puoi esplorare Invoice Ninja per ulteriori funzionalità e distribuirlo nell'ambiente di produzione. Non esitate a chiedermi se avete domande.