Ubuntu 管理心得

搜尋此網誌

2022年2月17日 星期四

Matplotlib 顯示中文

 cf: https://mathsyouth.github.io/2019/06/12/macos-matplotlib

  1. Run shell command:
    fc-list :lang=zh

    to find the fonts pathes, e.g. /usr/share/fonts/truetype/bkai00mp.ttf
  2. Follow the python codes below:
    import numpy as np
    import matplotlib.pyplot as plt
    from matplotlib import rcParams
    from matplotlib.font_manager import FontProperties
    rcParams['axes.unicode_minus']=False
    myfont_kai=FontProperties(fname='/usr/share/fonts/truetype/bkai00mp.ttf', size=15)
    myfont_ming=FontProperties(fname='/usr/share/fonts/truetype/arphic-bsmi00lp/bsmi00lp.ttf',size=12)
    x=np.linspace(0,2*np.pi,100)
    plt.plot(x,x)
    plt.title("準則", fontproperties=myfont_kai)
    plt.ylabel("隸屬度", fontproperties=myfont_ming)

2022年2月12日 星期六

Install LAMP server

 cf: https://upcloud.com/community/tutorials/installing-lamp-stack-ubuntu/

 

  1. sudo apt update
  2. sudo apt install apache 
  3. sudo systemctl status apache2
  4. sudo apt install php7.4 php7.4-mysql php-common php7.4-cli php7.4-json php7.4-common php7.4-opcache libapache2-mod-php7.4
  5. sudo systemctl restart apache2
  6. sudo apt install mariadb-server mariadb-client
  7. sudo systemctl status mariadb
  8. sudo mysql_secure_installation
    As you have no root password set for MariaDB you should simply press Enter when prompted, pressing Y on the next question to then set a root password (keep this safe and secure!) With that set, you can press Enter for the remaining questions as the defaults for each of these will help to secure your new installation.
  9. mysql_secure_installation

    https://mariadb.com/kb/en/mysql_secure_installation/
  10. Run mysql_secure_installation
  11. cf: https://kpchiaoo.blogspot.com/search?q=mysql
    If can't access mysql as mysql user root from normal user account but can access mysql without mysql root password from ubuntu root accout, then follow the lines below (the parentheses are comments):
    cf: https://askubuntu.com/questions/766334/cant-login-as-mysql-user-root-from-normal-user-account-in-ubuntu-16-04/801950
        (1). su - (get into ubuntu root account)
        (2). mysql -u root (get into mysql, should be no need password)
        (3). select User,host,plugin from mysql.user;
        (4). update mysql.user set plugin = 'mysql_native_password' where User='root';
        (5). select User,host,plugin from mysql.user; (plugin column should be changed)
        (6). SET PASSWORD FOR 'root'@'localhost' = PASSWORD('new password');
    or for mysql 8.0 in ubuntu 20.04
    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'newpassord' 
        (7). flush privileges;
  12. sudo a2enmod userdir
  13. sudo a2enmod rewrite
  14. sudo vim php7.4.conf Commnent out the following lines:
    #<IfModule mod_userdir.c>
    #    <Directory /home/*/public_html>
    #        php_admin_flag engine Off
    #    </Directory>
    #</IfModule>
     
  15. sudo apt install phpmyadmin
  16. cf: https://stackoverflow.com/questions/42490647/phpmyadmin-installation-error-1045-acces-denied-using-password-no
    $ mysql -u root -p
    mysql> create database phpmyadmin;
    mysql> create user 'phpmyadmin'@'localhost' identified by 'some_passwd';

    mysql> grant all privileges on phpmyadmin.* to 'phpmyadmin'@'localhost'
  17. cd  /usr/share/phpmyadmin/sql
    $ mysql -u phpmyadmin -p phpmyadmin < create_tables.sql
  18. Edit /etc/php/7.4/apache2/php.ini
    post_max_size = 200M
    upload_max_filesize = 200M
  19. Edit /etc/apache2/apache2.conf, add the lines:
    <Directory /home/chiao/public_html/drupal9/web>
    Options FollowSymLinks
    AllowOverride AuthConfig FileInfo Indexes Limit Options=All,MultiViews
    </Directory>
  20. sudo systemctl restart apache2

 

2022年2月6日 星期日

install pear php-pear spreadsheet

  1. sudo apt install php-pear
  2. Goto https://pear.php.net/package/OLE to see what OLE version is now. Say, 1.0.0RC3 (beta) was released on 2017-06-20
  3. sudo pear install OLE-1.0.0RC3
  4. Goto https://pear.php.net/package/Spreadsheet_Excel_Writer to see what SpreadSheet version is now. Say, 0.9.4 (beta) was released on 2017-05-24
  5. sudo pear install Spreadsheet_Excel_Writer-0.9.4
  6. Done

nmcli set static IP

  1. 執行: sudo  nmcli connection show 會出現下列:
    NAME            UUID                                  TYPE      DEVICE
    有線連線 1      7b62be74-2e0d-32e4-a08e-37a47c33d699  ethernet  eth0
    chiao-dlink842  710e0af6-9b51-455d-9b11-aac2091a2c87  wifi      --   
  2. 修改為 192.168.1.12 IP, 指令如下:
    sudo nmcli connection modify "有線連線 1" ipv4.addresses 192.168.1.12/24 ipv4.gateway 192.168.1.1 ipv4.gateway 192.168.1.1 ipv4.method manual
  3. sudo systemctl restart NetworkManager

eth0 ethernet 不受管理

cf: https://superuser.com/questions/1429490/unmanaged-network-manager-in-ubuntu

 

This works for my ubuntu 20.04.3 at pi4.

As root, edit /etc/NetworkManager/NetworkManager.conf to match the following. You can use the command sudo nano /etc/NetworkManager/NetworkManager.conf to do so.

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=true

[keyfile]
unmanaged-devices=*,except:type:wifi,except:type:gsm,except:type:cdma,except:type:wwan,except:type:ethernet,except:type:vlan

[device]
wifi.scan-rand-mac-address=no

2022年2月1日 星期二

update FAHPShowMembershipForm.php

Edit line 43:

 #        '#prefix' => '<div class=image><img src=/~chiao/drupal9/web/tmp/test_ranking.png>',
        '#prefix' => '<div class=image><img src=tmp/test_ranking.png>',

Line 48:

#        '#prefix' => '<div class=image><img src=/~chiao/drupal9/web/tmp/test.png>',
        '#prefix' => '<div class=image><img src=tmp/test.png>',

網誌存檔