How to Install Etcher, the open-source USB writer tool, on Ubuntu

How to Install Etcher, the open-source USB writer tool, on Ubuntu

http://ift.tt/2pJB28R

etcher image writer on ubuntu

Etcher, a popular open-source USB image writer tool for Windows, macOS and Linux, has just issued a new stable release.

Version 1.0 arrives almost one year to the day since we first introduced you to the easy-to-use image writer tool on this site. The stable release sees the app pick up a boat load of improvements that, its developers say, help make it “a much more stable and reliable tool”.

A Recap of Etcher Features

etcher usb selection

The company steering development of the app say over the course of the various beta releases Etcher was used to write over one million images to SD cards & USB drives.

Built using the Electron format, Etcher is a true cross-platform app that can write .iso, .img and .zip files to USB drives and SD cards.

The main interface is dead simple to use: you select an image, select a drive (the built in drive picker is designed to avoid you making mistakes and overwriting a hard drive, etc) and hit Flash. Validated burning double-checks images after writing so that you’re left faffing about trying to boot from a dud drive.

No sign of some previously planned features, like support for creating multi-boot USB sticks, or enabling persistent storage on Ubuntu images.

  • Support for creating multi-boot USBs
  • Support for persistent storage on Ubuntu images
  • Registered Etcher as handler for *.img and *.iso files

It’s not just the GUI client that’s gotten an update though. Etcher 1.0 also sees the first experimental release of the Etcher CLI.

The Etcher CLI lets you to write images and validate flashes from the command line. As it doesn’t rely on the Electron framework, it’s a smaller download and install size. Its developers also tout the ability for users to write custom scripts using the CLI to “perform tasks such as multi-writes.”

How to install Etcher on Ubuntu

Etcher 1.0 is available to download for Windows, macOS and Linux from the Etcher.io website or from its Github page:

Etcher on Github

Linux builds are provided in the AppImage package format. App Images are self-contained runtimes that do not require manual installation or root (but does require you to give it the necessary permissions to run as a programme). They will run on pretty much every distro out there — just download, and double-click to run:

etcher appimage

If you prefer to install your apps in a more traditional way, using apt, you can install Etcher on Ubuntu from the Etcher repository.

Now, getting this set up is a little bit more involved that with a regular PPA, but this methods the benefit of ensuring you get all future Etcher updates automatically through your update manager.

To add the Etcher repo open the Software & Updates app using the Unity Dash (or an alternative app launcher):

Select the ‘Other Software’ tab in Software & Updates [1]

adding repo software sources on ubuntu

Click ‘Add’ [2] and paste the following the entry field of the box that appears:

deb http://ift.tt/2qE7Sgv stable etcher

Click ‘Add Source’ [3] to confirm the change, then close Software & Updates. You’ll likely be prompted to update your software sources.

The next step is to add the repository key. This allows Ubuntu to verify that packages installed from the repository are made by who they say they are. You have to add this key to be able to install Etcher; Ubuntu will disable unsigned repos.

Open a new Terminal window, paste the following command, and then hit return/enter:

sudo apt-key adv --keyserver hkp://pgp.mit.edu:80 --recv-keys 379CE192D401AB61

Finally, update your packages list and install the app:

sudo apt update && sudo apt install etcher-electron

That’s it; launch Etcher from the Unity Dash (or an alternative app launcher) and follow the on-screen instructions.

Linux

Linux

via OMG! Ubuntu! http://ift.tt/eCozVa

May 13, 2017 at 02:16PM

4 terminal applications with great command-line UIs

4 terminal applications with great command-line UIs

http://ift.tt/2pWXiOl

In this article, I’ll look at a shortcoming of command-line interfaces—discoverability—and a few ways to overcome this problem.

I love command lines. My first command line was DOS 6.2, back in 1997. I learned the syntax for various commands and showed off how to list hidden files in a directory (attrib). I would carefully craft my commands one character at a time. When I made a mistake, I would proceed to retype the command from the beginning. One fine day someone showed me how to traverse the history using the up and down arrow keys and I was blown away.

Programming and development

