Web Solutions and Technical Support Resources

Date Time in Laravel and PHP with Carbon

This article covers how to manage date/time easily in Laravel and PHP with Carbon. Basically, Carbon is a package that helps us to deal with date/time in Laravel and PHP in a much easier and systematic manner.

Working with date and time in PHP is not the easiest or most clear of tasks. We have to deal with strtotime, formatting issues, lots of calculations, and more.

Carbon provides some nice functionality to deal with dates in PHP such as:

1. Dealing with timezones

2. Getting current time easily

3. Converting a datetime into something readable

4. Parse an English phrase into datetime (first day of January 2016)

5. Add and Subtract dates (+ 2 weeks, -6 months)

6. Semantic way of dealing with dates

Carbon is already included in Laravel so there's no need to go and add it with Composer.

Whenever we need to use Carbon, we can import it like so:


use Carbon\Carbon;

After importing you can do a lot with this great package.

Read More

Enable and Configure MPIO on Windows Server 2016 2012 R2

This article covers how to enable Multi-Path Input-Output or MPIO on a Windows server either from a graphical interface using the Server Manager console or from the PowerShell command line. 

Multipathing is the technique of creating more than one physical path between the server and its storage devices. It results in better fault tolerance and performance enhancement. Oracle VM Servers are installed with multipathing enabled because it is a requirement for SAN disks to be discovered by Oracle VM Manager.

To Install MPIO in Windows Server 2008 R2:

Note You must restart the server after you follow these steps.

1. Open Server Manager. To do this, click Start, click Administrative Tools, and then click Server Manager.

2. In Server Manager, click Features, and then click Add Features.

3. Select the Multipath I/O feature for installation, and then click Next.

4. Finish the installation by confirming the selections, and then restart the server.

To Configure MPIO for StorSimple volumes:

MPIO must be configured to identify StorSimple volumes. 

To configure MPIO to recognize StorSimple volumes, follow these steps:

1. Open the MPIO configuration. To do this, click Start, click Administrative Tools, and then click MPIO.

2. In the MPIO window, click Add on the MPIO Devices tab.

3. Type SSIMPLE Model in the Add MPIO Support window under Device Hardware ID.

4. Restart the server when you are prompted.

To Mount a StorSimple volume in Windows Server 2008 R2:

After MPIO is configured on the server, volumes that are created on the StorSimple appliance can be mounted and can take advantage of MPIO for redundancy. 

To mount a volume, follow these steps:

1. Open the iSCSI Initiator Properties dialog box on the server. To do this, click Start, click Administrative Tools, and then click iSCSI Initiator.

2. In the iSCSI Initiator Properties dialog box, click the Discovery tab, and then click Discover Portal.

3. Type the IP address of the "DATA" port on the StorSimple appliance.

Note If you use a private network for iSCSI connections, type the IP address of the DATA port that is connected to the private network.

4. Click the Targets tab in the iSCSI Initiator Properties dialog box. This displays the StorSimple appliance iSCSI qualified name (IQN) in the Discovered Targets section.

5. Click Connect to establish the iSCSI session with the StorSimple appliance. In the Connect To Target dialog box, click to select the Enable multi-path check box.

6. Open Server Manager. To do this, click Start, click Administrative Tools, and then click Server Manager.

7. In Server Manager, click Storage, and then click Disk Management. Volumes that are created on the StorSimple appliance and that are visible to this server appear under Disk Management as new disks.

8. Initialize the disk and create a new volume. During the format process, select a block size of 64 kilobytes (KB).

9. Under Disk Management, right-click the disk, and then click Properties.

10. In the SSIMPLE Model #### Multi-Path Disk Device Properties dialog box, click the MPIO tab, click Details in the DSM Name section, and then verify that the parameters are set to the default parameters.

Read More

Install Monit monitoring system on CentOS 8 - How to do it

This article covers how to #install Monit on #Centos 8 system. Also, we dealt with how to configure Monit on Centos, adjusting the configuration and setting up alerts to notify the users.

