How to Install PrestaShop on Debian 9 • LinuxCloudVPS Blog

How to Install PrestaShop on Debian 9

In this article, we will show you how to install PrestaShop on a Debian 9 VPS. Prestashop is an easy to use open source shopping cart application written in PHP used by website developers to build and run a successful online store. To install PrestaShop on a Debian 9 VPS follow the very easy steps described below.

Requirements

At the time of writing this tutorial, the latest stable version of PrestaShop is v1.7.4.2 and it requires:

  • Nginx or Apache Web Server
  • MySQL 5.5 or later is recommended, or MariaDB installed on your Linux virtual server.
  • PHP 5.4 or higher with the following PHP extensions enabled: mcrypt, cURL, GD, GZIP and PDO.
  • Full SSH root access or a user with sudo privileges is also required

Step 1: Log in via SSH on the Ubuntu server:

Log in to the VPS via SSH as user root

ssh roo@IP_Address -p Port_number

Step 2: Update all OS packages

Once you are logged, run the following command to make sure that all installed OS packages are up to date:

apt-get update
apt-get upgrade

Step 3: Install Nginx, MariaDB and PHP 7

Stop and disable Apache service:

systemctl stop apache2
systemctl disable apache2

Install Nginx from Debian package repository. Simply, run the following command to install Nginx on your server:

apt-get install nginx

After the installation is complete, Nginx will automatically start.
To verify that Nginx is running on the server, you can use the following command:

systemctl status nginx

Make sure that Nginx server is configured to automatically start upon a server boot:

systemctl enable nginx

Install MariaDB and PHP 7 on your server using the following commands:

apt-get install mysql-server
apt-get install php7.0 php7.0-cli php7.0-common php7.0-fpm php7.0-curl php7.0-zip php7.0-gd php7.0-mysql php7.0-xml php7.0-mcrypt php7.0-mbstring

Enable MariaDB and php-fpm to automatically start upon a server boot:

systemctl enable mariadb.service
systemctl enable php7.0-fpm.service

Step 4: Install PrestaShop

Download the latest stable version of PrestaShop in the /opt directory on your server and extract it in the /var/www/html/ directory:

cd /opt
wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip
unzip prestashop_1.7.4.2.zip
unzip prestashop.zip -d /var/www/html/prestashop/

Step 5: Modify the PHP configuration

Edit the ‘/etc/php/7.0/fpm/php.ini’ PHP configuration file.
Modify the memory_limit value to 128MB or higher:

memory_limit = 256M

Also, set upload_max_filesize to 32 MB (or more):

upload_max_filesize = 32M

Also, modify the following settings:

file_uploads = On
allow_url_fopen = On

Restart the php-fpm service for the changes to take effect:

systemctl restart php7.0-fpm.service

Step 6: Set file permissions

The web server user (www-data) needs to be able to write to files and directories inside the ‘/var/www/html/prestashop’ directory, so it can easily be accomplished by executing the following command:

chown www-data:www-data -R /var/www/html/prestashop/

Step 7: Configure Nginx to serve PrestaShop

Create a new Nginx server block:

vi /etc/nginx/sites-available/your-domain.com

and add the following content:

