Ubuntu 管理心得

搜尋此網誌

2023年3月18日 星期六

Install phpmyadmin on pi raspbian bullseye

 cf: http://linux.how2shout.com/how-to-install-phpmyadmin-on-debian-11-bullseye-apache/

  1. sudo apt -y install php-cgi php-mysqli php-pear php-mbstring libapache2-mod-php php-common php-phpseclib php-mysql
  2. wget https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.gz
  3. sudo tar xvf phpMyAdmin-latest-all-languages.tar.gz
  4. sudo mv phpMyAdmin-*-all-languages/ /var/www/html/phpmyadmin
  5. cd /var/www/html
    sudo cp phpmyadmin/config.sample.inc.php phpmyadmin/config.inc.php
  6. sudo mkdir /var/www/html/phpmyadmin/tmp
  7. openssl rand -base64 32
    (copy the output key)
  8. sudo vim /var/www/html/phpmyadmin/config.inc.php
  9. Put the key in Step 6 into:
    $cfg[‘blowfish_secret’] = ‘your-key‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
  10. And add this line:
    $cfg['TempDir'] = '/var/www/html/phpmyadmin/tmp';
  11. sudo chown -R www-data:www-data /var/www/html/phpmyadmin
  12. sudo vim /etc/apache2/conf-available/phpmyadmin.conf
  13. Add the followings:
    Alias /phpmyadmin /var/www/html/phpmyadmin

    <Directory /var/www/html/phpmyadmin/>
       AddDefaultCharset UTF-8
       <IfModule mod_authz_core.c>
              <RequireAny>
          Require all granted
         </RequireAny>
       </IfModule>
    </Directory>

    <Directory /var/www/html/phpmyadmin/setup/>
       <IfModule mod_authz_core.c>
         <RequireAny>
           Require all granted
         </RequireAny>
       </IfModule>
    </Directory>
  14. sudo a2enconf phpmyadmin.conf
  15. sudo systemctl restart apache2

php stuff in pi4

  1. sudo apt purge php*
  2. sudo apt install php8.0
  3. sudo apt install php8.0-mysql
    sudo apt install php8.0-dom
    sudo apt install php8.0-mbstring
    sudo apt install php8.0-fpm
    sudo apt install php8.0-pear
    sudo apt install php-pear

2023年3月8日 星期三

Clone drupaldam to pi4

  1. Open Backup and Migration in http://kpcp4.au.edu.tw/~chiao/drupaldam/dam/web/. Backup all tables and save it as backup_kpci7_drupaldam.sql.gz
  2. gzip -d backup_kpci7_drupaldam.sql.gz > backup_kpci7_drupaldam.sql
  3. sed 's/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g' backup_kpci7_drupaldam.sql > backup_kpci7_drupaldam_unicode.sql
  4. Open Backup and Migration in https://192.168.1.14/~chiao/drupaldam/dam/web/. Restore as with the file backup_kpci7_drupaldam_unicode.sql
  5. Done.
     

2023年2月27日 星期一

After certbot installed and renew

cf: https://pimylifeup.com/raspberry-pi-ssl-lets-encrypt/

Some settings about firewall:

  1. sudo vim /etc/arno-iptables-firewall/conf.d/00debconf.conf,
    add 443 for OPEN_TCP and OPEN_UDP
  2. Add 443 port forward in wifi web page
  3. Two more things:
    sudo a2enmod ssl
    sudo a2ensite default-ssl
  4. If it can be connected but shows secure error try this again:
    sudo certbot --apache

 IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/kpchiao9600k.sino.tw/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/kpchiao9600k.sino.tw/privkey.pem
   Your cert will expire on 2023-05-29. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot again
   with the "certonly" option. To non-interactively renew *all* of
   your certificates, run "certbot renew"
 - Your account credentials have been saved in your Certbot
   configuration directory at /etc/letsencrypt. You should make a
   secure backup of this folder now. This configuration directory will
   also contain certificates and private keys obtained by Certbot so
   making regular backups of this folder is ideal.
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

Run this to update certificaion:

sudo certbot certonly --standalone -d example.com -d www.example.com

