1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

エックスサーバーに PHP の sodium 拡張モジュールを入れる

1
Posted at

概要

エックスサーバーには一部 PHP アプリケーションに必要な sodium 拡張モジュールが入っていなかったので導入します。

ソースからビルド

~/opt ディレクトリ以下に格納することにします。

# 作業用ディレクトリの作成
mkdir -p ~/opt/src

# libsodium のダウンロードとコンパイル
cd ~/opt/src
curl -OL https://download.libsodium.org/libsodium/releases/libsodium-1.0.21.tar.gz
tar xf libsodium-1.0.21.tar.gz
cd libsodium-1.0.21
./configure --prefix=$HOME/opt
make && make check
make install

# PHP拡張のダウンロード&コンパイル
cd ~/opt/src
curl -OL https://github.com/php/php-src/archive/php-8.3.21.zip
unzip php-8.3.21.zip

cd php-src-php-8.3.21/ext/sodium

/opt/php-8.3.21/bin/phpize
./configure --with-php-config=/opt/php-8.3.21/bin/php-config --with-sodium PKG_CONFIG_PATH=$HOME/opt/lib/pkgconfig/ LDFLAGS=-L$HOME/opt/lib/
make
gmake test

設定をする

拡張モジュールは ~/opt/php-ext/php-8.3.21/ 以下に入れることにします。
PHPのバージョンが変わると動かなくなるので明示するためです。

# 移動
mkdir -p ~/opt/php-ext/php-8.3.21
cp ~/opt/src/php-src-php-8.3.21/ext/sodium/modules/sodium.so ~/opt/php-ext/php-8.3.21/

# もう要らないので削除
rm -rf ~/opt/src/

# 拡張モジュールを読み込ませる設定
vi ~/MYDOMAIN/xserver_php/php.ini

一番下にこれを追記します。

~/MYDOMAIN/xserver_php/php.ini
[Extensions]
extension=/home/xsACCOUNT/opt/php-ext/php-8.3.21/sodium.so

お疲れ様でした。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?