Saturday, March 04, 2023

Alicloud CentOS 9 PHP 8.1 WordPress installation and related commands

 Manually deploy an LNMP environment on a CentOS 8 instance


Manually build a WordPress website on an ECS instance that runs CentOS 8


at the time of this blog, if you follow 


you will not be able to install php-imagick extension of PHP 8.1

So follow the next one, use remi-php 8.1, then you'll be able to install all extensions.



commands might be handy


vim /etc/php-fpm.d/www.conf

vim  /usr/local/nginx/conf/nginx.conf

vim conf/vhosts/www.wc668.com.conf

sudo php-fpm -t

sudo systemctl restart php-fpm

sudo systemctl restart nginx


 ps -eo user,group,args | grep "php-fpm"

 ps -eo user,group,args | grep "nginx"




Saturday, February 25, 2023

Moving from Oh-My-Zsh to Starship & Fish Shell | www.joshfinnie.com

Moving from Oh-My-Zsh to Starship & Fish Shell | www.joshfinnie.com

🔥 Save unlimited web pages along with a full PDF snapshot of each page.
Unlock Premium →

I have been using Zsh for almost a decade. I remember the day that I switched from the default shell Bash to ZSH. Powered by Oh-My-Zsh, my terminal was powerful and helpful. Add on top of that Oh-My-Zsh amazing templates; it was also pretty!

It was an amazing experience, and I recently had that experience again with Starship.rs. Switching to Starship.rs meant I broke up with Oh-My-Zsh, and thus Zsh. With everything back up in the air, I thought this would be a great time to try the Fish shell!

If you want to see why you should make this switch without reading all my specific setup, click here

Installing Starship.rs

Since I am on a Macbook Pro and already set up homebrew as my package manager, installing Starship.rs was easy. You need to install Starship.rs through Homebrew. Run the below command and get Fish installed as well!

$ brew install starship fish

With Starship installed, let's update the terminal a bit. Create a configuration file for Starship:

$ mkdir -p $HOME/.config  $ touch $HOME/.config/starship.toml

Feel free to read this documentation to customize your prompt how you like it. Here is a snippet of mine. It seems to work for me for now, but terminal prompts are so personal:

command_timeout = 10000    # Inserts a blank line between shell prompts  add_newline = true    ...    [cmd_duration]  min_time = 4  show_milliseconds = false  disabled = false  format = " 🕙 $duration($style) "  style = "bold italic #87A752"

Installing Fish

After completing the install through homebrew, jump into the fish terminal. Type fish and see that you can start using Fish right away. Note: You can always type exit to get back to your default shell. But we want a more permanent solution, below is how we add Fish to our available shells and set it as default:

$ echo /usr/local/bin/fish | sudo tee -a /etc/shells  $ chsh -s /usr/local/bin/fish

These commands mean you are officially using Fish as your shell.

Configuring Fish

No configuration needed: fish is designed to be ready to use immediately, without requiring extensive configuration.

On the homepage for Fish is the above quote. The shell prides itself on clear defaults and powerful built-in features. But I am a tinkerer and need to configuration Fish a bit. These are the steps I took to customize.

To facilitate the configuration of Fish, we need to create a config file. If you have done any customization of Zsh or Bash you are already familiar with this concept. Where we make these changes is a bit different. Let's create the file we need:

$ mkdir -p $HOME/.config/fish  $ echo "set -gx EDITOR emacs" >> $HOME/.config/fish/config.fish

The above commands make sure we have a folder to hold our Fish configuration and sets my EDITOR variable to emacs. The next major change we want to do to our Fish configuration file is tie in Starship.rs.

$ echo "starship init fish | source" >> $HOME/.config/fish/config.fish

And with that, we should be using our Starship prompt with Fish!

Fish Oddities

Using Fish comes with a few oddities that we'll have to deal with. The biggest difficulty when moving to Fish is the change in how aliases work.

With Zsh I set up some aliases to make my life easier:

# My Aliases    alias rm='rm -i'  alias cp='cp -i'  alias mv='mv -i'  alias mkdir='mkdir -p'  alias h='history'  alias which='type -a'  alias ..='cd ..'  alias ...='cd ../..'  alias ls='exa -lag --header'  alias edit='vim'  alias ccd='clear && cd'  alias killpyc='find . -name \*.pyc -delete'  alias tmux="tmux -2"  alias latex="docker run -v `pwd`:/tmp latex pdflatex"  alias exa="$HOME/.asdf/installs/rust/nightly/bin/exa"