耳鳴、蟬鳴聲

 cf: https://tw.news.yahoo.com/%E8%80%B3%E9%B3%B4%E7%BA%8F%E8%BA%AB-%E9%A2%A8%E8%81%B2-%E8%9F%AC%E9%B3%B4%E8%81%B2%E5%A4%A7%E4%B8%8D%E5%90%8C-%E4%B8%AD%E9%86%AB%E5%B8%AB%E6%95%99%E4%BD%A0%E5%B0%8D%E7%97%87%E8%AA%BF%E7%90%86-4%E7%A9%B4%E4%BD%8Dko%E4%B8%8D%E9%81%A9-014000988.html

《虛證—蟬鳴聲型耳鳴》

若耳鳴聲屬於「蟬鳴聲」,則應與年老精衰、腎元虧乏,以致耳竅失養,發為耳鳴、耳聾有關。中醫典籍《靈樞經•脈度》中就提到,「腎氣通於耳,腎和則耳能聞五音矣」之說,以及「髓海不足則腦轉耳鳴」的紀錄。

治療方針:所以調理上,會以滋補腎陰、益氣活血為主。

推薦茶飲:

★核桃黑米粥

材料:核桃仁7顆、黑豆5公克、黑芝麻5公克、黑米5公克、白米5公克、枸杞20顆、山藥2片。

做法:製作前一天先把食材用冷水泡軟,第二天加入適量的水熬粥,以中火熬煮大概15分鐘,至水變黏稠的時候關火,用蓋子悶1小時後就可以使用。

作用:核桃、黑豆、黑芝麻、黑米、枸杞、山藥等食材有滋陰補腎、益氣活血的作用,適合年老精衰、腎元虧乏的耳鳴患者食用。

減緩耳鳴發作這樣做!時刻揉按4穴位,自我保健不求人

除了針對造成耳鳴發生的2大類型加以解說,郭祐睿中醫師也推薦經常有耳鳴困擾民眾,不妨可以養成時時扣擊耳門、聽宮、聽會及翳風4個保健穴位的習慣,每次搓揉1分鐘,到有酸脹感為止,就是很好的居家自我保養方式:

聽宮穴位於面部、耳屏前,下頜骨髁狀突的後方,張口時呈凹陷處。主治耳鳴、耳聾。

耳門穴位於頭部側面耳前,耳珠上方稍前的缺口,在聽宮穴上0.5寸,是治療多種耳疾重要的首選穴位之一。

★聽會穴:位於面部,在聽宮下方,張口有凹陷處。《百症賦》中「耳聾氣閉、全憑聽會、翳風」的記載,也是治療耳鳴的重要穴道。

★翳風穴:位於耳垂1後方,當乳突與下頜角之間的凹陷處。《扁鵲神應針灸玉龍經》日:「若人患耳即成聾,下手先須覓翳風。」所以搭配耳門、聽宮、聽會,四穴一體按摩,適度刺激能輔助改善耳鳴現象。


2023年2月24日 星期五

2023年2月23日 星期四

Remove mayo from drupal9

cf: https://www.drupal.org/docs/theming-drupal/defining-a-theme-with-an-infoyml-file
  1. mkdir ~/public_html/drupal9/web/themes/contrib/mayo
  2. cd ~/public_html/drupal9/web/themes/contrib/mayo
  3. vim mayo.info.yml with the following lines:
    name: Mayo
    type: theme
    description: 'remove mayo'
    core_version_requirement: ^9
    libraries:
      - mayo/l
    base theme: stable9
    regions:
      header: 'Header'
      content: 'Content'
      sidebar_first: 'Sidebar first'
    footer: 'Footer'
  4. touch mayo.l
  5. Go into admin/appearance 首頁-> 管理-> 外觀
    There sould be a Myao theme. Delete it. Done!
  6. If Mayo theme not appear, then this method not work.

2023年2月3日 星期五

libGL error: MESA-LOADER: failed to open iris

 cf: https://stackoverflow.com/questions/72110384/libgl-error-mesa-loader-failed-to-open-iris

 

$ cd /home/chiao/anaconda3/lib
$ mkdir libstd_orig  # Create a new folder to keep the original libstdc++
$ mv libstd* libstd_orig  # Put all libstdc++ files into the folder, including soft links
$ cp /usr/lib/x86_64-linux-gnu/libstdc++.so.6  ./ # Copy the c++ dynamic link library of the system here
$ ln -s libstdc++.so.6 libstdc++.so
$ ln -s libstdc++.so.6 libstdc++.so.6.0.29

 

2023年1月27日 星期五

