Saturday, March 23, 2019

CREATE A LEMP STACK IN AWS EC2 by Amazon Linux 2 (LINUX, NGINX, MARIADB AND PHP 7.2)

Launch Instance: latest Amazon Linux 2 AMI



# Update Linux and install essential packages
sudo yum -y update

# Install php72 using amazon-linux-extras
sudo amazon-linux-extras install php7.2

# Install Nginx 1.12 using amazon-linux-extras
sudo amazon-linux-extras install nginx1.12

# Install mariadb using amazon-linux-extras
sudo amazon-linux-extras install lamp-mariadb10.2-php7.2
## this will install apache/httpd as well, which we don't need.
### uninstall httpd
sudo yum earse httpd httpd-tools
# install mariadb-server should be version 10.2 or higher
sudo yum install mariadb-server
To enable nginx, php-fpm and mardb services on boot:
sudo systemctl enable nginx
sudo systemctl enable php-fpm
sudo systemctl enable mariadb
To start all 3 service:
sudo systemctl start php-fpm
sudo systemctl start nginx
sudo systemctl start mariadb
sudo mysql_secure_installation

Amazon Linux 2 add fail2ban from epel

Amazon Linux team did a great work to make it easy and clean at same time.

 The epel repo is no longer enable by default like the olden days.

This keep the rpm packages as slim as possible.

To enable epel, just one command:

# sudo amazon-linux-extras install epel
# sudo yum update
# sudo yum install fail2ban

Friday, March 22, 2019

Amazon Linux 2 Systemctl commands timeout - systemd issue

A long live AWS EC2 vm gave me this when I try to check the httpd running status:
systemctl status httpd
Failed to get properties: Connection timed out
According google search: https://serverfault.com/questions/712928/systemctl-commands-timeout-when-ran-as-root I tried both:
kill -9 1
systemctl daemon-reexec
None of them works. The [reboot] only flack a bit and kick me out of system but did not really reboot. I have to run:
systemctl --force --force reboot
To force it reboot. Love systemd!

Sunday, March 10, 2019

How to reset check_mk admin password

My Windows 10 Laptop just crashed after latest Intel patch upgrade.

Forgot to save the admin password on one of the latest check_mk site I built.
su - mysite

cd etc

ls -l htpasswd

OMD[mysite]:~/etc$ ls -l htpasswd
Example: check_mk version 1.4:
lambert:!$1$042926$lmAEb.P5TAi0sZfiGyWHX.
omdadmin:M29dfyFjgy5iA
check_mk version 1.5:
automation:$1$857531$PzhNz/zMdQv8xGu68EZhD.
cmkadmin:$1$386620$Xe5mZKwrPRlzx0BvZCJM8.
htpasswd htpasswd omdadmin          # set password for user *omdadmin*

New password: 

Re-type new password:
You should be good! Have a nice day!

Monday, February 25, 2019

recommend Script to remove Windows 10 bloatware

Recommend a great Script to remove Windows 10 bloatware.

You can find it here:

https://github.com/Sycnex/Windows10Debloater

Just download the zip and run in PowerShell by right click: Windows10Debloater.ps1
If you like GUI: Windows10DebloaterGUI.ps1

PS:
  1. Appreciate Richard Newton's great work.
  2. I did not run white list, because I do not want anything except the 'Core Windows 10'.
  3. If you really really need keep some Windows 10 bloatware, please run Windows10SysPrepDebloater.ps1 before you start the main .PowerShell script.
  4. The only one I may keep is the Mail which crashed every time I check the Gmail folders.
  5. I sill using Windows 10 as my Main working OS and Outlook as my Main Email client. But not a fan of any bloatware.

Tuesday, December 11, 2018

git pull: Unable to create ORIG_HEAD.lock No space left on device

# git pull
fatal: Unable to create '/mds/mds/.git/ORIG_HEAD.lock': No space left on device

# df -h .
Filesystem                                              Size  Used Avail Use% Mounted on
/dev/disk/by-uuid/b1358fbb-dab1-482d-ab22-fa2523975c2e   16G   11G  3.9G  74% /

# df -i .
Filesystem                                              Inodes   IUsed  IFree IUse% Mounted on
/dev/disk/by-uuid/b1358fbb-dab1-482d-ab22-fa2523975c2e 1003680 1003680      0  100% /
It just to many small log files in the folder. To quick delete them:
cd yourdirectory
perl -e 'for(<*>){((stat)[9]<(unlink))}'
Reference & Thanks: https://stackoverflow.com/questions/24895502/git-pull-unable-to-create-orig-head-lock-no-space-left-on-device/25002467 https://unix.stackexchange.com/questions/37329/efficiently-delete-large-directory-containing-thousands-of-files

