Category: Process Documentation

Add basic authentication in phpMyAdmin in CentOS 7

Problem: Want to increase phpMyAdmin security, for example adding one more gateway before entering username and password in xxx/phpmyadmin

This is possible and can be achieved in two way:

Solution: first find out where the PHPMyAdmin folder

find /etc/httpd/ -print0 | xargs -0 grep phpmyadmin

then create a .htpasswd  file for the user you want, like user1.

sudo htpasswd -c /etc/httpd/.htpasswd user1

the output will look like this:

user1:$apr1$0r/2zNGG$jopiWY3DEJd2FvZxTnugJ/

Way 1 -- edit /etc/httpd/conf/httpd.conf , change into below content:

<Directory /usr/share/phpmyadmin>
    AuthType Basic
    AuthName "Restricted Content"
    AuthUserFile /etc/httpd/.htpasswd
    Require valid-user
</Directory>

Way 2 -- go to phpMyAdmin folder that finds out via the previous command, add .htaccess file with below content:

AuthType Basic
AuthName "Admin Login"
AuthUserFile /etc/httpd/pma_pass
Require valid-user

Inside multistore + subdomain of Opencart, the new store still displaying the default store’s product and URL

Problem: Applying the multistore + subdomain inside Opencart. For example:

  • default store domain is opencart.com
  • new store domain is second.opencart.com

but here is the problem -- in the new store, the product page can display the default store’s product only, and the product URL still from the default store domain (opencart.com)

Solution: Check out this Youtube video, double-check the new Store URL should start with http:// and at the end append “/

Extend AWS EBS volumes after extending current volume in EC2 instance with no downtime

Problem: well there is a guide from AWS official website but I want to make a simplified version.

This post mainly takes this website as a reference, I saw the website have some indentation problem so I make a refined version here.

Solution: we mainly using “lsblk” and “growpart” command to extend drive storage.

First, after extending current volume in EC2 instance, enter “lsblk” to get block devices information:

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
└─xvda1 202:1 0 8G 0 part /

You can see the original file system size is 8G, and we extend the space from 8G to 20G. But the 12G new, fresh storage still hasn’t applied to the current system.

Second, using “growpart” to extend a partition in a partition table,  we know that the current system file partition is xvda1 so enter below command:

sudo growpart /dev/xvda 1

now check again with “lsblk”

NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
xvda 202:0 0 20G 0 disk
└─xvda1 202:1 0 20G 0 part /

Although the partition now reflects the increased volume size, last we need to extend the filesystem itself. If your filesystem is an ext2, ext3, or ext4, type:

sudo resize2fs /dev/xvda1

If your filesystem is an XFS, then type:

sudo xfs_growfs /dev/xvda1

Error “mount: unknown filesystem type ‘(null)'” occurred in CentOS 7 AWS

Problem: Attach a volume to AWS EC2 instance, after enter a command for mount drive:

sudo mount /dev/xxxx /xxx

An error occurred:

mount: /dev/xxxx is write-protected, mounting read-only mount: unknown filesystem type ‘(null)’

Solution: the volume is unformatted and you should format it first. Enter below command to format volume to ext4 file system :

sudo mkfs.ext4 /dev/xxxx

Then mount again:

sudo mount /dev/xxxx /xxx

By the way, you can use lsblk command to retrieve hard disk partitions and disk space information.

Android app violate policy – “Interstitials that unexpectedly launch” and how to solve it

Problem: According to Google policy, my app violates and needs to fix it before a certain date.

It is because of the interstitials launches when opening app.

Instead, It should be implemented at logical breaks in between your app’s content (e.g. pages, stages, or levels), so the user will not be confused since they are doing some action.

Solution: pre-load the interstitial in advance / Showing Interstitial Ads With Timer (in Splash Screen only)

Source in pdf

Run backup script to backup MySQL Database using cron

Problem: already add backup command in cron:

mysql -s -r -u root -e ‘show databases’ -N | while read dbname; do mysqldump -u root --complete-insert --single-transaction “$dbname” > /backup/sql/”$dbname”.sql; done

and add dbusername and dbpassword in ~/.my.cnf

[client]
user = dbusername
password = dbpassword

but fail to backup due to ‘INFORMATION_SCHEMA.GLOBAL_VARIABLES’ feature is disabled.

According to suggestion, enable MySQL 5.6 compatibility.

Solution: enter MySQL mode and enter

set global show_compatibility_56=on;

or add below directive to /etc/my.cnf :

show_compatibility_56=ON

Applying version design in Laravel

Problem: Current Laravel need to serve different companies and have different stage(production, test, etc.)

Using Route::group and create a different folder for different website/stage.

Solution: follow post on this and this:

  1. Create folders for a different purpose and put controller you want inside it
/app
  /controllers
    /Api
      /v1
        /UserController.php
      /v2
        /UserController.php

In the UserController.php, remember to change namespace accordingly.

For example for controller under v1 folder

namespace Api\v1;

for controller under v2 folder

namespace Api\v2;

In the web.php, using Route::group to determine using which controller, like:

Route::group(['prefix' => 'api/v1'], function () {
  Route::get('user',      'Api\v1\[email protected]');
  Route::get('user/{id}', 'Api\v1\[email protected]');
});

Route::group(['prefix' => 'api/v2'], function () {
  Route::get('user',      'Api\v2\[email protected]');
  Route::get('user/{id}', 'Api\v2\[email protected]');
});

for any prefix like api/v1, using the controller under v1 folder.

Route::group(['domain' => 'itdailydocumentation.com'], function () {
  Route::get('user',      'Api\v3\[email protected]');
  Route::get('user/{id}', 'Api\v3\[email protected]');
});

for domain itdailydocumentation.com, using controller under v3 folder.

As for the version design for layout, you can also copy the view blade to a different folder:

views/
├── v1/
│   ├── master
|   |   ├── master-public.blade.php
|   |   ├── master-admin.blade.php
|   |   ├── master-user.blade.php
|   ├── views
|   |   ├── home
|   |   ├── chat
|   |   ├── order
|   |   ├── reports
├── v2/
└── v3/

Save password for key login and no need to type again in Mac

Problem: When I try to establish an SSH connection with key, there are always have prompts for a password. And I don’t want to type the password on my personal PC again.

You can search how to save the password for key via ssh-agent

Solution: below the solution for macOS only. Enter below command:

ssh-add -K ~/.ssh/[your-private-key]

Then enter the password for the key file, so you won’t be asked for the password again.

Secured By miniOrange