Skip to content

Zeroplex 生活隨筆

軟體開發、伺服器和生活瑣事

小 縮小字型大小。 中 重設字型大小。 大 放大字型大小。

標籤: Linux

phpbrew install 時使用舊版 OpenSSL

Posted on 2023 年 8 月 8 日2023 年 8 月 8 日 By 日落 在〈phpbrew install 時使用舊版 OpenSSL〉中尚無留言

phpbrew install 8.0.11 時會出現 OpenSSL 的錯誤訊息:

/home/zero/.phpbrew/build/8.0.29/ext/openssl/xp_ssl.c:1240:9: warning: ‘DH_free’ is deprecated: Since OpenSSL 3.0 [-Wdeprecated-declarations]
 1240 |         DH_free(dh);
      |         ^~~~~~~
In file included from /usr/include/openssl/dsa.h:51,
                 from /usr/include/openssl/x509.h:37,
                 from /usr/include/openssl/ssl.h:31,
                 from /home/zero/.phpbrew/build/8.0.29/ext/openssl/xp_ssl.c:31:
/usr/include/openssl/dh.h:200:28: note: declared here
  200 | OSSL_DEPRECATEDIN_3_0 void DH_free(DH *dh);
      |                            ^~~~~~~

主要是因為舊版的 PHP 使用到的 OpenSSL 也是舊版的。

解決方法:

  • 編譯、安裝舊版 OpenSSL (v1.1)
  • 自訂 pkgconfig 來跑 phpbrew install


先下載 OpenSSL v1.1,並編譯:

cd ~/tmp/openssl-1.1.1v

# --prefix 設定為暫存路徑
./Configure --prefix=/home/zeroplex/openssl-1.1.1/ -fPIC -shared linux-x86_64
make
make install

make install 後執行檔、函式庫就會存放到 /home/zeroplex/openssl 中。


先設定要使用的 OpenSSL pkgconfig:

# 在 openssl 位置中找到 pkgconfig 的路徑
export PKG_CONFIG_PATH=/home/zeroplex/openssl/lib/pkgconfig

接下來 phpbrew 使用相同的指令即可:

phpbrew install 8.0.29 +defaults

備註:phpbrew install 7.4 也需要相同的方法

Tags:Linux, PHP, Ubuntu

設定 Linux SWAP 使用優先順序

Posted on 2023 年 7 月 16 日2023 年 7 月 16 日 By 日落 在〈設定 Linux SWAP 使用優先順序〉中尚無留言

之前提過可以自己在儲存空間上建立 swap file,而儲存空間可以是傳統硬碟,所以設定 swap file 使用優先順序是有差的。

在 /etc/fstab 的 mount option 中加入 pri:

# <file system> <mount point>   <type>  <options>   <dump>  <pass>
/dev/sdb       none             swap    sw,pri=0    0       0
/swapfile      none             swap    sw,pri=-2   0       0

其中 pri 數值越大表示優先權越高。範例中會先使用 /dev/sdb 的空間,用光後再使用 /swapfile。

Tags:Linux

在 Linux 建立 SWAP 用檔案

Posted on 2023 年 7 月 14 日2023 年 7 月 16 日 By 日落 在〈在 Linux 建立 SWAP 用檔案〉中尚無留言

以下範例,會建立一個 4GB 的 SWAP 用檔案,並 mount 起來。

建立 4GB 的檔案供 SWAP 使用:

sudo fallocate -l 4G /swapfile
sudo dd if=/dev/zero of=/swapfile bs=1G count=4

# 注意權限必須是 600
sudo chmod 600 /swapfile

檔案格式化為 swapfile:

sudo mkswap /swapfile

到這邊都沒有遇到問題的話,就可以使用 swapon 來讓 Linux mount 起來使用:

sudo swapon /swapfile

如果希望開機以後讓 Linux 自動 mount 起來,可修改 /etc/fstab 檔案:

# <file system>  <mount point>   <type>  <options>   <dump>  <pass>
/swapfile        none            swap    sw          0       0
Tags:Linux

OpenVPN 自訂路由 (route)

Posted on 2023 年 7 月 7 日2023 年 12 月 11 日 By 日落 在〈OpenVPN 自訂路由 (route)〉中尚無留言

OpenVPN 連線成功時,預設會將所有網路流向都導向新建立的 VPN。

若 OpenVPN client 是在 server 上面跑,僅特定連線走 VPN、不應該修改 default gateway,使用 --pull-filter 來忽略 gateway 設定:

sudo openvpn --config connect.cong --pull-filter ignore redirect-gateway

連線以後僅需要特定網段走 VPN,可以在設定檔中加上 push route :

auth-user-pass auth.conf
client
auth SHA1
ignore-unknown-option cipher data-ciphers
....

# 僅 10.3.0.* 的封包改走 VPN
push "route 10.3.0.0 255.255.255.0"

<ca>
-----BEGIN CERTIFICATE-----
Tags:Linux, OpenVPN

apt upgrade 時不詢問

Posted on 2023 年 6 月 27 日 By 日落 在〈apt upgrade 時不詢問〉中尚無留言

原本以為使用 DEBIAN_FRONTEND=noninteractive 參數就可以:

sudo DEBIAN_FRONTEND=noninteractive apt upgrade

後來發現還有個套件叫做 needrestart,預設會在 apt upgrade 完成後詢問哪一些服務要重新啟動:

which services should be restarted

先檢查一下是否有安裝 needrestart,有的話可以看到 /etc/needrestart 目錄。

再去修改設定檔 needrestart.conf:

# Restart mode: (l)ist only, (i)nteractive or (a)utomatically.
#
# ATTENTION: If needrestart is configured to run in interactive mode but is run
# non-interactive (i.e. unattended-upgrades) it will fallback to list only mode.
#
$nrconf{restart} = 'a';

參考資料:

  • How do I ask apt-get to skip any interactive post-install configuration steps?
  • apt-get upgrade auto restart services
Tags:Linux, Ubuntu

文章分頁

上一頁 1 2 3 4 ... 32 下一頁

其他

關於我  (About me)

小額贊助

  文章 RSS Feed

  留言 RSS Feed

Apache AWS Bash C/C++ Docker FreeBSD GCP Git Google Java JavaScript Laravel Linux Microsoft MSSQL MySQL Nginx PHP PHPUnit PostgreSQL Python Qt Ubuntu Unix Vim Web Windows WordPress XD 作業系統 分享 好站推薦 專題 攝影 新奇搞笑 新聞 旅遊 生活雜記 程式設計 網路架站 網頁設計 資訊學習 資訊安全 遊戲 音樂


創用 CC 授權條款
本著作係採用創用 CC 姓名標示-相同方式分享 4.0 國際 授權條款授權.