中文異體字

  1. Go to http://zht.glyphwiki.org/wiki/u2137c-fv
  2. Download ttf: u2137c-jv.ttf
  3. In terminal run: gnome-font-viewer u2137c-jv.ttf, 點選 "安裝"
  4. Run font-manager or 字型總管),





  5. Inside libreoffice, select font u2137c-fv and press Ctrl-Shift-U 3013 to get the
    character:

    𡍼

全字庫:
  1. Download from : Open_Data.zip
  2. Unzip ttf: Fonts/TW-Kai-Ext-B-98_1.ttf 
  3. Click TW-Kai-Ext-B-98_1.ttf to install ttf





  4.  Click 𡍼 to copy it and paste to libreoffice or other editor.

2023年1月17日 星期二

Install firefox with apt instead of snap

 cf: https://www.omgubuntu.co.uk/2022/04/how-to-install-firefox-deb-apt-ubuntu-22-04


ATTN: Must BE backup $HOME/.mozilla FIRST! New firefox will delete .mozilla


  • sudo snap remove firefox
  • sudo add-apt-repository ppa:mozillateam/ppa
  • echo ' Package: * Pin: release o=LP-PPA-mozillateam Pin-Priority: 1001 ' | sudo tee /etc/apt/preferences.d/mozilla-firefox
  • echo 'Unattended-Upgrade::Allowed-Origins:: "LP-PPA-mozillateam:${distro_codename}";' | sudo tee /etc/apt/apt.conf.d/51unattended-upgrades-firefox
  • sudo apt install firefox

2023年1月12日 星期四

dlink 842 turn off upnp

基本設定 ->  區域網路 -> 進階設定... (at bottom right) -> 啟用 UPnP IGD: 關閉



2023年1月9日 星期一

透過沖煮控制酸質

 cf: https://www.cometrue-coffee.com/blog/more-acidic-2 

參考上述網頁:


  • 研磨越細,萃取速度越快(註:萃取時間不同於沖煮時間)。研磨得越粗代表酸質越高、樂系代表苦味越多。
  • 沖煮時間越長、萃取的時間也會拉長。短時間沖煮酸質越多,長時間沖煮則越苦。
  • 水溫越高,萃取速度越快,但太低溫則無法萃出酸質。「沖煮時會同時萃出好跟不好的酸質,熱沖的咖啡會比冷萃咖啡萃出更多酸質(冷萃咖啡的特性就是非常溫和的酸質)

想要得到酸質更高的咖啡,可以用較高溫的水、較粗的研磨及較短的沖煮時間。如果咖啡臭酸,可以研磨細一點並延長沖煮時間,或是降低水溫來減少酸質。但是降低水溫的同時要記得拉長沖煮時間,因為萃取時間會因溫度降低而拉長。



lftp 嚴重錯誤 Certificate verification: Not trusted

 cf: https://www.kaijia.me/2012/11/lftp-fatal-error-certificate-verification-not-trusted-issue-solved/


Edit /etc/lftp.conf, add this line:

set ssl:verify-certificate no

2022年12月24日 星期六

Enabling Dual-Channel for RAM

 cf: Dual Channel

Installing RAM modules on A1 and B1 will enable dual-channel mode as well as A2 and B2. However, installing them in A1 and A2 will make them run in single-channel mode.

2022年12月23日 星期五

2022年11月25日 星期五

Reinstall samba

sudo purge samba
sudo remove samba
sudo aptitude to reinstall samba

Matplotlib error due to font size: type1ec.sty not found

sudo apt install cm-super

2022年11月17日 星期四

mount image img file

 cf: https://coldnew.github.io/ff159f7c/

  1. sudo fdisk -u -l pi3_20221116.img
    The outputs are
    ...
    所用裝置          可開機  Start     結束     磁區  Size Id 類型
    pi3_20221116.img1          8192   532480   524289  256M  c W95 FAT32 (LBA)
    pi3_20221116.img2        540672 30881791 30341120 14.5G 83 Linux

    Get the Start block 540672 for partition 2
  2. sudo mount -o loop,offset=$((540672 * 512)) pi3_20221116.img /mnt/myimg