server {
server_name your-domain.com;
listen 80;
root /var/www/html/prestashop/;
access_log /var/log/nginx/your-domain.com_access.log;
error_log /var/log/nginx/your-domain.com_error.log;

index index.php;

rewrite ^/api/?(.*)$ /webservice/dispatcher.php?url=$1 last;
rewrite ^/([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$1$2.jpg last;
rewrite ^/([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$1$2$3.jpg last;
rewrite ^/([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$1$2$3$4.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$1$2$3$4$5.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$1$2$3$4$5$6.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$1$2$3$4$5$6$7.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$1$2$3$4$5$6$7$8.jpg last;
rewrite ^/([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])([0-9])(-[_a-zA-Z0-9-]*)?/[_a-zA-Z0-9-]*.jpg$ /img/p/$1/$2/$3/$4/$5/$6/$7/$8/$1$2$3$4$5$6$7$8$9.jpg last;
rewrite ^/c/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$ /img/c/$1$2.jpg last;
rewrite ^/c/([a-zA-Z-]+)/[a-zA-Z0-9-]+.jpg$ /img/c/$1.jpg last;
rewrite ^/([0-9]+)(-[_a-zA-Z0-9-]*)/[_a-zA-Z0-9-]*.jpg$ /img/c/$1$2.jpg last;
try_files $uri $uri/ /index.php?$args;

location ~* .(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires max;
}

location ~ .php {
fastcgi_index index.php;
fastcgi_split_path_info ^(.+.php)(.*)$;
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/php7-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}

Create a symbolic link:

ln -s /etc/nginx/sites-available/your-domain.com /etc/nginx/sites-enabled/your-domain.com

Restart the Nginx service for the changes to take effect:

systemctl restart nginx

Step 8: Create a MariaDB database for PrestaShop

Login to the MariaDB console with the root account:

mysql -u root -p

Create a MariaDB database, user and grant permissions to the user using the following command:

MariaDB [(none)]> CREATE DATABASE prestashop;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON prestashop.* TO ‘prestashop’@’localhost’ IDENTIFIED BY ‘Str0ngPa55w0rd’;
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> q

Do not forget to replace ‘Str0ngPa55w0rd’ with an actual strong password.

Open your favorite web browser and type in the following URL to access the PrestaShop web interface and start the setup:

http://your-domain.com/

From here you can finish the setup by selecting the installation language and entering the information about your PrestaShop store. Then, create an administrator account and enter the following information to configure the database:

Database server address: 127.0.0.1

Database name: prestashop

Database login: prestashop

Database password: enter the MariaDB password for the PrestaShop MariaDB user.

For security reason, you must delete the ‘install’ directory:

rm -rf /var/www/html/prestashop/install/

Once you deleted the installation directory, login to the PrestaShop back-end by clicking on the ‘Manage your store’ button.

installing prestashop on debian 9

 

Congratulations! PrestaShop has been successfully installed on your server. You can now start using PrestaShop and customize it according to your needs.

Of course, you don’t have to Install PrestaShop on a Debian 9 VPS if you use our Managed PrestaShop Hosting services, in which case you can simply ask our expert Linux admins to install PrestaShop on Debian 9, for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post, on how to Install PrestaShop on Debian 9, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Source

How to Install Prestashop on CentOS 7 • LinuxCloudVPS Blog

28th September 2018 /
Category: Tips and Tricks /
Comments: None

How to Install Prestashop on CentOS 7

PrestaShop is one of the most popular open source e-commerce self-hosted platforms. PrestaShop is completely free and open source, used by thousands of online stores around the world. In this article, we will explain the process of installing the latest version of PrestaShop on a CentOS 7 VPS with Apache, MariaDB, and PHP. In this tutorial, we will show you how do you install Prestashop on CentOS 7 based server.

PrestaShop comes with hundreds of useful features, some of them are listed above:

  • Extendable with free, external or add-on modules
  • Wide choice of customizable e-commerce themes
  • Intuitive Interface
  • Easily manage your products and orders
  • More than 50 payments methods supported
  • and many more…

Prerequisites

– CentOS 7 VPS with SSH root access
– Apache 2.x or Nginx web server
– PHP version 5.4 or newer, with Mcrypt, OpenSSL, Zip, Curl, GD, and PDO extensions
– MySQL database server version 5.4 or newer with a database created

1. Login via SSH and update the system

In order to start installing the necessary services, we need to login to the CentoS 7 VPS via SSH as user root

ssh root@IP_Address -p Port_Number

Before we can continue, make sure that all installed packages are updated to the latest version

yum -y update

2. Install MariaDB

Next, install MariaDB database server on your VPS by executing the following command

yum -y install mariadb

Start the database server and enable it to automatically start upon server reboot

systemctl start mariadb
systemctl enable mariadb

After the installation is completed, run the ‘mysql_secure_installation’ script to set the password of the MariaDB ‘root’ user and additionally strengthen the security of the database server.

With this step, the installation of the MariaDB server is completed. Now, login to the database server as user root,

mysql -u root -p

MariaDB [(none)]> CREATE DATABASE prestashop;
MariaDB [(none)]> CREATE USER ‘user’@’localhost’ IDENTIFIED BY ‘PASSWORD’;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON prestashop.* TO ‘user’@’localhost’;
MariaDB [(none)]> FLUSH PRIVILEGES
MariaDB [(none)]> exit

and of course, don’t forget to replace ‘PASSWORD’ with an actual strong password.

3. Install Apache Web Server

Install Apache from the official CentOS 7 repositories using the yum package manager

yum -y install httpd

start the web server and enable it to automatically start after reboot

systemctl start httpd
systemctl enable httpd

4. Install PHP 7.1

PHP 5.6 is the minimum supported PHP version, but PrestaShop runs perfectly on PHP 7.1 and this is the recommended version, so we will install it on our server. CentOS 7 by default is shipped with PHP 5.4, so we will need to add an extra repository in order to be able to install a newer PHP version.

Run the following commands to add the Webtatic EL repository

yum -y install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

and install PHP 7.1 along with the PHP extensions we mentioned in the prerequisites section
yum install php71w php71w-common php71w-curl php71w-mysql php71w-mcrypt php71w-gd php70w-cli php70-pdo

5. Download and unpack PrestaShop

Download the latest stable release of PrestaShop to your server. Currently, it is version 1.7.4.2

wget https://download.prestashop.com/download/releases/prestashop_1.7.4.2.zip

Unpack the archive to the document root directory of your server

unzip prestashop_1.7.4.2.zip -d /var/www/html
unzip prestashop_1.7.4.2.zip
unzip prestashop.zip -d /var/www/html/prestashop/

and set the correct permissions to the PrestaShop directory

chown apache:apache -R /var/www/html/prestashop/

6. Create Apache Virtual Host

At this point, you should be able to access your PrestaShop website using your server’s IP address. We will create a new Apache virtual host, so we can be able to access it with a domain name. Create a new virtual host directive with the following content:

vi /etc/httpd/conf.d/prestashop.conf

ServerAdmin admin@your-domain.com
DocumentRoot /var/www/html/prestashop/
ServerName your-domain.com
ServerAlias www.your-domain.com

Options +FollowSymlinks
AllowOverride Al

ErrorLog /var/log/httpd/prestashop-error_log
CustomLog /var/log/httpd/prestashop-access_log common

Save the file and restart the web server for the changes to take effect

systemctl restart httpd

7. Access and install PrestaShop

Now, since we already installed and configured all necessary services and packages, and downloaded PrestaShop, you should be able to access your PrestaShop e-commerce website at http://your-domain.com and follow the on-screen instructions to complete the installation from your favorite web browser. Once everything is properly installed, for security purposes you should remove the installation directory

rm -rf /var/www/html/prestashop/install/

For more details on how to configure and use PrestaShop, please check their official documentation.

Of course, you don’t have to Install PrestaShop on CentOS 7 if you use our Managed PrestaShop Hosting services, in which case you can simply ask our expert Linux admins to install PrestaShop on CentOS 7, for you. They are available 24×7 and will take care of your request immediately.

Installing PrestaShop on CentOS 7

 

PS. If you liked this post, on how to Install PrestaShop on CentOS, please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

Be the first to write a comment.

Source

Debian: DSA-4320-1: asterisk security update

Posted by Anthony Pell

Debian
Multiple vulnerabilities have been discovered in Asterisk, an open source PBX and telephony toolkit, which may result in denial of service or information disclosure. —–BEGIN PGP SIGNED MESSAGE—–
Hash: SHA512

– ————————————————————————-
Debian Security Advisory DSA-4320-1 security@debian.org
https://www.debian.org/security/ Moritz Muehlenhoff
October 16, 2018 https://www.debian.org/security/faq
– ————————————————————————-

Package : asterisk
CVE ID : CVE-2018-7284 CVE-2018-7286 CVE-2018-12227 CVE-2018-17281
Debian Bug : 891227 891228 902954 909554

Multiple vulnerabilities have been discovered in Asterisk, an open source
PBX and telephony toolkit, which may result in denial of service or
information disclosure.

For the stable distribution (stretch), these problems have been fixed in
version 1:13.14.1~dfsg-2+deb9u4.

We recommend that you upgrade your asterisk packages.

For the detailed security status of asterisk please refer to
its security tracker page at:
https://security-tracker.debian.org/tracker/asterisk

Further information about Debian Security Advisories, how to apply
these updates to your system and frequently asked questions can be
found at: https://www.debian.org/security/

Mailing list: debian-security-announce@lists.debian.org

Source

AWS Managed Microsoft AD Now Offers Additional Configurations to Connect to Your Existing Microsoft AD

Posted On: Oct 16, 2018

AWS Directory Service for Microsoft Active Directory, also known as AWS Managed Microsoft AD, now gives you an additional option to implement the principle of least privilege by reducing the scope of access through the Active Directory (AD) trusts between AWS Managed Microsoft AD and your existing Microsoft AD. As an alternative to forest-wide trust, you can now use external trusts to connect to specific child or tree domains in your existing Microsoft AD forest.

By using external trust, only users from the domains you specify may use their existing AD credentials to access applications such as Amazon RDS for SQL Server, Amazon WorkSpaces, and other AD-aware applications that are using AWS Managed Microsoft AD. This also limits read access in your existing Microsoft AD by AWS Managed Microsoft AD when you implement two-way trusts or trusts from your existing Microsoft AD to AWS Managed Microsoft AD.

This feature is available today in all AWS Regions where AWS Managed Microsoft AD is offered. To learn more, see Connect to Your Existing AD Infrastructure.

Source

Sparky news 2018/08 | SparkyLinux

















The 8th monthly report of the 2018 of Sparky project:

• new additions: ONLYOffice, Caprine, Discord
• EFL updated up to 1.21.0 & Enlightenment to 0.22.4 (testing repos)
• fixed installation of a few desktops via APTus on testing (make sure that changes in Debian testing repos can make problems sometimes, so report whatever you find)
• Sparky Linux kernels updated up to version 4.18.5 & 4.19-rc1
• improved removing desktops via APTus, many thanks go to lami07
• Jade desktop updated up to 0.6.6
• Added Jade desktop installation to APTus
• lami07 keep improving i3 configuration which will be used as default by Sparky, when ready.

New iso images of Sparky 5.5 should be ready in the middle of September, but the point is to ship them with Linux kernel 4.18 as default.


Tags: 2018augustlinuxprojectreportsparkysparkylinux





‘,
enableHover: false,
enableTracking: true,
buttons: { twitter: },
click: function(api, options){
api.simulateClick();
api.openPopup(‘twitter’);
}
});
jQuery(‘#facebook’).sharrre({
share: {
facebook: true
},
template: ‘

‘,
enableHover: false,
enableTracking: true,
click: function(api, options){
api.simulateClick();
api.openPopup(‘facebook’);
}
});
jQuery(‘#googleplus’).sharrre({
share: {
googlePlus: true
},
template: ‘

‘,
enableHover: false,
enableTracking: true,
urlCurl: ‘https://sparkylinux.org/wp-content/themes/anew/js/sharrre.php’,
click: function(api, options){
api.simulateClick();
api.openPopup(‘googlePlus’);
}
});
jQuery(‘#pinterest’).sharrre({
share: {
pinterest: true
},
template: ‘

‘,
enableHover: false,
enableTracking: true,
buttons: {
pinterest: {
description: ‘Sparky news 2018/08’ }
},
click: function(api, options){
api.simulateClick();
api.openPopup(‘pinterest’);
}
});
});