Later when I was introduced to Linux, I was pleasantly surprised that up and down arrows retained their ability to traverse the history. I was still typing each character meticulously, but by now I knew how to touch type and I was doing exceedingly well with my 55 words per minute. Then someone showed me tab-completion and changed my life once again.

In GUI applications menus, tool tips and icons are used to advertise a feature for the user. Command lines lack that ability, but there are ways to overcome this problem. Before diving into solutions, I’ll look at a couple of problematic CLI apps:

1. MySQL

First we have our beloved MySQL REPL. I often find myself typing SELECT * FROM and then press Tab out of habit. MySQL asks whether I’d like to see all 871 possibilities. I most definitely don’t have 871 tables in my database. If I said yes, it shows a bunch of SQL keywords, tables, functions, and so on.

MySQL gif

2. Python

Let’s look at another example, the standard Python REPL. I start typing a command and press the Tab key out of habit. Lo and behold a Tab character is inserted, which is a problem considering that a Tab character has no business in a Python source code.

Python gif

Good UX

Now let’s look at well-designed CLI programs and how they overcome some discoverability problems.

Auto-completion: bpython

Bpython is a fancy replacement for the Python REPL. When I launch bpython and start typing, suggestions appear right away. I haven’t triggered them via a special key combo, not even the famed Tab key.

bpython gif

When I press the Tab key out of habit, it completes the first suggestion from the list. This is a great example of bringing discoverability to CLI design.

The next aspect of bpython is the way it surfaces documentation for modules and functions. When I type in the name of a function, it presents the function signature and the doc string attached with the function. What an incredibly thoughtful design.

Context-aware completion: mycli

Mycli is a modern alternative to the default MySQL client. This tool does to MySQL what bpython does to the standard Python REPL. Mycli will auto-complete keywords, table names, columns, and functions as you type them.

The completion suggestions are context-sensitive. For example, after the SELECT * FROM, only tables from the current database are listed in the completion, rather than every possible keyword under the sun.

mycli gif

Fuzzy search and online Help: pgcli

If you’re looking for a PostgreSQL version of mycli, check out pgcli. As with mycli, context-aware auto-completion is presented. The items in the menu are narrowed down using fuzzy search. Fuzzy search allows users to type sub-strings from different parts of the whole string to try and find the right match.

pgcli gif

Both pgcli and mycli implement this feature in their CLI. Documentation for slash commands are presented as part of the completion menu.

Discoverability: fish

In traditional Unix shells (Bash, zsh, etc.), there is a way to search your history. This search mode is triggered by Ctrl-R. This is an incredibly useful tool for recalling a command you ran last week that starts with, for example, ssh or docker. Once you know this feature, you’ll find yourself using it often.

If this feature is so useful, why not do this search all the time? That’s exactly what the fish shell does. As soon as you start typing a command, fish will start suggesting commands from history that are similar to the one you’re typing. You can then press the right arrow key to accept that suggestion.

Command-line etiquette

I’ve reviewed innovative ways to solve the discoverability problems, but there are command-line basics everyone should implement as part of the basic REPL functionality:

  • Make sure the REPL has a history that can be recalled via the arrow keys. Make sure the history persists between sessions.
  • Provide a way to edit the command in an editor. No matter how awesome your completions are, sometimes users just need an editor to craft that perfect command to drop all the tables in production.
  • Use a pager to pipe the output. Don’t make the user scroll through their terminal. Oh, and use sane defaults for your pager. (Add the option to handle color codes.)
  • Provide a way to search the history either via the Ctrl-R interface or the fish-style auto-search.

Conclusion

In part 2, I’ll look at specific libraries in Python that allow you to implement these techniques. In the meantime, check out some of these well-designed command-line applications:

  • bpython or ptpython: Fancy REPL for Python with auto-completion support.
  • http-prompt: An interactive HTTP client.
  • mycli: A command-line interface for MySQL, MariaDB, and Percona with auto-completion and syntax highlighting.
  • pgcli: An alternative to psql with auto-completion and syntax-highlighting.
  • wharfee: A shell for managing Docker containers.

Learn more in Amjith Ramanujam’s  PyCon US 2017 talk, Awesome Commandline Tools, May 20th in Portland, Oregon.

Python,Linux

via Opensource.com

May 9, 2017 at 06:33PM

4 terminal applications with great command-line UIs