Friday, October 12, 2018

Install abiword on Amazon Linux 2

In Amazon Linux 2, there is no full version of Abiword. But abiword library and convert tools are available, if you can live with it.
libabw.x86_64 : A library for import of AbiWord files
libabw-tools.x86_64 : Tools to transform AbiWord files into other formats
However my client running a python/django website using webodt package to convert word documents to html and txt.
The [libabw-tools] package has 2 tools for this kind of work.
/usr/bin/abw2html
/usr/bin/abw2text

But I won't rewrite the code. I install abiword 3.0.2 for EL7 from http://repo.iotti.biz/CentOS/.
rpm -Uvh http://repo.iotti.biz/CentOS/7/noarch/lux-release-7-1.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-LUX
Have to update the repo files before update. /etc/yum.repos.d/lux.repo
[lux]
name=CentOS $releasever - $basearch - Lux
baseurl=http://repo.iotti.biz/CentOS/$releasever
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LUX
Because the $releasever = 2 in Amazon Linux 2, just change it To 7 in the file.
[lux]
name=CentOS $releasever - $basearch - Lux
baseurl=http://repo.iotti.biz/CentOS/7
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LUX
Same /etc/yum.repos.d/frank.repo
[frank]
name=CentOS $releasever - $basearch - Frank
baseurl=http://repo.iotti.biz/Frank/$releasever
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LUX
# Frank should be manually enabled
enabled=0
# Frank packages should be explicitly included with includepkgs
exclude=*
To:
[frank]
name=CentOS $releasever - $basearch - Frank
baseurl=http://repo.iotti.biz/Frank/7
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-LUX
# Frank should be manually enabled
enabled=0
# Frank packages should be explicitly included with includepkgs
exclude=*
Then you can update and install via yum:
yum update
yum install abiword
Dependencies Resolved

=======================================================================================================================================================================
 Package                                         Arch                         Version                                           Repository                        Size
=======================================================================================================================================================================
Installing:
 abiword                                         x86_64                       1:3.0.2-3.el7.lux                                 lux                              1.3 M