Advertising













Source

How Do Rest APIs Work

REST or RESTful APIs are everywhere these days. You may have used it even without knowing anything about it. In this article, I will talk about REST APIs. I will discuss how they work, their applications and many more. Let’s get started.

In traditional web applications, let’s say a simple PHP web server,

  • You request a page (let’s say php) from the server.
  • The server finds the script file (php) corresponding the page you requested and starts executing it. The script connects to the database, looks for the required information, places the information into the page in a nicely formatted way (mixing HTML + CSS + JavaScript with the data) that looks very attractive to the visitor.
  • Then the server sends it back to the visitor.

In this model, all the processing is done on the server side. So the server has to do more work. Here, data is not separate from the page, it’s embedded deeply into the page.

If in future, you want to make an Android app or iOS app or a Desktop app of your website, you will have to do a lot more work. You will have to connect to the database directly from each of these apps, which may not be very secure. The development time will increase and portability issues will arise.

Let’s say you’ve successfully made Desktop, Android and iOS apps of your website. The user’s full name is displayed in lowercase in each of them. Now, you would like to show it in uppercase. Well, the developers have to modify the Desktop, Android and iOS version of your app separately in order to do that. Which is time consuming. In real world, things won’t be as simple as this one. So, one version of the app (Let’s say the Desktop version) may have a serious bug in the update process. Fixing it later would take more time. Can you see how the development time increases? This solution is not portable as well.