The most important alias I want to cary over Fish is my ls alias which uses exa. I have fallen for exa, and seeing the normal ls is disappointing. Other aliases are better defaults, but will be helpful to have these in Fish too!

Fish has two different kinds of abbreviations. abbr is manages abbreviations - user-defined words that are replaced with longer phrases after they are entered. 1 alias is a simple wrapper for the function builtin, which creates a function wrapping a command.2 Since we are trying to mirror Zsh's aliases, we'll use Fish's abbr.

First, let's create a file to hold our abbreviations. Fish has a standard location for additional config files, so let's create that file and edit our abbreviations:

$ mkdir -p $HOME/.config/fish/conf.d/  $ touch $HOME/.cofig/fish/conf.d/abbr.fish

And fill it out:

abbr rm "rm -i"  abbr cp "cp -i"  abbr mv "mv -i"  abbr mkdir "mkdir -p"  abbr h "history"  abbr which "type -a"  abbr ls "exa -lag --header"

Once the abbreviations file is complete, we can add it to our Fish config file. Add source $HOME/.config/fish/conf.d/abbr.fish to the Fish config file. After reloading the config, we should be able to use our abbreviations.

To test it out, I ran ls in the $HOME/.config/fish/ folder and got this:

Permissions Size User       Group Date Modified Name  drwxr-xr-x     - joshfinnie staff  3 Apr 15:28  completions  drwxr-xr-x     - joshfinnie staff  3 Apr 16:19  conf.d  .rw-r--r--   181 joshfinnie staff  3 Apr 16:21  config.fish  .rw-r--r--  1.6k joshfinnie staff  3 Apr 16:19  fish_variables  drwxr-xr-x     - joshfinnie staff  3 Apr 15:28  functions

Super!

Another thing that is different in Fish than Zsh or Bash is how we set Environment Variables. With Zsh or Bash, we'd export a variable to set it globally. But in Fish, there is a different syntax that we will have to use.

Below is an example of setting up the FZF_DEFAULT_COMMAND in both Zsh and Fish. It's a small difference, but a noticeable one.

# Bash  export FZF_DEFAULT_COMMAND='ag -g "" --hidden --ignore .git'    # Fish  set -x FZF_DEFAULT_COMMAND 'ag -g "" --hidden --ignore .git'

I do not set many environment variables this way, but if you do this should be an easy update.

Benefits

Although changing shells can be overwhelming, there are some great benefits to using Fish.

  1. It is fast. I find interacting with Fish to be snappier than Zsh even when customized at the same level.
  2. It is much easier to customize. There are plenty of services like Oh-My-Zsh that work for Fish. Just to list a few, check out Fisher and Oh-My-Fish.
  3. There is an amazing ecosystem of functions. I will speak a bit more about functions below.
  4. Autocomplete and history search are next level. These are available for Zsh too, but Fish's autocomplete feels infinitely better.

Functions

I listed functions as one of the benefits of Fish. And I have to admit I have not used them to their full potential yet. But they are worthy of note.

Within Fish, you can define functions that can do powerful things. The function can iterate over files, or modify files based on boolean checks. Your creativity is the only limit Fish functions have. Below, I write and use a "Hello, World!" function for you to see:

$ function hello        echo Hello $argv!    end    $ hello  Hello    $ hello Josh  Hello Josh!

It is that easy. You can always see what functions are currently available by typing functions in the Fish shell.

Another option for you is to write and save function in files. Any file in your $fish_function_path will work as long as it ends with .fish. By default this path includes $HOME/.config/fish/functions which is where I'd recommend storing these files.

Per the documentation functions are best use as a stronger alias or abbreviation. So, as we aliased exa above, I'll also create a function for this command:

function lsa      exa -lag --header $argv  end

This function saved at $HOME/.config/fish/functions/lsa.fish will now allow me to use lsa. Doing so will trigger the above function and give me the same output as my abbreviated ls. This is nice as it does not expand the abbreviation like ls does. But miles might vary on the importance of that feature.

Note: you can also use the funcsave command that comes with Fish shell to save any functions you created. So we could save our hello function above by typing funcsave hello. This will write the function to your function folder automatically!

$ funcsave hello  funcsave: wrote $HOME/.config/fish/functions/hello.fish

Conclusion

This is a quick explanation of how I adopted Fish and Starship.rs for my terminal. I will be honest, I tried Fish five or so years ago and hated it. Let's see if my experience is better than last time. If you have used Starship.rs and Fish, let me know! Contact me on Twitter and I'd love to chat. So far it has been a nice change-of-pace.

Also Might Enjoy