Installing for dependencies:
 adwaita-cursor-theme                            noarch                       3.26.0-1.amzn2                                    amzn2-core                       641 k
 adwaita-icon-theme                              noarch                       3.26.0-1.amzn2                                    amzn2-core                        12 M
 aiksaurus                                       x86_64                       1:1.2.1-34.el7.lux                                lux                              324 k
 at-spi2-atk                                     x86_64                       2.22.0-2.amzn2.0.2                                amzn2-core                        81 k
 at-spi2-core                                    x86_64                       2.22.0-1.amzn2.0.2                                amzn2-core                       159 k
 atk                                             x86_64                       2.22.0-3.amzn2.0.2                                amzn2-core                       258 k
 avahi-libs                                      x86_64                       0.6.31-19.amzn2                                   amzn2-core                        62 k
 cairo                                           x86_64                       1.14.8-2.amzn2.0.2                                amzn2-core                       718 k
 cairo-gobject                                   x86_64                       1.14.8-2.amzn2.0.2                                amzn2-core                        25 k
 colord-libs                                     x86_64                       1.3.4-1.amzn2.0.2                                 amzn2-core                       186 k
 cups-libs                                       x86_64                       1:1.6.3-35.amzn2                                  amzn2-core                       360 k
 dbus-glib                                       x86_64                       0.100-7.2.amzn2                                   amzn2-core                       103 k
 dconf                                           x86_64                       0.26.0-2.amzn2.0.2                                amzn2-core                       106 k
 desktop-file-utils                              x86_64                       0.23-1.amzn2.0.2                                  amzn2-core                        68 k
 enchant                                         x86_64                       1:1.6.0-8.amzn2.0.2                               amzn2-core                        55 k
 fontconfig                                      x86_64                       2.10.95-11.amzn2.0.2                              amzn2-core                       231 k
 fontpackages-filesystem                         noarch                       1.44-8.amzn2                                      amzn2-core                        10 k
 fribidi                                         x86_64                       0.19.4-6.amzn2.0.2                                amzn2-core                        63 k
 gdk-pixbuf2                                     x86_64                       2.36.5-1.amzn2.0.2                                amzn2-core                       567 k
 glib-networking                                 x86_64                       2.50.0-1.amzn2.0.2                                amzn2-core                       132 k
 gnutls                                          x86_64                       3.3.26-9.amzn2.0.2                                amzn2-core                       670 k
 graphite2                                       x86_64                       1.3.10-1.amzn2.0.2                                amzn2-core                       115 k
 gsettings-desktop-schemas                       x86_64                       3.24.1-2.amzn2                                    amzn2-core                       586 k
 gtk-update-icon-cache                           x86_64                       3.22.26-4.amzn2                                   amzn2-core                        27 k
 gtk2                                            x86_64                       2.24.31-1.amzn2.0.2                               amzn2-core                       3.4 M
 gtk3                                            x86_64                       3.22.26-4.amzn2                                   amzn2-core                       4.4 M
 gtkmathview                                     x86_64                       0.8.0-16.el7.lux                                  lux                              628 k
 harfbuzz                                        x86_64                       1.3.2-1.amzn2.0.2                                 amzn2-core                       181 k
 hicolor-icon-theme                              noarch                       0.12-7.amzn2                                      amzn2-core                        43 k
 jasper-libs                                     x86_64                       1.900.1-31.amzn2.0.2                              amzn2-core                       149 k
 json-glib                                       x86_64                       1.2.6-1.amzn2.0.2                                 amzn2-core                       134 k
 lcms2                                           x86_64                       2.6-3.amzn2.0.2                                   amzn2-core                       152 k
 libX11                                          x86_64                       1.6.5-1.amzn2.0.2                                 amzn2-core                       614 k
 libX11-common                                   noarch                       1.6.5-1.amzn2.0.2                                 amzn2-core                       164 k
 libXau                                          x86_64                       1.0.8-2.1.amzn2.0.2                               amzn2-core                        29 k
 libXcomposite                                   x86_64                       0.4.4-4.1.amzn2.0.2                               amzn2-core                        22 k
 libXcursor                                      x86_64                       1.1.14-8.amzn2.0.2                                amzn2-core                        30 k
 libXdamage                                      x86_64                       1.1.4-4.1.amzn2.0.2                               amzn2-core                        20 k
 libXext                                         x86_64                       1.3.3-3.amzn2.0.2                                 amzn2-core                        39 k
 libXfixes                                       x86_64                       5.0.3-1.amzn2.0.2                                 amzn2-core                        18 k
 libXfont                                        x86_64                       1.5.2-1.amzn2.0.2                                 amzn2-core                       152 k
 libXft                                          x86_64                       2.3.2-2.amzn2.0.2                                 amzn2-core                        60 k
 libXi                                           x86_64                       1.7.9-1.amzn2.0.2                                 amzn2-core                        41 k
 libXinerama                                     x86_64                       1.1.3-2.1.amzn2.0.2                               amzn2-core                        14 k
 libXrandr                                       x86_64                       1.5.1-2.amzn2.0.2                                 amzn2-core                        27 k
 libXrender                                      x86_64                       0.9.10-1.amzn2.0.2                                amzn2-core                        26 k
 libXtst                                         x86_64                       1.2.3-1.amzn2.0.2                                 amzn2-core                        20 k
 libXxf86vm                                      x86_64                       1.1.4-1.amzn2.0.2                                 amzn2-core                        17 k
 libabiword                                      x86_64                       1:3.0.2-3.el7.lux                                 lux                              5.2 M
 libasyncns                                      x86_64                       0.8-7.amzn2.0.2                                   amzn2-core                        26 k
 libepoxy                                        x86_64                       1.3.1-2.amzn2                                     amzn2-core                       198 k
 libfontenc                                      x86_64                       1.1.3-3.amzn2.0.2                                 amzn2-core                        31 k
 libglvnd                                        x86_64                       1:1.0.0-1.amzn2.0.2                               amzn2-core                        89 k
 libglvnd-egl                                    x86_64                       1:1.0.0-1.amzn2.0.2                               amzn2-core                        43 k
 libglvnd-glx                                    x86_64                       1:1.0.0-1.amzn2.0.2                               amzn2-core                       124 k
 libgsf                                          x86_64                       1.14.26-7.amzn2.0.2                               amzn2-core                       165 k
 libgusb                                         x86_64                       0.2.9-1.amzn2.0.2                                 amzn2-core                        40 k
 libical                                         x86_64                       1.0.1-1.amzn2.0.2                                 amzn2-core                       175 k
 libmodman                                       x86_64                       2.0.1-8.amzn2.0.2                                 amzn2-core                        29 k
 libpng                                          x86_64                       2:1.5.13-7.amzn2.0.2                              amzn2-core                       214 k
 libproxy                                        x86_64                       0.4.11-10.amzn2.0.3                               amzn2-core                        61 k
 librsvg2                                        x86_64                       2.40.16-1.amzn2.0.2                               amzn2-core                       129 k
 libsoup                                         x86_64                       2.56.0-6.amzn2                                    amzn2-core                       401 k
 libthai                                         x86_64                       0.1.14-9.amzn2.0.2                                amzn2-core                       187 k
 libusbx                                         x86_64                       1.0.21-1.amzn2                                    amzn2-core                        62 k
 libwayland-client                               x86_64                       1.14.0-2.amzn2.0.1                                amzn2-core                        32 k
 libwayland-cursor                               x86_64                       1.14.0-2.amzn2.0.1                                amzn2-core                        20 k
 libwayland-server                               x86_64                       1.14.0-2.amzn2.0.1                                amzn2-core                        38 k
 libwmf                                          x86_64                       0.2.8.4-41.amzn2.0.2                              amzn2-core                       136 k
 libwmf-lite                                     x86_64                       0.2.8.4-41.amzn2.0.2                              amzn2-core                        68 k
 libxcb                                          x86_64                       1.12-1.amzn2.0.2                                  amzn2-core                       216 k
 libxkbcommon                                    x86_64                       0.7.1-1.amzn2.0.2                                 amzn2-core                       109 k
 libxshmfence                                    x86_64                       1.2-1.amzn2.0.2                                   amzn2-core                       7.2 k
 link-grammar                                    x86_64                       5.3.14-1.el7.lux                                  lux                              2.1 M
 loudmouth                                       x86_64                       1.5.3-1.el7.lux                                   lux                               71 k
 lyx-fonts                                       noarch                       2.2.3-1.el7                                       epel                             159 k
 mesa-libEGL                                     x86_64                       17.2.3-8.20171019.amzn2.0.4                       amzn2-core                       100 k
 mesa-libGL                                      x86_64                       17.2.3-8.20171019.amzn2.0.4                       amzn2-core                       159 k
 mesa-libgbm                                     x86_64                       17.2.3-8.20171019.amzn2.0.4                       amzn2-core                        37 k
 mesa-libglapi                                   x86_64                       17.2.3-8.20171019.amzn2.0.4                       amzn2-core                        43 k
 mesa-libwayland-egl                             x86_64                       17.2.3-8.20171019.amzn2.0.4                       amzn2-core                        18 k
 minisat2-libs                                   x86_64                       2.2.1-1.el7.lux                                   lux                               43 k
 nettle                                          x86_64                       2.7.1-8.amzn2.0.2                                 amzn2-core                       329 k
 ots-libs                                        x86_64                       0.5.0-12.el7.lux                                  lux                               46 k
 pango                                           x86_64                       1.40.4-1.amzn2.0.2                                amzn2-core                       276 k
 pangox-compat                                   x86_64                       0.0.2-2.el7                                       epel                              56 k
 pixman                                          x86_64                       0.34.0-1.amzn2.0.2                                amzn2-core                       254 k
 rest                                            x86_64                       0.8.0-2.amzn2                                     amzn2-core                        63 k
 t1lib                                           x86_64                       5.1.2-14.amzn2.0.2                                amzn2-core                       168 k
 telepathy-glib                                  x86_64                       0.24.0-1.amzn2.0.2                                amzn2-core                       725 k
 trousers                                        x86_64                       0.3.14-2.amzn2.0.2                                amzn2-core                       294 k
 urw-fonts                                       noarch                       2.4-16.amzn2                                      amzn2-core                       3.0 M
 wv                                              x86_64                       1.2.9-10.el7.lux                                  lux                              259 k
 xkeyboard-config                                noarch                       2.20-1.amzn2                                      amzn2-core                       799 k
 xorg-x11-font-utils                             x86_64                       1:7.5-20.amzn2.0.2                                amzn2-core                        87 k

Transaction Summary
=======================================================================================================================================================================
Install  1 Package (+95 Dependent packages)

Total download size: 46 M
Installed size: 147 M
Have a nice worm day!