In REST API, you ask the API server what you need and it sends you just the information you ask for, no additional formatting is done in the server. There is no need for unnecessary processing in the server. So, the performance of your website and apps are naturally improved. Also, you can use the same data in your website, desktop app, Android and iOS apps. Changes made to the servers will be reflected in the apps that are using the API. The app development time and cost will also be reduced.

How REST API Work:

The REST APIs have endpoints. An endpoint is nothing more than a URL, but in a nicely formatted way and it is meaningful. It uses the native HTTP requests (such as GET, POST, PUT, DELETE etc) to decide what to do when you access each endpoints. I will talk about these later.

The output format of the REST API is JSON also known as JavaScript Object Notation.

An example of the output of a GET request to the REST API on /users/id/12 endpoint may look as follows:

{
“id”: 12,
“name”: “David Smith”,
“age”: 42,
“phones”: [“124-211-2341”, “889-211-4545”],
“country”: “US”
}

As you can see, I did a GET request on /users/id/12 endpoint to tell the REST API to give me information about the user who has the id 12. I got just the information I requested, nothing more, nothing less.

Now let’s say, you want information on the last 10 users who signed up on your website. You may do a GET request on /users/latest/10 endpoint.

You can add new data on your server using the REST API as well. Usually, the HTTP POST request is used to ask the REST API to add new data to the API server.

For example, you can do a POST request on /users endpoint with the data of the new user and it will be added to the database on your API server. You can also configure your API to return the status of the request.

{
“statusCode”: 400,
“statusText”: “User successfully added.”,
“data”: {
“id”: 13,
“name”: “Mary Smith”,
“age”: 35,
“phones”: [“124-211-2341”, “889-211-4545”],
“country”: “US”
}
}

As you can see, the statusCode and statusText property of the JSON object notifies the API client that the user is successfully added. The data added is returned as well in the data property of the JSON object. You can configure your API just the way you want.

You can update an existing record from the API server’s database as well. The PUT HTTP request is used on an API endpoint to update existing data on your API server’s database.

For example, let’s say you want to update the phone number of the user with the id 13. You may do a PUT request on the API endpoint /user/id/13.

{
“statusCode”

:

200,
“statusText”

:

“User updated.”,
“old_data”

:

{
“id”

:

13,
“name”

:

“Mary Smith”,
“age”

:

35,
“phones”

:

[“124-211-2341”, “889-211-4545”],
“country”

:

“US”
},
“new_data”

:

{
“id”

:

13,
“name”

:

“Mary Smith”,
“age”

:

35,
“phones”

:

[“100-211-1111”, “140-211-1145”],
“country”

:

“US”

}}

As you can see, the update operation is successful. The old data and new data is returned in the old_data and new_data property of the JSON object respectively.

You can also delete data from the API server’s database with the HTTP DELETE request on the API endpoint.

For example, to delete the user with the id 12, you may do a DELETE request on the API endpoint /user/id/12.

{
“statusCode”: 150,
“statusText”: “User removed.”,
“data”: {
“id”: 12,
“name”: “David Smith”,
“age”: 42,
“phones”: [“124-211-2341”, “889-211-4545”],
“country”: “US”
}
}

As you can see, the user is deleted and the deleted user data is returned in the data property of the JSON object.

I have explained the standard way to use the GET, POST, PUT and DELETE HTTP request on the API endpoints to do CRUD (Create, Read, Update and Delete) operation using REST API. But you can configure your API to do certain things on certain HTTP request. Nothing is fixed here. For example, you can update the API using GET HTTP request. You don’t have to use PUT. It’s up to the API designer.

You design the API endpoints as well. Giving meaningful names to your API endpoints make your REST API much easier to use.

Applications of REST API:

APIs make app development easier and modular. With the help of REST API, you can easily port your app to different platforms.

All you have to do is design and develop a REST API of your application. Then you can use your REST API from your website, Android app, iOS app, Windows desktop app and Linux app etc. This way, all of your apps on different platform will use the same logic and your development time and cost will be reduced. The apps will be easier to manage as well. REST APIs are used rapidly in Single Page Web Applications these days as well.

I have written an article on writing REST APIs using Python. Thanks for reading this article.

Source

5 Docker Compose Examples | Linux Hint

Docker compose is an efficient and easy way of deploying docker containers on a host. Compose takes in a YAML file and creates containers according to its specifications. The specification includes what images are needed to be deployed, which specific ports are needed to be exposed, volumes, cpu and memory usage limits, etc.