Source: https://www.joshfinnie.com/blog/moving-from-oh-my-zsh-to-starship-and-fish-shell/
This web page was saved on Saturday, Feb 25 2023.

Upgrade to Premium Plan

✔ Save unlimited bookmarks.

✔ Get a complete PDF copy of each web page

✔ Save PDFs, DOCX files, images and Excel sheets as email attachments.

✔ Get priority support and access to latest features.

Upgrade now →

Monday, January 02, 2023

Controlling a garage door using 433 Mhz Remote

Controlling a garage door using 433 Mhz Remote

🔥 Save unlimited web pages along with a full PDF snapshot of each page.
Unlock Premium →

What if you could control your garage through the internet? A smartphone can come in handy.

If you have a motoric garage door, shades or burglar alarm sensors, it is very possible that these devices work with 315/433 MHz signals. Ozeki 10 can run on a Raspberry Pi 2 or 3, which fits in your palm and consumes less energy then a lightbulb. This guide describes how to connect a 433 MHz transmitter device to Ozeki and control your garage by broadcasting the same signals coming from your garage's remote. 2.4 GHz transceivers are supported by Ozeki 10 as well, but devices with short and simple commands use 315/433 MHz frequencies. For example on/off, up/down, move/stop and more. I am sure you love to read and build.

STEP 1: Check if your garage door uses 315 or 433 MHz

Mimic signals with Ozeki 10's high-tech solution. Most remote garage doors use 315 MHz or 433 MHz frequencies. Both are supported by Ozeki 10 with the correct hardware. You are lucky if you have safely kept the user's guide of your automatic garage door. Look around the pages to find the signal frequency. If you cannot find the guide, visit a car key copier. They can hopefully figure it out or you can go for sure with an RF Frequency Counter device. It does the job. You can order them online, but you can find them in electronic shops or ask your neighbour if you can borrow their RF counter.

mimic signals checking of your garage door
Figure 1 - Mimic signals checking of your garage door

STEP 2: Gather the components for an intelligent garage

Tune up your garage, to get it smarter then in a dream:

  • Raspberry Pi 2/3 (or Asus Tinker Board)
  • Arduino Nano, Uno or Mega
  • RF 315 or 433 MHz receiver, transmitter
  • breadboard (to build your first RF circuit on)
  • Jumper wires and a single USB cable
components of the intelligent garage controll
Figure 2 - Components of the intelligent garage control

STEP 3: The circuit diagram helps you

By looking below at the circuit diagram, you can figure out the connection. This is how you will be able to wire the radio controller. In the center of the control you can have a Raspberry Pi (or an Asus Tinker Board). A PC is not suggested since it consumes too much energy 24/7. To the main computer an Arduino is plugged, so it will control all radio modules through colorful jumper wires. The red wire powers the 5V and the black wire is the GND. Other colors can make difference between incoming and outgoing signals.

circuit diagram
Figure 3 - Circuit diagram

STEP 4: Build the circuit for real

Use a breadboard for building a test circuit, which will control your garage. Factory antennas are not perfect, but they look good. Use 17.3 cm long copper wires as antennas, which was perfectly calculated for the 433 MHz frequency. If the electronic circuit works through the guide, place the white board away and solder the parts on a printed ciruit board. Receiver's have two D0 pins, but only one white wire is necessary. This means you can leave out the other one below. Although it works with two wires as well.

the test breadboard setup
Figure 4 - The test breadboard setup

STEP 5: Download and install Ozeki on a Pi

Above, on the circuit diagram, look closer at the Pi. The Raspberry's HDMI socket is the best way to reach the GUI through any screen. Shops are full with HDMI to VGA or DVI converters to help you out. Power it up and watch the OS boot up with a perfectly designed GUI. Do not forget the keyboard, mouse and ethernet cable. Now start Chromium and open the download page: http://www.ozeki.hu/index.php?owpn=231 Select the debian package as below. Follow the guide on page 5986 for Pi ( or 6026 for Asus Board )

download ozeki 10 to raspberry
Figure 5 - Downloading Ozeki 10 for your Raspberry

STEP 6: Download Arduino development package

If you are quilified to upload Arduino codes through Linux, stay just where you are and download the IDE from https://www.arduino.cc or you can do it on a more familiar place, called Microsoft Windows. In this case unplug the USB and replug it to a Windows machine where you install Arduino IDE. All installers are fully integrated with the required drivers. This green surface leads your codes through USB serial technology, which fills up the flash memory of each ATmega. It is the main chip powering every Arduino.

downloading the arduino development package
Figure 6 - Downloading the arduino development package