The script file: (cf: https://github.com/AlexanderAmelkin/mountimg/blob/master/mountimg

#!/bin/bash
IMAGE="$1"
PART="$2"
WHERE="$3"
shift 3

OPTIONS="$*"

if [ ! -f "$IMAGE" ] || [ -z "$PART" ] || [ -z "$WHERE" ]; then
    echo "Disk image partition mounter by Alexander Amelkin."
    echo "Version 1.0"
    echo
    echo "Usage: mountimg <image> <partition> <where> [<mount options>]"
    echo "Example: mountimg sdcard.img 1 /mnt/sdcard0p1 -t vfat -o ro,codepage=866,iocharset=utf-8"
    exit 1
fi

# Now find the first unused loop device and use it
OFFSET=$(
    sfdisk -l $IMAGE |
    grep $IMAGE$PART |
    awk 'BEGIN { FS="[ *\t]+"}
         /.+/ { print $2; found=1 }
         END { if(!found) exit 1 }'
    ) || { echo "No such partition in the image"; exit 1; }

echo "Mounting $IMAGE partition $PART (offset $OFFSET) to $WHERE via $LODEV"

set -e

mount $OPTIONS -o loop,offset=$((OFFSET * 512)) $IMAGE $WHERE

2022年11月16日 星期三

PhpOffice\PhpSpreadsheet\Spreadsheet' not found

composer require phpoffice/phpspreadsheet



You have requested a non-existent service "user.private_tempstore"

Change this line:

$tempstore = \Drupal::service('user.private_tempstore')->get('appraisal_edit');

into

$tempstore = \Drupal::service('tempstore.private')->get('appraisal_edit');



2022年11月7日 星期一

Disable php7.4-fpm.conf, enable php8.1-fpm.conf

sudo a2disconf php7.4-fpm.conf
sudo a2enconf php8.1-fpm.conf

2022年11月3日 星期四

Upgrade Mac OS X stuck hung at progress bar

cf: https://www.sysprobs.com/macos-13-ventura-vmware-pre-installed-image-download-windows-11-10 

This links also contains the download urls for Ventura vmware image (worked!)

  1. Poweroff the virtual guest (not workstation)
  2. Add this line into vmx file, e.g. Monterey.vmx
    smc.version= "0" 
  3. Change the line as follows:
    #ethernet0.virtualDev = "e1000e"
    ethernet0.virtualDev = "vmxnet3"
  4. Save and restart guest.
  5. If it is successfully opened, but the mouse and keyboard are not working, then change the USB version in VM settings to USB3.1.
  6. Viola!

 

2022年10月22日 星期六

Safely power off USB drive

  1. Umount all: e.g
    sudo umount /media/pi/ntfs_1TB
    sudo umount /media/pi/ext4_1.7TB
    sudo umount /media/pi/ext4_1TB
  2. sudo udisksctl power-off -b /dev/sda

2022年10月13日 星期四

2022年10月9日 星期日

Rsyslogd: action ‘action-0-builtin:omfile’ ‘action-7builtin:omfile’

cf: https://ubuntu-mate.community/t/rsyslogd-action-action-0-builtin-omfile-resumed-module-builtin-omfile/24105

Edit /etc/rsyslog.conf and comment the following lines.

#
# Set the default permissions for all log files.
#
#$FileOwner syslog
#$FileGroup adm
#$FileCreateMode 0640
#$DirCreateMode 0755
#$Umask 0022
#$PrivDropToUser syslog
#$PrivDropToGroup syslog

Restart rsyslog

 

2022年10月6日 星期四

Set network interface priority

cf: https://forums.raspberrypi.com/viewtopic.php?t=278033  

For linux: 

First run the command:

route -n 

It will show the metrics of the interface. 

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.2.1     0.0.0.0         UG    202    0        0 eth1
0.0.0.0         192.168.1.12    0.0.0.0         UG    303    0        0 wlan0
 
The lower the route priority first. So eth0 is higher than wlan0.
Edit /etc/dpchcd.conf: 
interface wlan0 
metric 100 
And run route -n, it will then show:
 
Kernel IP routing table 
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.1.12 0.0.0.0 UG 100 0 0 wlan0 
0.0.0.0 192.168.2.1 0.0.0.0 UG 204 0 0 eth1  
 
Thus, wlan0 will is higher than eth1. 
Becuase wlan0 is the external interface, while eth1 is for internal interface, the wlan0 priority need to be higher than eth1. Otherwise, the outside internet can not be reached. 
 
For windows:
The following image shows the NIC is set to metric 5.

 

 
 

網誌存檔