It is an easy way to set up automated application deployment with a frontend, a database and a few passwords and access keys thrown in for good measure. Everytime you run docker-compose up from inside a directory that contains a docker-compose.yml it goes through the file and deploys your application as specified.

To help you write your own docker-compose.yml here are 5 simple and, hopefully, helpful YAML snippets that you can mix and match.

Probably the most common application to be deployed as a Docker container is Nginx. Nginx can serve as reverse proxy server and as SSL termination point for your web applications. Different content management systems like Ghost and WordPress can be hosted behind a single Nginx reverse proxy server and thus it makes sense to have an nginx server snippet handy at all times. The first thing you would need is an nginx configuration file. If you choose not to create one, the default HTTP server is what you will get.

For example, I would create a folder nginx-configuration in my home folder. The configuration file nginx.conf will be present inside this folder, along with other files directories that nginx would expect at /etc/nginx. This includes SSL certs and keys, and host names for the backend servers where the traffic needs to be forwarded.

This folder can then be mounted inside nginx container at /etc/nginx (with read-only permission if you prefer extra precaution) and you can run the server as a container, but you can configure it locally from your home directory without having to log into the container.

This is a sample:

version: ‘3’
services:
nginx:
image: nginx:latest
volumes:
– /home/USER/nginx-configuration:/etc/nginx
ports:
– 80:80
– 443:443

2. Ghost Blog

Ghost is a CMS written mostly in Node.js and is simplistic, fast and elegant in design. It relies on Nginx to route traffic to it and uses MariaDB or sometimes SQLite to store data. You can deploy a quick and dirty Docker image for Ghost using a simple snippet as shown below:

version:

‘3’

services:

ghost:

image: ghost:latest

ports:

2368

:

2368

volumes:

– ghost-data:/var/lib/ghost/content/

volumes:

Ghost-data:

This creates a new volume and mounts it inside the container to store the website’s content persistently. You can add the previous nginx reverse proxy service to this compose file and have a production grade Ghost Blog up and running in the matter of minutes, provided you have configured Nginx to route the relevant traffic from port 80 or 443 to port 2368 on the ghost container.

3. MariaDB

MariaDB is quite a useful piece of software to not be available at a moment’s call on your server. However, databases create a lot of logs, the actual data tends to get spread all over the place and setting up database servers and/or clients never goes smoothly. The carefully crafted docker-compose file can mitigate some of the problems by trying to store all the relevant data in a single Docker volume, while the database software and its complexities are tucked away in the a container:

version

:

‘3’

services:

mydb:

image: mariadb

environment:

MYSQL_ROOT_PASSWORD

=

my

secret

pw

You can create a new database container for each new application, instead of creating more users on the same database, setting up privileges and going through a painful rigmarole of ensuring every app and user stays on its own turf. You also won’t have to open ports on the host system since the database container will run on its own isolated network and you can have it so that only your application can be a part of that network and thus access the database.

4. WordPress Stack

A culmination of all the various parts from the use of environment variables to running a frontend web server and a backend database can be combined in a docker-compose file for a WordPress website, as shown below:

version

:

‘3.3’

services:

db:

image: mysql:

5.7

volumes:

db_data:

/

var

/

lib

/

mysql

restart: always

environment:

MYSQL_ROOT_PASSWORD: somewordpress

MYSQL_DATABASE: wordpress

MYSQL_USER: wordpress

MYSQL_PASSWORD: wordpress

wordpress:

depends_on:

db

image: wordpress:latest

ports:

– “8000:80”

restart: always

environment:

WORDPRESS_DB_HOST: db:

3306

WORDPRESS_DB_USER: wordpress

WORDPRESS_DB_PASSWORD: wordpress

volumes:

db_data:

This is the most popular example and is also mentioned in the official Docker-Compose documentation. Chances are you won’t be deploying WordPress, but the compose file here can still serve as a quick reference for similar application stacks.

5. Docker-Compose with Dockerfiles

So far we have only been dealing with the pure deployment side of docker-compose. But chances are you will be using Compose to not just deploy but develop, test and then deploy applications. Whether running on your local workstation, or on a dedicated CD/CI server, docker-compose can build an image by using the Dockerfile present at the root of the repository concerning your application or part of the application:

version: ‘3’
services:
front-end:
build: ./frontend-code
back-end:
image: mariadb

You will have noticed that while the backend service is using a pre-existing image of mariadb, the frontend image is first built from the Dockerfile located inside ./frontend-code directory.

Lego blocks of Docker-Compose

The entire functionality of Docker-Compose is pretty easy to grasp if only we first ask ourselves what it is that we are trying to build. After a few typos and failed attempted, you will be left with a set of snippets that work flawlessly and can be put together like lego building blocks to define your application deployment.

I hope the above few examples will give you a good head start with that. You can find the complete reference for writing compose file here.

Source

How to use arrays in bash script

Objective

After following this tutorial you should be able to understand how

bash

arrays work and how to perform the basic operations on them.

Requirements

  • No special system privileges are required to follow this tutorial

Difficulty

EASY

Introduction

bash-logoBash

, the

Bourne Again Shell

, it’s the default shell on practically all major linux distributions: it is really powerful and can be also considered as a programming language, although not as sophisticated or feature-reach as python or other “proper” languages. In this tutorial we will see how to use bash arrays and perform fundamental operations on them.

Create an array

The first thing to do is to distinguish between bash

indexed

array and bash

associative