4 terminal applications with great command-line UIs

http://ift.tt/2pWXiOl

4 awesome command-line tools

In this article, I’ll look at a shortcoming of command-line interfaces—discoverability—and a few ways to overcome this problem.

I love command lines. My first command line was DOS 6.2, back in 1997. I learned the syntax for various commands and showed off how to list hidden files in a directory (attrib). I would carefully craft my commands one character at a time. When I made a mistake, I would proceed to retype the command from the beginning. One fine day someone showed me how to traverse the history using the up and down arrow keys and I was blown away.

read more

Linux,Gray Matters,Python

Linux

via Opensource.com http://ift.tt/1EBSQUh

May 8, 2017 at 03:33AM

10 More Quick Tips to Make Linux Networking Easier

10 More Quick Tips to Make Linux Networking Easier

http://ift.tt/2pYfpn5

If you either work on a Linux desktop, or administer a Linux server, there might be times when frustration sets in over networking issues. Although Linux has made significant advances over the years, there are still instances where the standard troubleshooting or optimizations won’t work. To that end, you need to have some tricks and tips up your sleeve to make your life easier.

Linux

Linux

via http://ift.tt/1Wf4iBh

May 8, 2017 at 10:18AM

How to run command or code in parallel in bash shell under Linux or Unix

How to run command or code in parallel in bash shell under Linux or Unix

http://ift.tt/2q8BulH

H

ow do I run commands in parallel in a bash shell script running under Linux or Unix-like operating system? How can I run multiple programs in parallel from a bash script?

You have various options to run programs or commands in parallel:

=> Use GNU/parallel or xargs command.

=> Use wait built-in command with &.

=> Use xargs command.

How to run multiple programs in parallel from a bash script in linux / unix?

Putting jobs in background

The syntax is:
command &
command arg1 arg2 &
custom_function &

OR
prog1 &
prog2 &
wait
prog3

In above code sample, prog1, and prog2 would be started in the background, and the shell would wait until those are completed before starting the next program named progr3.

Examples

In this following example run sleep command in the background:
$ sleep 60 &
$ sleep 90 &
$ sleep 120 &

To displays status of jobs in the current shell session run jobs command as follows:
$ jobs
Sample outputs:

[1]   Running                 sleep 60 &
[2]-  Running                 sleep 90 &
[3]+  Running                 sleep 120 &

Let us write a simple bash shell script:

#!/bin/bash
# Our custom function
cust_func(){
  echo "Do something $1 times..."
  sleep 1
}
# For loop 5 times
for i in {1..5}
do
	cust_func $i & # Put a function in the background
done
 
## Put all cust_func in the background and bash 
## would wait until those are completed 
## before displaying all done message
wait 
echo "All done"

#!/bin/bash
# Our custom function
cust_func(){
echo “Do something $1 times…”
sleep 1
}
# For loop 5 times
for i in {1..5}
do
cust_func $i & # Put a function in the background
done## Put all cust_func in the background and bash
## would wait until those are completed
## before displaying all done message
wait
echo “All done”

Let us say you have a text file as follows:
$ cat list.txt
Sample outputs:

http://ift.tt/2piFZq2
http://ift.tt/2pKEy69
http://ift.tt/2pj1KWo
http://ift.tt/2pKCco9
http://ift.tt/2piQTMf
http://ift.tt/2pKvOgu
http://ift.tt/2piKKjd
http://ift.tt/2pKAL96
http://ift.tt/2piLzIT
http://ift.tt/2pKlQfe
http://ift.tt/2piXVAI
http://ift.tt/2pKvtKT

To download all files in parallel using wget:

#!/bin/bash
# Our custom function
cust_func(){
  wget -q "$1"
}
 
while IFS= read -r url
do
        cust_func "$url" &
done < list.txt
 
wait
echo "All files are downloaded."

#!/bin/bash
# Our custom function
cust_func(){
wget -q “$1”
}while IFS= read -r url
do
cust_func “$url” &
done < list.txtwait
echo “All files are downloaded.”

GNU parallel examples

From the GNU project site:

GNU parallel is a shell tool for executing jobs in parallel using one or more computers. A job can be a single command or a small script that has to be run for each of the lines in the input. The typical input is a list of files, a list of hosts, a list of users, a list of URLs, or a list of tables.