#Monit is a free, open-source process supervision tool for Unix and Linux. With Monit, system status can be viewed directly from the command line, or via the native HTTP(S) web server. Monit is able to do automatic maintenance, repair, and run meaningful causal actions in error situations.

To enable web interface you need to make changes in monit configuration file. 

The main configuration file of monit located at /etc/monit. conf under (RedHat/CentOS/Fedora) and /etc/monit/monitrc file for (Ubuntu/Debian/Linux Mint). 

Monit is very easy to use nearly out of the box. By default, it is set up to check that services are running every 2 minutes and stores its log file in “/var/log/monit.

To Install Monit to monitor your server running CentOS:

1. Install EPEL repository: yum install epel-release yum update.

2. Install Monit: yum install monit.

3. Activate Monit to start automatically during the system boot and start it: systemctl enable monit systemctl start monit.

To #Install #Monit Package on #Ubuntu:

Run the commands given below;

sudo apt update

sudo apt install monit

After installing Monit, the commands below can be used to stop, start and enable Monit service;

sudo systemctl stop monit.service

sudo systemctl start monit.service

sudo systemctl enable monit.service

Read More

Adding users to the local admin group in PowerShell

This article covers how to add users to local admin group either via Group Policy Objective or directly via command line. 

To add a user to the local group in PowerShell:

You can add AD groups or users to the local admin group using the below Powershell command.

Add-LocalGroupMember -Group "Administrators" -Member "domain\user or group," "additional users or groups."

To add a user to the local admin group:

1. Right-click the newly created Group, select Properties, navigate to the Members tab, click Add… and enter designated users to the group, e.g. domain\administrator, domain\domain admins, domain\syskitmonitorservice. 

2. Add other users that also need administrative privileges, if necessary. 

3. Click OK to proceed.

To get local admin group members in PowerShell:

To get the local Administrators group members using PowerShell, you need to use the GetLocalGroupMember command. 

This command is available in PowerShell version 5.1 onwards and the module for it is Microsoft. PowerShell. LocalAccounts.

To Create a User Account in Windows 10 with PowerShell:

1. Open PowerShell as Administrator.

2. To create a new user account without a password, type New-LocalUser -Name "user_name" -Description "Description of your new account." -NoPassword .

3. To create a user account that has a password, firstly execute the following line: $Password = Read-Host -AsSecureString .

Read More

mkvirtualenv command not found on Ubuntu - How to fix this error

This article covers solution to the #error 'mkvirtualenv: command not found' which happens while running mkvirtualenv #command.

You'll need to install virtualenvwrapper package into the same global site-packages area where virtualenv is installed. 

Administrative privileges are required for this installation. 

Ensure you're logged in as root user or standard user with sudo privileges.

Start by Updating the System package list:

$ sudo apt update

Then install #Python build tools.

# Python 2

$ sudo apt-get install python-pip python-dev build-essential

# Python 3

$ sudo apt-get install python3-pip python3-dev build-essential

Then install virtualenv and virtualenvwrapper packages.

With APT package manager:

$sudo apt install virtualenv virtualenvwrapper

With Pip:

# Python 2

$ sudo pip install virtualenv virtualenvwrapper

# Python 3

$ sudo pip3 install virtualenv virtualenvwrapper

Read More

Unable to connect to MongoDB in Docker container - How to fix this error

This article covers solution to the error "Unable to connect to MongoDB in docker container".

Basically, this Docker error happens when there is a port issue.

if a container listens on, then the host can't map ports to it.

You need to listen on or similar, and then the -p can reach the container's interface.

How do Docker ports work?

The -P command opens every port the container exposes. 

Docker identifies every port the Dockerfile exposes and the ones that are exposed with the Docker container build --expose parameter. 

Every exposed port is bound directly on a “random” port of the host machine.

The docker build command builds Docker images from a Dockerfile and a “context”. A build's context is the set of files located in the specified PATH or URL . 

The build process can refer to any of the files in the context. 

For example, your build can use a COPY instruction to reference a file in the context.

Read More