array. The former are arrays in which the keys are ordered integers, while the latter are arrays in which the keys are represented by strings. Although indexed arrays can be initialized in many ways, associative ones can only be created by using the

declare

command as we will see in a moment.

Create indexed or associative arrays by using declare

We can explicitly create an array by using the

declare

command:

$ declare -a my_array

Declare, in bash, it’s used to set variables and attributes. In this case, since we provided the

-a

option, an

indexed array

has been created with the “my_array” name.

Associative arrays can be created in the same way: the only thing we need to change is the option used: instead of lowercase -a we must use the -A option of the declare command: $ declare -A my_array This, as already said, it’s the only way to create associative arrays in bash.

Create indexed arrays on the fly

We can create indexed arrays with a more concise syntax, by simply assign them some values: $ my_array=(foo bar) In this case we assigned multiple items at once to the array, but we can also insert one value at a time, specifying its index: $ my_array[0]=foo

Array operations

Once an array is created, we can perform some useful operations on it, like displaying its keys and values or modifying it by appending or removing elements:

Print the values of an array

To display all the values of an array we can use the following shell expansion syntax: $ Or even: $ Both syntax let us access all the values of the array and produce the same results, unless the expansion it’s quoted. In this case a difference arises: in the first case, when using @, the expansion will result in a word for each element of the array. This becomes immediately clear when performing a for loop. As an example, imagine we have an array with two elements, “foo” and “bar”: $ my_array=(foo bar) Performing a for loop on it will produce the following result:
$ for i in “$”; do echo “$i”; done
foo
bar
When using *, and the variable is quoted, instead, a single “result” will be produced, containing all the elements of the array:
$ for i in “$”; do echo “$i”; done
foo bar

Print the keys of an array

It’s even possible to retrieve and print the keys used in an indexed or associative array, instead of their respective values. The syntax is almost identical, but relies on the use of the ! operator:
$ my_array=(foo bar baz)
$ for index in “${!my_array[@]}”; do echo “$index”; done
0
1
2
The same is valid for associative arrays:
$ declare -A my_array
$ my_array=([foo]=bar [baz]=foobar)
$ for key in “${!my_array[@]}”; do echo “$key”; done
baz
foo
As you can see, being the latter an associative array, we can’t count on the fact that retrieved values are returned in the same order in which they were declared.

Getting the size of an array

