Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
vms:invoiceninja [2015/09/04 01:47]
admin [Install Nginx with PHP (php-fpm)]
vms:invoiceninja [2015/09/04 02:58] (current)
admin [Backup the Database]
Line 147: Line 147:
 <​code>​ <​code>​
 > php artisan key:​generate > php artisan key:​generate
 +Application key [htxxxxxxxxxxxxxxxxxxxxxxxxxxxxGY] set successfully.
 +> nano -c config/​app.php
  
 +SET LINE 83:
 +     '​key'​ => env('​APP_KEY',​ '​htqGwktj0oDzolDW2c45qyNx0mD5NvGY'​),​
 +</​code>​
 +
 +
 +----
 +===== Configure Nginx and PHP =====
 +----
 +
 +==== Create a New PHP-FPM Pool for Our User ====
 +
 +(the following commands are to be executed as **root**, or using **sudo**)
 +
 +<​code>​
 +> nano /​etc/​php5/​fpm/​pool.d/<​ininja>​.conf
 +
 +PASTE:
 +[<​ininja>​]
 +user = <​ininja>​
 +group = <​ininja>​
 +listen = /​var/​run/​php5-fpm-ininja.sock
 +listen.owner = <​ininja>​
 +listen.group = <​ininja>​
 +listen.mode = 0666  ​
 +pm = ondemand
 +pm.max_children = 5
 +pm.process_idle_timeout = 10s;
 +pm.max_requests = 200
 +chdir = /
 +
 +> service php5-fpm restart
 +</​code>​
 +
 +Once again do not forget to substitute ''​%%<​ininja>​%%''​ with the user name you created earlier.
 +
 +----
 +==== Generate a Self Signed SSL Certificate ====
 +
 +<​code>​
 +> mkdir -p /​etc/​nginx/​ssl
 +> cd /​etc/​nginx/​ssl
 +> openssl genrsa -des3 -passout pass:x -out ininja.pass.key 2048
 +> openssl rsa -passin pass:x -in ininja.pass.key -out ininja.key
 +> rm ininja.pass.key
 +> openssl req -new -key ininja.key -out ininja.csr
 +> openssl x509 -req -days 365 -in ininja.csr -signkey ininja.key -out ininja.crt
 +</​code>​
 +
 +----
 +==== Create a New Nginx Server Block ====
 +
 +<​code>​
 +> nano /​etc/​nginx/​sites-available/​ininja
 +
 +PASTE:
 +server {
 +    listen ​     443 default;
 +    server_name ininja;
 +
 +    ssl on;
 +    ssl_certificate ​    /​etc/​nginx/​ssl/​ininja.crt;​
 +    ssl_certificate_key /​etc/​nginx/​ssl/​ininja.key;​
 +    ssl_session_timeout 5m;
 +
 +    ssl_ciphers ​              '​AES128+EECDH:​AES128+EDH:​!aNULL';​
 +    ssl_protocols ​             TLSv1 TLSv1.1 TLSv1.2;
 +    ssl_prefer_server_ciphers on;
 +
 +    root /​var/​www/​ininja/​public;​
 +
 +    index index.html index.htm index.php;
 +
 +    charset utf-8;
 +
 +    location / {
 +        try_files $uri $uri/ /​index.php?​$query_string;​
 +    }
 +
 +    location = /​favicon.ico { access_log off; log_not_found off; }
 +    location = /​robots.txt ​ { access_log off; log_not_found off; }
 +
 +    access_log ​ /​var/​log/​nginx/​ininja.access.log;​
 +    error_log ​  /​var/​log/​nginx/​ininja.error.log;​
 +
 +    sendfile off;
 +
 +    location ~ \.php$ {
 +        fastcgi_split_path_info ^(.+\.php)(/​.+)$;​
 +        fastcgi_pass unix:/​var/​run/​php5-fpm-ininja.sock;​
 +        fastcgi_index index.php;
 +        include fastcgi_params;​
 +        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;​
 +        fastcgi_intercept_errors off;
 +        fastcgi_buffer_size 16k;
 +        fastcgi_buffers 4 16k;
 +    }
 +
 +    location ~ /\.ht {
 +        deny all;
 +    }
 +}
 +
 +server {
 +    listen ​     80;
 +    server_name 172.20.20.10;​
 +
 +    add_header Strict-Transport-Security max-age=2592000;​
 +    rewrite ^ https://​$server_name$request_uri?​ permanent;
 +}
 +</​code>​
 +
 +You'll need to adapt the "​ininja"​ values to your configuration... Also we've used the IP as server name as we're using a VM, you'd need to put the FQDN of your server in case your are deploying on a production machine.
 +
 +=== Activate the server block ===
 +
 +This is done by creating a symbolic link from /​etc/​nginx/​sites-available/​ to /​etc/​nginx/​sites-enabled/,​ then restarting nginx:
 +<​code>​
 +> ln -s /​etc/​nginx/​sites-available/<​ininja>​ /​etc/​nginx/​sites-enabled/<​ininja>​
 +> service nginx restart
 +</​code>​
 +
 +----
 +===== Start Using Invoice Ninja =====
 +----
 +
 +Directing a web browser to your VM's IP should now display the **Invoice Ninja Setup** page, enjoy !
 +
 +----
 +==== Backup the Database ====
 +
 +For development purposes it might sometimes be usefull to make a backup of the database at a certain state. To do that, use the ''​%%mysqldump%%''​ command:
 +
 +**backup**:
 +<​code>​
 +> mysqldump -uininja -p ininja > /​path/​to/​ininja-state.sql
 +Enter password:
 +</​code>​
 +
 +**restore**:​
 +<​code>​
 +> mysql -uininja -p ininja < /​path/​to/​ininja-state.sql
 +Enter password:
 </​code>​ </​code>​