LiteSpeedの管理画面でPHP7をインストールしてみる

openlitespeed

LiteSpeedはデフォルトでPHPが入っているのですが、なぜかバージョンが5.4です。そして通常PHPをインストールするとなるとSSHによるコマンドですが、もしかしたらLiteSpeedは不要かもしれません。

ダッシュボードにPHPコンパイルがある

PHPのコンパイルという画面があります。ちょっと見ていきたいと思います

PHPのバージョンが指定できる

これはどういうことか、バージョンの指定ができます。画面には映っていないですが次へボタンがあるので押してみます

ビルドオプションの選択

パラメーターもデフォで入ってます。これは凄い。特に何もしなくてもいいかもしれません

なんか普通に成功しました。やった。次いこう

コマンドが必要な画面にでます

セキュリティ上の理由から、サーバーにログインし、シェルから事前生成されたスクリプトを実行してください。 この画面から進行状況を監視することができます。

正常にビルドできたら、必要に応じてphp.iniを更新してください。 変更を適用するには、緩やかな再起動を実行してください。

Iエラーにより停止した場合は、パッケージを紛失したためにインストールした後、同じコマンドを再実行すると、このページに更新されたログが表示されます。LSPHPの詳細については、次のURLを参照してください LiteSpeed wiki.

rootとしてログインした場合は、次のコマンドを直接実行できます:
/usr/local/lsws/phpbuild/buildphp_manual_run.sh

sudo権限を持つユーザーとしてログインした場合は、sudoでコマンドを実行し、プロンプトの後にrootパスワードを入力することができます。
sudo /usr/local/lsws/phpbuild/buildphp_manual_run.sh

どうやらここはコマンドで対応しないといけないみたいです

1[root@ik1-343-31745 ~]# /usr/local/lsws/phpbuild/buildphp_manual_run.sh

管理画面に戻るとエラーになりました。詳細ログを見ると

01**LOG_DETAIL** retrieved from /usr/local/lsws/phpbuild/buildphp_1533204918.5.log
02 
03==============================================
04Start building PHP 7.2.8 with LSAPI
05==============================================
06Thu Aug 2 19:24:46 JST 2018
07 
08Changing to build directory /usr/local/lsws/phpbuild/php-7.2.8
09Configuring PHP build (2-3 minutes)
10 ./configure '--prefix=/usr/local/lsws/lsphp7' '--with-mysqli' '--with-zlib' '--with-gd' '--enable-shmop' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-mbstring' '--with-iconv' '--with-mcrypt' '--with-pdo-mysql' '--enable-ftp' '--enable-zip' '--with-curl' '--enable-soap' '--enable-xml' '--enable-json' '--with-openssl' '--enable-bcmath' '--with-litespeed'
11configure: WARNING: unrecognized options: --with-mcrypt
12checking for grep that handles long lines and -e... /bin/grep
13checking for egrep... /bin/grep -E
14checking for a sed that does not truncate output... /bin/sed
15checking build system type... x86_64-unknown-linux-gnu
16checking host system type... x86_64-unknown-linux-gnu
17checking target system type... x86_64-unknown-linux-gnu
18checking for cc... cc
19checking whether the C compiler works... yes
20checking for C compiler default output file name... a.out
21checking for suffix of executables...
22checking whether we are cross compiling... no
23checking for suffix of object files... o
24checking whether we are using the GNU C compiler... yes
25checking whether cc accepts -g... yes
26checking for cc option to accept ISO C89... none needed
27checking how to run the C preprocessor... cc -E
28checking for icc... no
29checking for suncc... no
30 
31checking for OpenSSL support... yes
32checking for Kerberos support... no
33checking whether to use system default cipher list instead of hardcoded value... no
34checking for RAND_egd... no
35checking for pkg-config... /bin/pkg-config
36configure: error: Cannot find OpenSSL's <evp.h>
37**ERROR** Could not configure PHP build

OpenSSLがないとエラーがでました。

1[root@ik1-343-31745 ~]# yum install openssl-devel

でインストールします。その後またエラーがでました。。。

1checking for cURL 7.10.5 or greater... configure: error: cURL version 7.10.5 or later is required to compile php with cURL support
2**ERROR** Could not configure PHP build

cURL関係っぽいです

