SpeedUp Composer (PHP)

This is a note of the way to speed up composer install.

Use mirror

If you live Asia or South America, use composer mirror.

https://packagist.org/mirrors

This is an example of setting when using Japanese mirror.

1
$ composer config -g repos.packagist composer https://packagist.jp

Use prestissimo

prestissimo is composer parallel install plugin.

1
$ composer global require hirak/prestissimo

Initial Server Setting of Ubuntu 18.04 - DigitalOcean

This is a note of the Ubuntu 18.04 server setup procedure.

I referred to Initial Server Setup with Ubuntu 18.04 .

SSH Login

1
$ ssh -i {YOUR_PRIVATE_KEY} root@{SERVER_IP_ADDRESS}

Basic Settings

Do the following with root.

update libraries by apt-get

1
2
# apt-get update
# apt-get dist-upgrade

reboot

After apt-get dist-upgrade, you need to reboot servers.

1
# reboot

SSH Settings for security

1
# vi /etc/ssh/sshd_config

Edit the following. Change port number of ssh.

1
2
PasswordAuthentication no
Port {SSH_PORT_NUMBER} ( 1024 to 65535 )

Restart sshd.

1
# service ssh restart

Check whether the SSH port number has been changed.

1
# lsof -i:{SSH_PORT_NUMBER}

Setting of ufw

Allow connections to port numbers set in / etc / ssh / sshd_config on ufw.

1
# vi /etc/ufw/applications.d/openssh-server

Change the “port number” on the last line.

1
2
3
4
[OpenSSH]
title=Secure shell server, an rshd replacement
description=OpenSSH is a free implementation of the Secure Shell protocol.
ports={SSH_PORT_NUMBER}/tcp

Enable ufw.

1
2
3
4
# ufw app list
# ufw allow OpenSSH
# ufw enable
# ufw status

Add user

1
# adduser {USER_NAME}

Enable added user to run sudo.

1
$ usermod -aG sudo {USER_NAME}

Add authorized_keys to the user.

1
2
3
4
5
$ cd
$ mkdir .ssh
$ chmod 700 .ssh
$ vi .ssh/authorized_keys # Paste authorized_keys
$ chmod 600 .ssh/authorized_keys

Disable ssh login with root.

1
$ vi /etc/ssh/sshd_config

PermitRootLogin * no .

1
PermitRootLogin no

Restart sshd.

1
$ sudo service ssh restart

Cloud Firewalls

On the Cloud Firewalls, you can only SSH login with SSH port number changed this time.

Initial Server Setting of CentOS 7 - DigitalOcean

This is a note of the CentOS 7 server setup procedure.

I referred to Initial Server Setup with CentOS 7 (Digitalocean) .

SSH Login

1
$ ssh -i {YOUR_PRIVATE_KEY} root@{SERVER_IP_ADDRESS}

Basic Settings

Do the following with root.

yum upddate

1
# yum update

reboot

After yum update, you need to reboot servers.

1
# reboot

Settings of SeLinux

Allow connections to port numbers set in / etc / ssh / sshd_config on selinux.

1
# semanage port -a -t ssh_port_t -p tcp {SSH_PORT_NUMBER}

SSH Settings for security

1
# vi /etc/ssh/sshd_config

Edit the following. Change port number of ssh.

1
2
PasswordAuthentication no
Port {SSH_PORT_NUMBER} ( 1024 to 65535 )

Restart sshd.

1
# systemctl restart sshd.service

Check whether the SSH port number has been changed.

1
# netstat -an | grep LISTEN | grep {SSH_PORT_NUMBER}

Add user

1
2
# useradd {USER_NAME}
# passwd {USER_NAME}

Enable added user to run sudo.

1
# usermod -aG wheel {USER_NAME}

Change user.

1
# su {USER_NAME}

Add authorized_keys to the user.

1
2
3
4
5
$ cd
$ mkdir .ssh
$ chmod 700 .ssh
$ vi .ssh/authorized_keys # Paste authorized_keys
$ chmod 600 .ssh/authorized_keys