The syntax is pretty simple:
parallel ::: prog1 prog2
For example, you can find all *.doc files and gzip (compress) it using the following syntax:
$ find . -type f -name '*.doc' | parallel gzip --best
$ find . -type f -name '*.doc.gz'

Our above wget example can be simplified using GNU parallel as follows:
$ cat list.txt | parallel -j 4 wget -q {}
OR
$ parallel -j 4 wget -q {} < list.txt

See also

Linux

Linux

via [RSS/Feed] nixCraft: Linux Tips, Hacks, Tutorials, And Ideas In Blog Format http://ift.tt/Awfi7s

May 5, 2017 at 06:02PM

When you delete a line of code that you thought was useless…

When you delete a line of code that you thought was useless…

http://ift.tt/2qGPeEj

Or when you run rm -rf / on Linux or Unix-like system 😉

rm-rf

rm-rf

Another gif showing the same issue:

Delete a block of code

Delete a block of code

Now, I am hitting u, u, u in vim to undo (ctrl-z in other IDE) like a maniac to get back that line or a code block. Lmao.

Linux

Linux

via [RSS/Feed] nixCraft: Linux Tips, Hacks, Tutorials, And Ideas In Blog Format http://ift.tt/Awfi7s

May 7, 2017 at 05:05PM

Graph Any Data with Cacti!

Graph Any Data with Cacti!

http://ift.tt/2qbLG9N

For the past few years, I’ve been trying to understand how to make graphs usingRRDtool (Round-Robin Database tool) after failing miserably to understand MRTG(Multi-Router Traffic Grapher) before that. The thing I like about RRDtoolis that it’s newer and supports a wider variety of data sources.

Linux

Linux

via LXer Linux News http://lxer.com/

April 27, 2017 at 04:43PM

How to install GoAccess web log analyzer with Nginx on Linux or Unix

How to install GoAccess web log analyzer with Nginx on Linux or Unix

http://ift.tt/2pLDvUM

G

oAccess is a real-time Apache/Nginx/Lighttpd web log analyzer and interactive viewer that runs in a terminal and provides fast and valuable HTTP statistics for system administrators that require a visual report on the fly. How do I install GoAccess on Ubuntu Linux server? How can I instal and use GoAccess on Linux or Unix-like system?