01[root@ik1-343-31745 ~]# yum install curl-devel
02Loaded plugins: fastestmirror, langpacks
03Loading mirror speeds from cached hostfile
04 * base: ftp.iij.ad.jp
05 * epel: mirror.dmmlabs.jp
06 * extras: ftp.iij.ad.jp
07 * updates: ftp.iij.ad.jp
08Resolving Dependencies
09--> Running transaction check
10---> Package libcurl-devel.x86_64 0:7.29.0-46.el7 will be installed
11base/7/x86_64/filelists_db                                                                                                                                                                                                                                                                           | 6.9 MB  00:00:00
12--> Finished Dependency Resolution
13 
14Dependencies Resolved
15 
16============================================================================================================================================================================================================================================================================================================================
17 Package                                                                          Arch                                                                      Version                                                                           Repository                                                               Size
18============================================================================================================================================================================================================================================================================================================================
19Installing:
20 libcurl-devel                                                                    x86_64                                                                    7.29.0-46.el7                                                                     base                                                                    300 k
21 
22Transaction Summary
23============================================================================================================================================================================================================================================================================================================================
24Install  1 Package
25 
26Total download size: 300 k
27Installed size: 623 k
28Is this ok [y/d/N]: y
29Downloading packages:
30libcurl-devel-7.29.0-46.el7.x86_64.rpm                                                                                                                                                                                                                                                               | 300 kB  00:00:00
31Running transaction check
32Running transaction test
33Transaction test succeeded
34Running transaction
35  Installing : libcurl-devel-7.29.0-46.el7.x86_64                                                                                                                                                                                                                                                                       1/1
36  Verifying  : libcurl-devel-7.29.0-46.el7.x86_64                                                                                                                                                                                                                                                                       1/1
37 
38Installed:
39  libcurl-devel.x86_64 0:7.29.0-46.el7
40 
41Complete!
42[root@ik1-343-31745 ~]#

再度コマンドを実行してみます

1[root@ik1-343-31745 ~]# /usr/local/lsws/phpbuild/buildphp_manual_run.sh

またまたエラーです。。というわけで、【PHP】7.0.0 ソースからコマンド最短インストール方法を参考にでたエラーの数だけ必要なのをいれていきます。

成功しました

普通にインストールが成功しました。

ビルドプロセスが成功すると、PHPバイナリは /usr/local/lsws/fcgi-bin/ の配下に名前が lsphp-7.2.8 で作成され、 そして lsphp7 のシンボリックリンクが新しく作成されるか又はビルドされたバイナリが更新されます。 lsphp-7.2.8 が既に存在する場合は、lsphp-7.2.8.bak に名前が変更されます。

とのことですリンク見てみます

1[root@ik1-343-31745 ~]# ls /usr/local/lsws/fcgi-bin/
2RackRunner.rb  lsperld.fpl  lsphp  lsphp-7.2.8  lsphp5  lsphp7
3[root@ik1-343-31745 ~]#

リンクがありました。ブラウザ上でPHP7のインストールができました。

PHP7の設定

初期状態ではPHP5.6のため、切り替えをします。これもコンソール画面でできます。

サーバー設定 > 外部アプリ

アクションを押します

コマンドを修正

デフォルトのコマンド$SERVER_ROOT/fcgi-bin/lsphpを変更します変更コマンドは$SERVER_ROOT/fcgi-bin/lsphp7となります

PHP7に変更完了

この後再起動するだけで変更完了です。なんと楽な・・・

追記

デフォルトの状態だとphp-gdでjpegがサポートされていないため、jpegサポートする方法を追記します

1[root@ik1-343-31745 /]# yum install libjpeg-devel

インストールしたらどこにインストールされたか確認します

1[root@ik1-343-31745 /]# find /usr/ -name libjpeg.so
2/usr/lib64/libjpeg.so
3[root@ik1-343-31745 /]#

見つかりました

再コンパイル

ビルドオプションに--with-jpeg-dir=/usr/lib64/libjpeg.soを追記して再コンパイルします。これでjpegもサポートされます

個人支援・寄付について

サイトラボでは個人支援・寄付を受けております。ご協力いただける方はお願いいたします。当サイトではビットコインで受け付けております。

  • ビットコイン:3LHnADwZwUbic2L45EnVJEykiG6KfbqrwS