Disable ssh login with root.

1
$ sudo vi /etc/ssh/sshd_config

PermitRootLogin : no .

1
PermitRootLogin no

Restart sshd

1
$ sudo systemctl restart sshd.service

Cloud Firewalls

On the Cloud Firewalls, you can only SSH login with SSH port number changed this time.

Install JVM Languages (Java, kotlin, etc...) with SDKMAN on macOS

This is a note on how to install JVM Languages (Java, kotlin, etc…) with SDKMAN on macOS and how to use it.
SDKMAN is a tool for managing parallel versions of multiple Software Development Kits ( Mainly JVM Languages ) on most Unix based systems.
It is easy-to-use on macOS.

Install SDKMAN

1
2
$ curl -s "https://get.sdkman.io" | bash
$ source "$HOME/.sdkman/bin/sdkman-init.sh"

By default it will be installed under ~ / .sdkman / .

Detail is SDKMAN install page .

How to use SDKMAN

Detail is

Example

JVM Languages

1
2
3
$ sdk install java
$ sdk install kotlin
$ sdk install scala

Frameworks

1
$ sdk install springboot

How to convert HEIC to JPEG on macOS

If you take a photo on iPhone and save it on your Mac, I think that the extension of the picture file is heic, not png or jpeg.
To convert heic to jpeg in such a case, use iMazing HEIC Converter or the following command in macOS.

1
2
3
$ cd PHOTO_DIR

$ sips --setProperty format jpeg *.HEIC --out ./

Command line and GUI image compression tools on macOS

GUI or commandline tools that converts image formats and compresses on Mac. Use it to reduce the size of the image.

GUI tool

ImageOptim is an easy-to-use GUI tool is a GUI tool for compressing image. This tool can compress all the images contained in the folder at once. But, processing may take a while.

Commandline tools

Commandline tools are easy-to-use and speedy to compress or convert images, if you are familiar with the command line.

Compress png images

pngquant is good tool.

Install pngquant

1
$ brew install pngquant

How to use pngquant