GoAccess is a free and open source real-time web log analyzer and interactive viewer that runs in a terminal in Linux/Unix/*BSD systems or through your browser. T

his tutorial shows how to install the GoAccess on Linux/Unix and how to use it on the *nix command line

.

Install GoAccess

You must install GoAccess as per your Linux or Unix distro.

Install GoAccess on Ubuntu Linux

Type the following apt-get command/apt command as follows:
$ sudo apt-get install goaccess
Sample outputs:

Fig.01: How to install GoAccess on Ubuntu Linux server
Fig.01: How to install GoAccess on Ubuntu Linux server

Install GoAccess on Debian Linux

Type the following apt-get command/apt command as follows:
$ sudo apt-get install goaccess

Install GoAccess on Debian Linux

Type the following apt-get command/apt command as follows:
$ sudo apt-get install goaccess

Install GoAccess on Alpine Linux

Type the following apk command as follows:
# apk add goaccess

Install GoAccess on CentOS Linux

First turn on the EPEL repo and type the following yum command as follows:
$ sudo yum install epel-release
$ sudo yum install goaccess

Install GoAccess on Fedora Linux

First turn on the EPEL repo and type the following dnf command as follows:
$ sudo dnf install epel-release
$ sudo dnf install goaccess

Install GoAccess on Arch Linux

Type the following pacman command as follows:
# pacman -S goaccess

Install GoAccess on FreeBSD UNIX

To install the port:
# cd /usr/ports/sysutils/goaccess/ && make install clean
OR To add the package:
# pkg install goaccess

Install GoAccess on macOS UNIX (Homebrew)

Type the following brew command:
$ brew install goaccess

Install GoAccess on OpenBSD UNIX

Type the following pkg_add command:
$ doas pkg_add goaccess

Installing GoAccess using source code method

Type the following command to download and compile GoAccess on Unix-like system:
$ cd /tmp
$ wget http://ift.tt/2oMTfXs
$ tar -zxvf goaccess-1.2.tar.gz
$ cd goaccess-1.2/
$ ./configure --enable-utf8 --enable-geoip=legacy && make
$ sudo make install

How do I use GoAccess?

The syntax is:
goaccess -f /path/to/nginx/access.log
goaccess -f /path/to/apache/access.log
goaccess -f /path/to/lighttpd/access.log
goaccess -f /path/to/lighttpd/access.log /path/to/lighttpd/access.log.1
zcat /path/to/nginx/access.log.*.gz | goaccess access.log -
goaccess [options] /path/to/lighttpd/access.log

Examples

Let us see some examples.

How can I see output on screen with a live report?

goaccess -f /var/log/nginx/access.log
You will be promoted to select “Log Format Configuration”:

Fig.02: Set the log-format for your log file
Fig.02: Set the log-format for your log file

Next you will see a report as follows:

Fig.03:  See an interactive report on screen
Fig.03: See an interactive report on screen

Important shortcut keys

You can use the following keys:

  • q – Quit the program.
  • h or ? – See help.
  • 0-9 and Shift + 0 – Set selected module to active.
  • j – Scroll down within expanded module.
  • k – Scroll up within expanded module.
  • c – Set or change scheme color.
  • ^f – Scroll forward one screen within active module.
  • ^b – Scroll backward one screen within active module.
  • TAB – Iterate modules (forward).
  • SHIFT + TAB – Iterate modules (backward).
  • s – Sort options for active module.
  • /Search – across all modules (regex allowed).
  • n – Find position of the next occurrence.
  • g – Move to the first item or top of screen.
  • G – move to the last item or bottom of screen.

How do I generate an HTML report?

The syntax is:
goaccess -f /var/log/nginx/access.log --log-format=COMBINED -o http://ift.tt/2oYHv05
Sample outputs:

Parsing... [669] [1112]

You can view report with your web-browser. Here is a sample report:
http://ift.tt/2oYOw13

How do I use goaccess over an ssh based session?

The syntax is:
$ ssh [email protected] 'cat /var/log/nginx/access.log'|goaccess --log-format=COMBINED -a -
$ ssh [email protected] 'cat /var/log/nginx/access.log'|goaccess --log-format=COMBINED -
$ ssh [email protected] 'cat /var/log/nginx/access.log'|goaccess --log-format=COMBINED -o http://ift.tt/2oYNodZ -

How do I view real time stats in browser?

Run it as follows:
$ goaccess -f access.log -o report.html --real-time-html --addr=192.168.1.254 --port=8022
See man page or project page for more info.

Linux

Linux

via [RSS/Feed] nixCraft: Linux Tips, Hacks, Tutorials, And Ideas In Blog Format http://ift.tt/Awfi7s

April 30, 2017 at 12:49PM

How to Install Invoice Ninja on Ubuntu 16.04

How to Install Invoice Ninja on Ubuntu 16.04

http://ift.tt/2oTY4um

How to Install Invoice Ninja on Ubuntu 16.04

Invoice Ninja is a web-based open source software for invoicing, payments, time tracking and much more. You can create Invoices online in seconds, interact with payments gateways like Stripe, PayPal, WePay, and others. Invoice Ninja can show you a live invoice preview in PDF format. You can change the company logo in templates easily yourself. Invoice Ninja is based on PHP, build with the Laravel Framework and can be installed on Linux and Windows.

In this tutorial, I will show you how to install Invoice Ninja on Ubuntu 16.04. I will use Nginx as the web server and MariaDB as Database system.

Prerequisite

  • Ubuntu 16.04 server.
  • Root privileges.

Step 1 – Install Nginx

In this step, we will install the Nginx web server. Connect to your server with your ssh root account (or login with another user and use ‘sudo -s’ to become root) and update the repository.

ssh [email protected]
apt-get update

Install Nginx with the apt command below:

apt-get install -y nginx

When the nginx installation is finished, start Nginx and add it to start at boot time.

systemctl start nginx
systemctl enable nginx

Make sure nginx is running. Check the port used by nginx, the default web server port is 80.

netstat -plntu

Nginx installed on Ubuntu 16.04

Step 2 – Install and Configure MariaDB Server

After installing Nginx, we need to install the package mariadb-server on the system. It’s available in the Ubuntu repository. Install mariadb-server and its dependencies with the command below.

apt-get install -y mariadb-server

When the installation is done, start the mariadb service and enable it to start at boot time with these systemctl commands.

systemctl restart mysql
systemctl enable mysql

MariaDB is started, now you can set the root password for mariadb with the command below.

mysql_secure_installation

Set your new MariaDB root password.

Set root password? [Y/n] Y
New password:
Re-enter new password:

Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Next, try to connect with the mysql shell as root user.

mysql -u root -p
TYPE YOUR ROOT PASSWORD

You will see MySQL shell when everything worked correctly.

Now we need to create a new database and a new user for Invoice Ninja. I will create a new database named ‘ninjadb‘, a new user ‘ninja‘ with password ‘aqwe123‘. Please choose a different and secure password for your installation!

Create them with the mysql query below. Create a new database, create new user and password, grant database to the new user with a password.

create database ninjadb;
create user [email protected] identified by ‘aqwe123’;
grant all privileges on ninjadb.* to [email protected] identified by ‘aqwe123’;
flush privileges;

Install and Configure MariaDB for Invoice Ninja

MariaDB has been installed and a new database and user for Invoice Ninja were created.

Step 3 – Install and Configure PHP7.0-FPM

Invoice Ninja is based on PHP, so we need to install PHP to the system. We will use PHP7.0-FPM for this Invoice Ninja installation.

Install PHP7.0-FPM and other PHP extensions needed by Invoice Ninja with the command below.

apt-get install -y php7.0-fpm php7.0-gd php7.0-xml php7.0-mysql php7.0-zip php7.0-mbstring php7.0-mcrypt php7.0-curl php7.0-gmp

After the installation, go to the PHP configuration directory and edit the php.ini file.

cd /etc/php/7.0/
vim fpm/php.ini

Uncomment the CGI line below and change the value to 0.

cgi.fix_pathinfo=0

Save and exit.

Edit php.ini file in the cli directory.

vim cli/php.ini

Uncomment the CGI line below and change the value to 0.

cgi.fix_pathinfo=0

Save and exit.

Next, start PHP7.0-FPM and enable it to start at boot time.

systemctl restart php7.0-fpm
systemctl enable php7.0-fpm

By default, PHP7.0-FPM is running with a socket file, check it with the command below and you will see the PHP socket file as shown in the screenshot.

netstat -pl

Configure PHP7.0-FPM on Ubuntu 16.04

PHP7.0-FPM and all extensions needed by Invoice Ninja are installed.

Step 4 – Install and Configure Invoice Ninja

In this step, we will download and configure Invoice Ninja. First, install unzip on your system.

apt-get install -y unzip

Go to the ‘/var/www’ directory and download the Invoice Ninja source code with the wget command.

cd /var/www/
wget http://ift.tt/2p2Pzzr

Extract the Invoice Ninja zip file and go to the ‘ninja’ directory.

unzip ninja-v3.1.0.zip
cd ninja/

For the Laravel project, we need to install the composer dependency manager for PHP. It’s available in the Ubuntu repository, so we can install it with the apt command.

apt-get install -y composer

Next, install Invoice Ninja dependencies with the composer command below.

composer install –no-dev -o

  • –no-dev : Disables installation of require-dev packages
  • -o : Optimize autoloader during autoloader dump

When the dependency installation is done, copy the .env file and edit with vim.

cp .env.example .env
vim .env

Change the value of database settings below.

DB_DATABASE=ninjadb
DB_USERNAME=ninja
DB_PASSWORD=aqwe123

Save and exit.

environment setup for Invoice Ninja

Next, edit the database configuration in the config directory.

vim config/database.php

We are using MariaDB/MySQL database, go to the MySQL line 55.

‘database’  => env(‘DB_DATABASE’, ‘ninjadb’),
‘username’  => env(‘DB_USERNAME’, ‘ninja’),
‘password’  => env(‘DB_PASSWORD’, ‘aqwe123’),

Replace the password with the one that you have set for the ninja user!

Save and exit.

Invoice Ninja Database Configuration

All configuration files are edited. Next, migrate the database with the command below.

php artisan migrate

You will be asked to run the command, type ‘yes‘ and press Enter.

Invoice Ninja Migrate Database

Next, seed the database with all records.

php artisan db:seed

Type ‘yes‘ and press Enter to confirm.

Invoice Ninja Seed Tables

Generate a new application key for the Laravel project Invoice Ninja.

php artisan key:generate

You will see the application key.

Edit the app.php file with vim.

vim config/app.php

Go to the APP_KEY line 85 and paste the key we generated.

‘key’ => env(‘APP_KEY’, ‘base64:0o5QLWbNeDCNer064+600Hl8oJ20OPCIymadKJQ1RGo=’),

Save and exit.

Finally, change the owner of ‘/var/www/ninja‘ directory to ‘www-data‘ user and group.

cd /var/www/
chown -R www-data:www-data ninja/

Invoice Ninja is configured and ready for the installation.

Step 5 – Configure SSL and Virtual Host

In this step, we will generate an SSL Certificate file with the OpenSSL command and create new virtual host configuration for Invoice Ninja. If you are on a live server, you can use a free SSL from Let’s Encrypt instead of generating a self-signed SSL cert with OpenSSL.

Create a new ‘cert‘ directory for the SSL files.

mkdir -p /etc/nginx/cert/

Run the openssl command below to generate the certificate files.

openssl req -new -x509 -days 365 -nodes -out /etc/nginx/cert/ninja.crt -keyout /etc/nginx/cert/ninja.key

Change the permission of the certificate files to ‘600’.

chmod 600 /etc/nginx/cert/*

Generate SSL Certificate for Invoice Ninja

Next, go to the Nginx directory and create a new virtual host configuration file named ‘ninja‘.

cd /etc/nginx/
vim sites-available/ninja

Paste virtual host configuration below.

server {
    # Your Domain Name - hakase-labs.co
    listen      80;
    server_name ninja.co www.ninja.co;

    # Rewrite redirect to https
    add_header Strict-Transport-Security max-age=2592000;
    rewrite ^ https://$server_name$request_uri? permanent;
}

server {
    # Your Domain Name - hakase-labs.co
    listen      443 default;
    server_name ninja.co www.ninja.co;

    # Enable SSL for Invoice Ninja
    ssl on;
    ssl_certificate     /etc/nginx/cert/ninja.crt;
    ssl_certificate_key /etc/nginx/cert/ninja.key;
    ssl_session_timeout 5m;

    ssl_ciphers               'AES128+EECDH:AES128+EDH:!aNULL';
    ssl_protocols              TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;

    # Invoice Ninja web root files
    root /var/www/ninja/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 and Error Log for Invoice Ninja
    access_log  /var/log/nginx/ininja.access.log;
    error_log   /var/log/nginx/ininja.error.log;

    sendfile off;

    # Handle PHP Applications
    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/run/php/php7.0-fpm.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;
    }
}

Save and exit.

Enable the ninja virtual host and test the Nginx configuration, make sure there is no error.

ln -s /etc/nginx/sites-available/ninja /etc/nginx/sites-enabled/
nginx -t

Now restart the nginx web server.

systemctl restart nginx

Invoice Ninja Virtual Host Installed

The Invoice Ninja virtual host configuration is finished.

Step 6 – Finishing the Installation and Testing

Open your web browser and type in the Invoice Ninja URL: ninja.co. You will be redirected to the https connection and setup page.

Invoice Ninja Installation

Type in the Application Settings, Database Connection, Email Settings, User Details and check the Invoice Ninja TOS.

Invoice Ninja Installation Configuration setup

Click ‘Submit‘ and you will be redirected to the login page of Invoice Ninja.

Type in your email and password, then press ‘LOGIN‘.

You will see the Invoice Ninja Dashboard.

Invoice Ninja Admin Dashboard

Invoice Ninja Settings Page.

Invoice Ninja Setting Page

Invoice Ninja Installed with Nginx and MariaDB on Ubuntu 16.04.

Reference

Linux

Linux

via LXer Linux News http://lxer.com/

April 28, 2017 at 04:17PM