amh 4.2 升级php_Centos系统 + AMH4.2面板 PHP升级7.3.5
首先說一下 基本環(huán)境信息,我用的是linux系統(tǒng) + AMH4.2面板 已經(jīng)安裝好PHP5.6、PHP7.0、PHP7.1,希望將PHP7.3.5安裝在PHP7.0目錄中/usr/local/php7.0以方便面板虛擬機對php按本的選擇。
一. 下載和解壓PHP7.3.5
下載wget http://cn2.php.net/distributions/php-7.3.5.tar.gz
或wget https://www.php.net/distributions/php-7.3.5.tar.xz
解壓tar -zxvf php-7.3.5.tar.gz
進入php-7.3.5文件夾中cd php-7.3.5
二. 編譯PHP7.3.5./configure --prefix=/usr/local/php7.0 --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-openssl --with-zlib --with-curl --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --enable-mbstring --enable-zip --enable-openssl --enable-pcntl --with-iconv=/usr/local/libiconv --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --without-pear
編譯完成之后,執(zhí)行安裝命令make && make install
安裝過程大約需要10分鐘時間,請耐心等待。
三、配置PHP
上面編譯過程中我們已經(jīng)將配置文件指明了位置路徑--prefix=/usr/local/php7.0 指明了安裝php路徑,
-with-config-file-path=/etc 指明了php.ini存放路徑。
[可選項] 設(shè)置讓PHP錯誤信息打印在頁面上vim /usr/local/php/php.ini
display_errors = On
修改/usr/local/php7.0/etc/php-fpm.conf.default
添加腳本授權(quán)l(xiāng)isten.owner = www
listen.group = www
listen.mode = 0660
重啟linux,如果openssl報錯,說明openssl文件沒有安裝或者php.ini配置有問題。為了進一步確認(rèn)問題所在可以在測試環(huán)境中查看phpinfo()看看到底是哪里出現(xiàn)的問題。我這里查看出現(xiàn)的是配置有問題,如圖:
可以看出來openssl目錄與路徑都為空
解決辦法:
/etc/php.ini
追加extension=openssl
openssl.capath=/etc/pki/tls/certs/
openssl.cafile=/etc/pki/tls/certs/ca-bundle.crt
重新啟動環(huán)境,查看配置如下
目錄與ca證書已經(jīng)加載成功。
因為在上面我們在安裝php編譯過程中已經(jīng)將openssl配置編譯進去了,所以這里只需要配置一下就好。注意:如果是在前面編譯文件的時候沒有將openssl擴展編譯進去下面我們將安裝php7.3.5 openssl擴展方法寫出來。
五、安裝openssl
1、找到之前編譯安裝PHP的安裝包。
2、解壓并進入文件夾cd php7.3.5/ext/openssl
3、運行 phpize 初始化php,因為我們將php7.3.5安裝在/usr/local/php7.0目錄中了,所以php初始化文件在php7.0目錄中。/usr/local/php7.0/bin/phpize備注,如果出現(xiàn)如下錯誤:Cannot find config.m4.
Make sure that you run ‘/usr/local/php/bin/phpize’ in the top level source directory of the module
【解決辦法】cp ./config0.m4 ./config.m4 即可解決,解決問題后需要重新初始化,因為前面初始化過程中并沒有成功。
4、編譯./configure --with-openssl --with-php-config=/usr/local/php7.0/bin/php-config
5、安裝make && make install
安裝成功會打印出如下信息:/bin/sh /root/php-7.3.5/ext/openssl/libtool --mode=install cp ./openssl.la /root/php-7.3.5/ext/openssl/modules
cp ./.libs/openssl.so /root/php-7.3.5/ext/openssl/modules/openssl.so
cp ./.libs/openssl.lai /root/php-7.3.5/ext/openssl/modules/openssl.la
PATH="$PATH:/sbin" ldconfig -n /root/php-7.3.5/ext/openssl/modules
----------------------------------------------------------------------
Libraries have been installed in:
/root/php-7.3.5/ext/openssl/modules
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the `LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable
during linking
- use the `-Wl,--rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php7.0/lib/php/extensions/no-debug-non-zts-20180731/
最后提示的目錄就是openssl.so安裝成功的目錄,進入后會發(fā)現(xiàn)是如下信息。
/usr/local/php7.0/lib/php/extensions/no-debug-non-zts-20180731/openssl.so
5、找到php.ini,在最后面添加如下內(nèi)容
extension=openssl.so
重啟nginx,查看phpinfo(),到這里我們從php安裝到openssl擴展的安裝也就說完了。
總結(jié)
以上是生活随笔為你收集整理的amh 4.2 升级php_Centos系统 + AMH4.2面板 PHP升级7.3.5的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 为什么蒸的馒头硬底?
- 下一篇: 高压锅用电磁炉多大火