Compress and save it as a another file leaving the original image
1
2
$ pngquant image.png
$ pngquant dir/*.png
Compress and overwrite the original image
1
2
$ pngquant --ext .png --force image.png
$ pngquant --ext .png --force dir/*.png
Other option

For other detailed options refer to the official website : pngquant.

Compress jpeg images

jpegoptim is good tool.

Install jpegoptim

1
$ brew install jpegoptim

How to use pngquant

Compress and save it as a another file leaving the original image
1
2
$ jpegoptim fff.jpeg
$ jpegoptim dir/*.jpeg
Compress and overwrite the original image
1
2
$ jpegoptim --ext .png --force image.png
$ jpegoptim --ext .png --force dir/*.png

To erase all the meta data (location,date,etc…) contained in jpeg and compress it and save it, use the -s option.

1
$ jpegoptim -s image.jpeg
Other option

For other detailed options refer to the --help option.

1
$ jpegoptim --help
Other tools to compress jpg images

There are other tools such as Guetzli and Mozjpeg, so it may be good to use it.Both tools can be installed with brew command.

1
2
$ brew install guetzli
$ brew install mozjpeg

webp に変換

For images in jpg or png format, converting the format to WebP is often the smallest size.

Install webp

1
$ brew install webp

How to use webp

1
$ cwebp image.png -o image.webp
Other option
1
$ cwebp -longhelp

Install Go with goenv at macOS

This is a note on how to install goenv on macOS and how to use it.

1. Install goenv

Install goenv.

1
$ git clone https://github.com/syndbg/goenv.git ~/.goenv

Add the following to .bash_profile

1
2
3
4
# goenv
export GOENV_ROOT="$HOME/.goenv"
export PATH="$GOENV_ROOT/bin:$PATH"
eval "$(goenv init -)"

Load .bash_profile in shell

1
$ source .bash_profile

2. How to Use goenv ( Install and manage Go )

How to check which version you can use

1
$ goenv install -l

How to check which version you insatlled

1
$ goenv versions

How to install the specified version of Go

1
$ goenv install 1.10.3

Run this command after you install a new version of Go

1
$ goenv rehash

How to use the specified version of Go at global

1
$ goenv global 1.10.3

How to use the specified version of Go at local ( directory ).

1
$ goenv local 1.10.3

This command will create .go-version file at current directory.

3. How to use dep

dep is package manager of golang.

1
$ go get -u github.com/golang/dep/cmd/dep

4. How to Update goenv

1
2
$ cd $(goenv root)
$ git pull

Install PHP with phpenv on macOS

This is a note on how to install phpenv on mac and how to use it.

1. Install phpenv

Install phpenv

1
$ git clone https://github.com/madumlao/phpenv.git ~/.phpenv

Install php-build to build php

1
$ git clone https://github.com/php-build/php-build.git ~/.phpenv/plugins/php-build

Install libraries to build php

1
$ brew install re2c openssl bison libxml2 autoconf automake icu4c libjpeg libpng libmcrypt libzip

If Mojave

1
$ sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /

Homebrew is needed

Add the following to .bash_profile

1
2
3
4
5
# phpenv
export PATH="/usr/local/opt/bison/bin:$PATH"
export PHPENV_ROOT="$HOME/.phpenv"
export PATH="$PHPENV_ROOT/bin:$PATH"
eval "$(phpenv init -)"

Load .bash_profile in shell

1
$ source .bash_profile

2. How to Use phpenv ( Install and manage PHP )

How to check which version you can use.

1
$ phpenv install -l

How to check which version you insatlled.

1
$ phpenv versions

How to install the specified version of PHP.

1
$ phpenv install 7.3.7

Run this command after you install a new version of PHP

1
$ phpenv rehash

How to use the specified version of PHP at global.

1
$ phpenv global 7.3.7

How to use the specified version of PHP at local ( directory ).

1
$ phpenv local 7.3.7

This command will create .php-version file at current directory.

3. How to use composer

Install composer to phpenv

1
2
$ git clone https://github.com/ngyuki/phpenv-composer.git ~/.phpenv/plugins/phpenv-composer
$ phpenv rehash

4. How to Update phpenv

1
2
$ cd $(phpenv root)
$ git pull

5. How to Update php-build

When a new version of PHP is released, you need to update php-build. Otherwise you can not install the new version of PHP.

1
2
$ cd $(phpenv root)/plugins/php-build
$ git pull

Install Python with pyenv on macOS

This is a note on how to install pyenv on macOS and how to use it.

1. Install pyenv

Install pyenv.

1
$ git clone https://github.com/pyenv/pyenv.git ~/.pyenv

Add the following to .bash_profile

1
2
3
4
# pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"

Load .bash_profile in shell

1
$ source .bash_profile

2. How to Use pyenv ( Install and manage Python )

How to check which version you can use

1
$ pyenv install -l

How to check which version you insatlled

1
$ pyenv versions

How to install the specified version of PHP

1
$ pyenv install 3.6.3

Run this command after you install a new version of Python

1
$ pyenv rehash

How to use the specified version of Python at global

1
$ pyenv global 2.7.14

How to use the specified version of Python at local ( directory ).

1
$ pyenv local 2.7.14

This command will create .python-version file at current directory.

3. How to use pip

You can use pip.
When you install pip packages global ( pip install *** ), the gem packages will installed at current version of python directory)( example: ./.pyenv/versions/2.7.14/lib/python2.7/site-packages/ ).
So, you shuld use pyenv rehash command after install pip packages at global.
I think this is safe because the pip packages installed global is related Python version.

example.

1
2
$ pyenv install ansible
$ pyenv rehash

4. How to Update pyenv

When a new version of Python is released, you need to update.

1
2
$ cd $(pyenv root)
$ git pull