當使用nginx + php-fpm建立virtual host (server block)時,要注意權限問題,最好不同的site用不同的使用者去存取php-fpm的pool,以下以建立site1及site2二個網站為例:
1.建立使用者,並記得修改/etc/passwd為nologin
sudo groupadd site1
sudo useradd -g site1 site1
sudo groupadd site2
sudo useradd -g site2 site2
當使用nginx + php-fpm建立virtual host (server block)時,要注意權限問題,最好不同的site用不同的使用者去存取php-fpm的pool,以下以建立site1及site2二個網站為例:
1.建立使用者,並記得修改/etc/passwd為nologin
sudo groupadd site1
sudo useradd -g site1 site1
sudo groupadd site2
sudo useradd -g site2 site2
在netbeans設定tomcat時,若port設定為8084,且又打開 HTTP monitor功能的話,會導致tomcat開啟不了,顯示"Starting of Tomcat failed, the server port 8084 is already in use."
這是因為HTTP Monitor打開後,netbeans會啟動內建的tomcat 3 server,導致占port 8084,
要嘛將Server port改掉,要嘛關掉HTTP Monitor (這功能是會在HTTP Server Monitor顯示GET/POST等訪問紀錄)
另外,netbeans的web專案要是出現 "Deployment descriptor directory could not be found" 訊息,那可能就是少了web.xml 或WEB-INF資料夾,在專案按右鍵新增web.xml檔案即可。
場景:
phpmyadmin 5.2.0
mariadb 10.88.0.1
問題:
phpmyadmin點選使用者帳號(User accounts)頁籤時,無法顯示使用者,出現"Not enough privilege to view users"(權限不足以檢視使用者)錯誤訊息
解決方式:
執行以下語句,並重新啟動mariadb
use mysql;
INSERT INTO `tables_priv` (`Host`, `Db`, `User`, `Table_name`, `Grantor`, `Timestamp`, `Table_priv`, `Column_priv`) VALUES ('localhost','mysql','mariadb.sys','global_priv','root@localhost','0000-00-00 00:00:00','Select,Delete','');
ref:
https://stackoverflow.com/questions/60387072/not-enough-privilege-to-view-users-in-phpmyadmin
前二天早上tomcat突然掛掉,log 顯示如下:
20-Apr-2022 10:22:41.714 嚴重 [https-jsse-nio2-8443-Acceptor-0] org.apache.tomcat.util.net.Acceptor.run Socket accept failed java.util.concurrent.ExecutionException: java.io.IOException: 開啟太多檔案 at sun.nio.ch.CompletedFuture.get(CompletedFuture.java:69) at org.apache.tomcat.util.net.Nio2Endpoint.serverSocketAccept(Nio2Endpoint.java:334) at org.apache.tomcat.util.net.Nio2Endpoint.serverSocketAccept(Nio2Endpoint.java:59) at org.apache.tomcat.util.net.Acceptor.run(Acceptor.java:95) at java.lang.Thread.run(Thread.java:748) Caused by: java.io.IOException: 開啟太多檔案 at sun.nio.ch.UnixAsynchronousServerSocketChannelImpl.accept0(Native Method) at sun.nio.ch.UnixAsynchronousServerSocketChannelImpl.accept(UnixAsynchronousServerSocketChannelImpl.java:344) at sun.nio.ch.UnixAsynchronousServerSocketChannelImpl.implAccept(UnixAsynchronousServerSocketChannelImpl.java:280) at sun.nio.ch.AsynchronousServerSocketChannelImpl.accept(AsynchronousServerSocketChannelImpl.java:125) ... 4 more
初步調查是tomcat開啟了太多檔案,造成"too many open files" (開啟太多檔案),網路上一般說法是說要調整系統的ulimit上限才行,但想想不太對,這系統會需要同時開啟的檔案不多,而且運行了幾年也沒有發生file leak的狀況。
先找出tomcat的pid,再用 ls -al /proc/<pid>/fd | wc -l,就可以知道tomcat目前開啟多少檔案(包含unix socket file)。
後來發現是tomcat自已的bug,會一直存取tomcat-users.xml卻沒有釋放資源,解法是升級 tomcat 9 >= 9.0.14+,或修改 server.xml,加入watchSource="false":
<resource auth="Container" description="User database that can be updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory" name="UserDatabase" pathname="conf/tomcat-users.xml" type="org.apache.catalina.UserDatabase" watchsource="false">ref:
在ubuntu/mint下要啟用chromium的硬體加速,必須是pathced過的版本,
可以用 https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-beta
(包含Widevine,觀看netflix等有DRM保護的串流時需要)
或 https://github.com/Eloston/ungoogled-chromium#downloads
(不包含Widevine)
先裝好對應各顯卡的VA-API driver,啟動chromium時加上以下參數:
chromium-browser --use-gl=desktop --enable-features=VaapiVideoDecoder --disable-features=UseChromeOSDirectVideoDecoder
(chromium 98開始需加上 --disable-features=UseChromeOSDirectVideoDecoder)
====2024.09更新(在128的版本實測有效):==========
https://ubuntuhandbook.org/index.php/2024/01/chromium-va-api-wayland/
https://debugpointnews.com/va-api-chromium-wayland/
chromium 121以後的版本,可以不用再找有va-api patched過的版本,直接使用以下參數開啟硬體加速:
On X11:
chromium-browser --enable-features=VaapiVideoDecodeLinuxGL --use-gl=angle --use-angle=gl --ozone-platform=x11
On Wayland:
chromium-browser --enable-features=VaapiVideoDecodeLinuxGL --use-gl=angle --use-angle=gl --ozone-platform=wayland
=====================================
用ungoogled-chromium又想加上Widevine DRM支援時,
可先下載對應版本的Chrome DEB安裝檔(stable, unstable),
解開後,把 ./opt/google/chrome/WidevineCdm 複製到
/usr/lib/chromium/WidevineCd 或 ~/.local/lib/WidevineCdm
ref:
https://wiki.archlinux.org/title/Chromium#Hardware_video_acceleration
https://www.linuxuprising.com/2018/08/how-to-enable-hardware-accelerated.html
https://ungoogled-software.github.io/ungoogled-chromium-wiki/faq#linux
想要支援平版型筆電, MINT裝Cinnamon版本會友善一點,MATE/XFCE的支援度差一點,但後面會講解法。
1.開機時按F2進BIOS,
在Main頁面按ctrl+s呼叫出隱藏選項,
將SATA Mode=> AHCI, trackpad => PS2(待會會再改回來),
在Security將TPM關閉,
在Boot頁面將Secure Boot關閉(要先在Security頁面設Supervisor Password才能改),
Boot priority order 設為要用來安裝Ubuntu/Mint的USB。
2.開始安裝Mint,安裝時個人是分成三個分割區:
EFI => 550mb (UEFI開機載入需要此分割區)
SWAP=> 5120mb
剩下的都格式化為ext4並 mount 給 /
3.裝完後,修改 /etc/default/grub:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash pci=nocrs" #加入pci=nocrs
GRUB_SAVEDEFAULT=true
GRUB_DEFAULT=saved
GRUB_TIMEOUT=3
修改完執行 sudo update-grub
3.打開更新管理員執行更新,若是intel版本,AX210網卡需5.10+ kernel,AX200需5.1+ kernel。若是amd版本,附的應該是都MT7921聯發科網卡,需要5.12+ kernel,但我建議把聯發科卡換成intel網卡,就算弄到能上網一樣是真心爛(掉包降速斷線等)。
重開機,進BIOS把trackpad改回IC2,開機時在選單選擇用最新的kernel開機。
4.調整自動旋轉
= 若是Cinnamon =:
進 管理/顯示器/設定,選擇Hi-DPI啟用fractional scaling,fractional scaling選150%
安裝touchscreen旋轉時的xinput修正:
sudo apt-get install x11-touchscreen-calibrator
Cinnamon其中有一個"自動螢幕旋轉",請保持停用狀態,不然啟用的話,螢幕設定不知怎的都無法正常保存。
= 若是MATE/XFCE =:
桌面設定一樣改 Hi-DPI
sudo apt-get install x11-touchscreen-calibrator
xrandr --output eDP --scale 1.5x1.5
sudo apt install autorandr
autorandr --save work
不管哪個版本,自動旋轉請改用自動偵測script (https://askubuntu.com/a/1375561),可放到開機自動啟動:
sudo apt install iio-sensor-proxy inotify-tools
==================================
#!/bin/bash
# Auto rotate screen based on device orientation
monitor-sensor | \
while IFS= read -r str; do
if [[ $str =~ orientation\ changed:\ (.*)$ ]]; then
case "${BASH_REMATCH[1]}" in
normal)
xrandr --output eDP --rotate normal ;;
bottom-up)
xrandr --output eDP --rotate inverted ;;
right-up)
xrandr --output eDP --rotate right ;;
left-up)
xrandr --output eDP --rotate left ;;
esac
fi
done
=================================
5.調整firefox滑動及steam縮放,修改/etc/environment,加入:
MOZ_USE_XINPUT2=1 #firefox,並把firefox設定中的平滑捲動取消
# GDK_SCALE=2 #steam,不過建議在啟動steam時加在指令前面就好
6.調整java介面縮放,修改 ~/.profile,加入:
#java ui scale
export _JAVA_OPTIONS='-Dsun.java2d.uiScale.enabled=true -Dsun.java2d.uiScale=2'
7.fcitx輸入文字時,候選字(preedit)視窗(fcitx-qimpanel)過小:
譬如用的是ubutnu-grey主題,那麼就修改:
sudo vi /usr/share/fcitx-qimpanel/skin/ubuntu-grey/fcitx_skin.conf
FontSize=36
CandFontSize=36
若是用default佈景,那就修改:
sudo vi /usr/share/fcitx/skin/default/fcitx_skin.conf
8.觸控板多指手勢支援:
X11(後面指令以X11為主):
https://github.com/bulletmark/libinput-gestures
https://gitlab.com/cunidev/gestures
sudo apt install python3 python3-pip python3-venv python3-gi python-gobject meson wmctrl xdotool libinput-tools gettext appstream-util
sudo gpasswd -a $USER input
git clone https://github.com/bulletmark/libinput-gestures.git
cd libinput-gestures
sudo make install (or sudo ./libinput-gestures-setup install)
cp /etc/libinput-gestures.conf ~/.config/libinput-gestures.conf
newgrp input
libinput-gestures-setup autostart start
git clone https://gitlab.com/cunidev/gestures
cd gestures
meson build --prefix=/usr
ninja -C build
sudo ninja -C build install
ref:
https://sciactive.com/2020/12/04/how-to-install-ubuntu-on-acer-spin-5-sp513-54n-for-the-perfect-linux-2-in-1/
https://wiki.archlinux.org/title/HiDPI
安裝很簡單,直接參考github官方網站:
https://github.com/JetBrains/projector-installer
設定:
projector config list
projector config edit <APP_NAME>
憑證:
若有用let's encrypt,可直接用如下指令安裝,記得憑證過期一樣要再重安裝一次
(APP_NAME可能為IntelliJ或DataGrip,可參照 ~/.projector/configs):
projector install-certificate <APP_NAME> --certificate /etc/letsencrypt/live/<change.to.your.site.com>/fullchain.pem --key /etc/letsencrypt/live/<change.to.your.site.com>/privkey.pem;
以下補充如何以user systemd的方式自啟動,這樣ide點擊exit或reload時就會重新啟動,也不用登入tty,以下以新增 IntelliJ IDEA為例:
mkdir -p ~/.config/systemd/user/
vi ~/.config/systemd/user/idea.service
加入:
======================
[Unit]
Description=Jetbrains Projector - IDEA
[Service]
Type=simple
#注意這裡要改為用 run.sh 執行
ExecStart=%h/.projector/configs/IntelliJ/run.sh
Restart=always
[Install]
WantedBy=default.target
======================
再執行(以一般使用者身份執行即可)
systemctl --user start idea
systemctl --user status idea
systemctl --user enable idea
#不用tty登入也可reboot時自啟動
loginctl enable-linger <username>
ref:
https://youtrack.jetbrains.com/issue/PRJ-298
https://wiki.archlinux.org/title/systemd/User#Automatic_start-up_of_systemd_user_instances