We can retrieve the size of an array (the number of elements contained in it), by using a specific shell expansion:
$ my_array=(foo bar baz)
$ echo “the array contains ${#my_array[@]} elements”
the array contains 3 elements
We have created an array which contains three elements, “foo”, “bar” and “baz”, then by using the syntax above, which differs from the one we saw before to retrieve the array values only for the # character before the array name, we retrieved the number of the elements in the array instead of its content.

Adding elements to an array

As we saw, we can add elements to an indexed or associative array by specifying respectively their index or associative key. In the case of indexed arrays, we can also simply add an element, by appending to the end of the array, using the += operator:
$ my_array=(foo bar)
$ my_array+=(baz)
If we now print the content of the array we see that the element has been added successfully:
$ echo “$”
foo bar baz
Multiple elements can be added at a time:
$ my_array=(foo bar)
$ my_array+=(baz foobar)
$ echo “$”
foo bar baz foobar
To add elements to an associative array, we are bound to specify also their associated keys:

$ declare -A my_array

# Add single element
$ my_array[foo]=”bar”

# Add multiple elements at a time
$ my_array+=([baz]=foobar [foobarbaz]=baz)

Deleting an element from the array

To delete an element from the array we need to know it’s index or its key in the case of an associative array, and use the unset command. Let’s see an example:
$ my_array=(foo bar baz)
$ unset my_array[1]
$ echo $
foo baz
We have created a simple array containing three elements, “foo”, “bar” and “baz”, then we deleted “bar” from it running unset and referencing the index of “bar” in the array: in this case we know it was 1, since bash arrays start at 0. If we check the indexes of the array, we can now see that 1 is missing:
$ echo ${!my_array[@]}
0 2
The same thing it’s valid for associative arrays:
$ declare -A my_array
$ my_array+=([foo]=bar [baz]=foobar)
$ unset my_array[foo]
$ echo $
foobar
In the example above, the value referenced by the “foo” key has been deleted, leaving only “foobar” in the array.

Deleting an entire array, it’s even simpler: we just pass the array name as an argument to the unset command without specifying any index or key:
$ unset my_array
$ echo ${!my_array[@]}

After executing unset against the entire array, when trying to print its content an empty result is returned: the array doesn’t exist anymore.

Conclusions

In this tutorial we saw the difference between indexed and associative arrays in bash, how to initialize them and how to perform fundamental operations, like displaying their keys and values and appending or removing items. Finally we saw how to unset them completely. Bash syntax can sometimes be pretty weird, but using arrays in scripts can be really useful. When a script starts to become more complex than expected, my advice is, however, to switch to a more capable scripting language such as python.

Source

Linux-driven LoRaWAN gateway ships with new “Wzzard” LoRa nodes

Advantech has launched a rugged, Arm Linux based “WISE-6610” LoRaWAN gateway in 100- or 500-node versions with either 915MHz or 868MHz support. There’s also a “Wzzard LRPv2 Node” that can connect four sensors at once.

Advantech announced the industrial WISE-6610 gateway and Wzzard LRPv2 Node for long-range, low-bandwidth LoRaWAN gateways on May 31, and judging from this Oct. 5 Electronics Weekly post, they are now available. Designed for I/O sensor data management and network protocol conversion primarily on private LoRaWAN networks, the products are part of a Wzzard LoRa Sensing Network family that includes a recent SmartSwarm 243 gateway that appears to be almost identical to the WISE-6610 (see farther below).

The WISE-6610 product page and data sheet are a little thin on hardware details, but Advantech has informed us the gateway runs Linux on an ARM-based processor.

Advantech’s Wzzard devices (l to r): SmartSwarm 243, an unidentified LoRa node, Wzzard LRPv2 Node, and WISE-6610
(click image to enlarge)

The 868MHz or 915MHz LoRa wireless technology can work in peer-to-peer fashion between low-cost, low-power LoRa nodes. LoRa nodes can also connect to the Internet via a LoRaWAN gateway, thereby avoiding cellular data costs for long distance IoT data acquisition and aggregation. Other LoRaWAN gateways include Aaeon’s Intel Cherry Trail based

AIOT-ILRA01

and more recently, Pi Supply’s

Iot LoRa Gateway and IoT LoRa Node pHAT

add-ons for the Raspberry Pi.

WISE-6610

Advantech offers four models of the WISE-6610 gateway, letting you mix and match capacity and frequency. The WISE-6610-N100 and WISE-6610-N500 support 100 and 500 nodes, respectively, using the 915MHz LoRa standard used primarily the U.S. The WISE-6610-E100 and WISE-6610-E500 support 100 and 500 nodes, respectively, but with the more widely used 868MHz European standard.

WISE-6610

The WISE-6610 is equipped with 512MB of RAM and 128KB of M-RAM, Advantech informs us. There is also 256MB of flash “for hosting custom software applications.”

The gateway can connect to an application or SCADA server using the MQTT protocol, and VPN tunnel creation is available via Open VPN, EasyVPN, and other protocols. The network server can encrypt and convert LoRaWAN data.

The WISE-6610 is equipped with a 10/100 Ethernet port with 1.5-kV magnetic isolation protection, and there’s an SMA female connector for attaching an antenna. A Molex port provides Digital I/O with a 2.7 to 36VDC range.

There’s a wide-range, 9-36VDC input with a Molex port, as well as “redundancy-enhanced functions…specifically designed to prevent connection loss,” says Advantech. Power consumption which is low enough to support solar or battery powered operation, is listed as “3.1/6.6/40 mW (average/peak/sleep mode).”

The 150 x 83 x 30mm device can be wall or DIN-rail mounted and features 4x LEDs and a reset button. The gateway offers IP30 ingress protection and a -40 to 75°C operating range, and there are regulatory approvals for EMC (EN61000-4-x Level 3), shock (IEC 60068-2-27), free fall (IEC 60068-2-32), and vibration (IEC 60068-2-6).

SmartSwarm 243

We didn’t see a product page for a Wzzard LRPv2 Node, but we did find one for a first-gen Wzzard LRPv Node. On May 1, a month prior to the WISE-6610 announcement, Advantech announced a Wzzard LRPv Node paired with a new Advantech SmartSwarm 243 LoRaWAN gateway, also referred to as the BB-SG30000115-43. The launch was said to be in partnership with Semtech, which presumably supplies the
LoRa chipsets for the systems, and most likely also for the WISE-6610.

SmartSwarm 243
(click image to enlarge)

The SmartSwarm 243 appears to be identical to the WISE-6610 in size, ruggedization features, power, and I/O, and it presumably also runs Linux on an Arm processor. The only difference we can see is in the external design and in the image above (but not at top), the addition of two more antenna connectors.

Wzzard LRPv2 Node

Based on the Wzzard LRPv2 Node announcement and image, it’s almost identical to the Wzzard LRPv Node described in the datasheet. The only additional information we spotted was a claim that the v2 model can connect and acquire data from up to four sensor devices simultaneously.


Wzzard LRPv2 Node

The Wzzard LRPv Node supports either 868MHz or 915MHz LoRa networks and offers an optional omnidirectional antenna. There are no details on processor, memory, or firmware, but the system is said to support MQTT and JSON protocols. In addition: “The software is specifically designed to be customizable so as to accommodate the most sophisticated of monitoring plans,” says Advantech.

The Wzzard LRPv Node is available in several different I/O models including a high-end SKU with single digital inputs and outputs, dual 12-bit analog outputs, and dual thermocouple inputs. Other options provide 3x and 2x analog inputs and 1x digital input, but no thermocouples or digital outputs. I/O connections can be implemented via conduit fittings, cable glands, or an M12 connector.

The 115.9 x 95.25 x 65.15mm, 0.34 kg device offers the same -40 to 75°C range as the WISE-6610 gateway and the same shock, free fall, and vibration ratings. In addition, it features a higher IP66 level of ingress protection.

The Wzzard LRPv Node ships with dual 3.6-V, 2400-mAH AA batteries, and there’s an optional external 6-12V input. Sleep and operation modes are available, and there’s an embedded alarm system “to notify users when a threshold has been exceeded so that action can be taken,” says Advantech.

Further information

The WISE-6610 gateway and Wzzard LRPv2 Node appear to be available now with undisclosed pricing. More information may be found on Advantech’s WISE-6610 and Wzzard LoRa Sensing Network page, which offers links to individual product pages, including the BB-SG30000115-43 (SmartSwarm 243). (The Wzzard nodes are listed under BB-WSL2xx product names.)

Source

NanoPi Neo4 SBC breaks RK3399 records for size and price

FriendlyElec has launched a $45, Rockchip RK3399 based “NanoPi Neo4” SBC with a 60 x 45mm footprint, WiFi/BT, GbE, USB 3.0, HDMI 2.0, MIPI-CSI, a 40-pin header, and -20 to 70℃ support — but only 1GB of RAM.

In August, FriendlyElec introduced the NanoPi M4, which was then the smallest, most affordable Rockchip RK3399 based SBC yet. The company has now eclipsed the Raspberry Pi style, 85 x 56mm NanoPi M4 on both counts, with a 60 x 45mm size and $45 promotional price ($50 standard). The similarly open-spec, Linux and Android-ready NanoPi Neo4, however, is not likely to beat the M4 on performance, as it ships with only 1GB of DDR3-1866 instead of 2GB or 4GB of LPDDR3.

NanoPi Neo4 and detail view
(click images to enlarge)

This is the first SBC built around the hexa-core RK3399 that doesn’t offer 2GB RAM at a minimum. That includes the still unpriced

Khadas Edge

, which will soon launch on Indiegogo, and Vamrs’ $99 and up, 96Boards form factor

Rock960

, in addition to the many other RK3399 based entries listed in our

June catalog of 116 hacker boards

.


NanoPi M4

Considering that folks are complaining that the quad -A53, 1.4GHz Raspberry Pi 3+ is limited to only 1GB, it’s hard to imagine the RK3399 is going to perform up to par with only 1GB. The SoC has a pair of up to 2GHz Cortex-A72 cores and four Cortex -A53 cores clocked to up to 1.5GHz plus a high-end Mali-T864 GPU.

Perhaps size was a determining factor in limiting the board to 1GB along with price. Indeed, the 60 x 45mm footprint ushers the RK3399 into new space-constrained environments. Still, this is larger than the earlier 40 x 40mm Neo boards or the newer, 52 x 40mm NanoPi Neo Plus2, which is based on an Allwinner H5.

We’re not sure why FriendlyElec decided against calling the new SBC the NanoPi Neo 3, but there have been several Neo boards that have shipped since the Neo2, including the NanoPi Neo2-LTS and somewhat Neo-like, 50 x 25.4mm NanoPi Duo.

The NanoPi Neo4 differs from other Neo boards in that it has a coastline video port, in this case an HDMI 2.0a port with support for up to [email protected] video with HDCP 1.4/2.2 and audio out. Another Neo novelty is the 4-lane MIPI-CSI interface for up to a 13-megapixel camera input.

NanoPi Neo4 with and without optional heatsink
(click images to enlarge)

You can boot a variety of Linux and Android distributions from the microSD slot or eMMC socket (add $12 for 16GB eMMC). Thanks to the RK3399, you get native Gigabit Ethernet. There’s also a wireless module with 802.11n (now called WiFi 4) limited to 2.4GHz WiFi and Bluetooth 4.0.

The NanoPi Neo4 is equipped with coastline USB 3.0 and USB 2.0 host ports plus a Type-C power and OTG port and an onboard USB 2.0 header. The latter is found on one of the two smaller GPIO connectors that augment the usual 40-pin header, which like other RK3399 boards, comes with no claims of Raspberry Pi compatibility. Other highlights include an RTC and -20 to 70℃ support.

Specifications listed for the NanoPi Neo4 include:

  • Processor — Rockchip RK3399 (2x Cortex-A72 at up to 2.0GHz, 4x Cortex-A53 @ up to 1.5GHz); Mali-T864 GPU
  • Memory:
    • 1GB DDR3-1866 RAM
    • eMMC socket with optional ($12) 16GB eMMC
    • MicroSD slot for up to 128GB
  • Wireless — 802.11n (2.4GHz) with Bluetooth 4.0; ext. antenna
  • Networking — Gigabit Ethernet port
  • Media:
    • HDMI 2.0a port (with audio and HDCP 1.4/2.2) for up to 4K at 60Hz
    • 1x 4-lane MIPI-CSI (up to 13MP);
  • Other I/O:
    • USB 3.0 host port
    • USB 2.0 Type-C port (USB 2.0 OTG or power input)
    • USB 2.0 host port
  • Expansion:
    • GPIO 1: 40-pin header — 3x 3V/1.8V I2C, 3V UART, SPDIF_TX, up to 8x 3V GPIOs, PCIe x2, PWM, PowerKey
    • GPIO 2: 1.8V 8-ch. I2S
    • GPIO 3: Debug UART, USB 2.0
  • Other features — RTC; 2x LEDs; optional $6 heatsink, LCD, and cameras
  • Power — DC 5V/3A input or USB Type-C; optional $9 adapter
  • Operating temperature — -20 to 70℃
  • Dimensions — 60 x 45mm; 8-layer PCB
  • Weight – 30.25 g
  • Operating system — Linux 4.4 LTS with U-boot 2014.10; Android 7.1.2 or 8.1 (requires eMMC module); Lubuntu 16.04 (32-bit); FriendlyCore 18.04 (64-bit), FriendlyDesktop 18.04 (64-bit); Armbian via third party;

Further information

The NanoPi Neo4 is available for a promotional price of $45 (regularly $50) plus shipping, which ranges from $16 to $20. More information may be found on FriendlyElec’s NanoPi Neo4 product page and wiki, which includes schematics, CAD files, and OS download links.

Source

WP2Social Auto Publish Powered By : XYZScripts.com