STEP 7: Please format the EEPROM

The Ozeki codes have a special ability. They use the EEPROM to store highly important ID's that can differentiate all Ozeki devices and this is how Ozeki 10 can detect them. For an Ozeki microcontroller code to work, it is highly advised to wipe the EEPROM and after that jump to STEP 8. You can find the EEPROM cleaner code on http://www.ozeki.hu/index.php?owpn=3110 No other program should use the COM port when uploading. Open the serial monitor to see if the EEPROM was formatted successfully.

formating the eeprom
Figure 7 - Formating the EEPROM

STEP 8: Upload the Arduino RF transceiver code

http://www.ozeki.hu/attachments/5952/RF_transceiver_code.txt (copy)
This code can manage both 315 and 433 MHz frequencies for both receiving and transmitting signals. It is not suggested to modify the Arduino pins that are tested daily at Ozeki Ltd. To get all required libraries, you have to download Ozeki 10 for Windows too. After saving or writing down the remote controller signals, you will not need the receiver circuit and codes, unless you would like to use Ozeki for receiving other RF signals as well.

upload the arduino rf transceiver code
Figure 8 - Upload the Arduino RF transceiver code

STEP 9: Start the Control Panel

Finally the code is on the ATmega chip, so please replug the Arduino to your Raspberry ( or Asus Tinker Board ). The Ozeki 10 installed on one of these boards will detect it. Go back to the browser and open your Ozeki 10 GUI with the server IP and port 9505. Please login with the same admin credentials provided during the installation of the debian package. The screenshot below will be the next place you will find yourself. Click on the red Napoleon icon to open the 'Control Panel'. It manages connections.

start the control panel
Figure 6 - Start the control panel

STEP 10: Click on the RF Transceiver connection

In this case the connection is the MyRF433 transceiver device. It is great that you can install multiple devices on a single Arduino, but now only a single device controls both modules. The device is called MyRF433, which is the device name of the uploaded code. It appears in the connections list as a single row. On the left side a green dot shows if it is available. By hovering the mouse over the question mark, you can read about the device. Please click on the 'Details' button, which you can find on the right side.

click on the rf transceiver connection
Figure 7 - Click on the RF Transceiver connection

STEP 11: Receive signals from garage remote

This is the test surface of your transceiver. Now you are able to receive any RF signal from your remote controller, so please take the remote in your hand and press the garage opening button. Press the button again to close your garage. The signals will appear on the screen while your door moves.

receive signals
Figure 8 - Click on the RF Transceiver connection

STEP 12: Open and close garage from Ozeki GUI

Bring the RF transceiver circuit closer to your garage. Copy paste the signals and click the blue 'Send' button to transmit them over the antenna. Your garage should open and close as you see the transmission below. The 'Chat' GUI was used in STEP 11 and 12. You can chat with connections.

open and close garage for ozeki gui
Figure 9 - Open and close garage for Ozeki GUI

The technology can be used in an efficient manner

Control the garage from your smartphone browser

Easily reach your garage from the beach or the mountains. Please start your webbrowser and type your Ozeki server's IP and port number 9505. You can find the IP by typing 'ifconfig' in your Raspbian or TinkerOS. Log in and start the 'Control Panel' as you can see it below. Find the transceiver on the connection list to be in control of all RF device in your home or office.

ozeki control panel on android
Figure 9 - Ozeki control panel on Android

Build a 433 MHz RF transceiver box

The black plastic box contains the same circuit that you have built, although the pins are soldered together. This small construction can be comfortably placed into this small box, which was printed by a 3D printer running Ozeki 10 OS. This compact device can fit in your palm, but takes control over your RF electronic devices to create a smart home or it can collect data as well.

ozeki control panel on android
Figure 10 - Ozeki control panel on Android

How to make the radio range wider

Search for RF devices in your home, which work on 315/433 MHz frequencies. It is good to know that for 315 MHz the proper antenna length is 23.8 cm, but for the 433 MHz frequency it is 17.3 cm. Use a simple copper wire instead of the beautiful factory spiral antennas. This should ensure a wider antenna range. You can find the end of the range by placing an RF controlled object further until it cannot be reached.

More information

Source: https://ozeki.hu/p_5952-controlling-a-garage-door-using-433-mhz-remote.html
This web page was saved on Sunday, Jan 01 2023.

Upgrade to Premium Plan

✔ Save unlimited bookmarks.

✔ Get a complete PDF copy of each web page

✔ Save PDFs, DOCX files, images and Excel sheets as email attachments.

✔ Get priority support and access to latest features.

Upgrade now →