PHP7 學習筆記(一)Ubuntu 16.04 編譯安裝Nginx-1.10.三、 PHP7.0.九、Redis3.0 擴展、Phalcon3.1 擴展、Swoole1.9.8 擴展、ssh2擴展(

 ==================== PHP 7.0 編譯安裝==================php

wget http://cn2.php.net/get/php-7.0.9.tar.bz2/from/this/mirror -- 下載php鏡像
tar xvf mirror  -- 解壓鏡像
cd php-7.0.9/ -- 進入安裝目錄
sudo apt-get update -- 更新阿里雲庫
sudo apt-get install libkrb5-dev \ 
libc-client2007e \
libc-client2007e-dev \
libcurl4-openssl-dev \
libbz2-dev \
libjpeg-dev \
libmcrypt-dev \
libxslt1-dev \
libxslt1.1 \
libpq-dev \
libpng12-dev \
libfreetype6-dev \
build-essential \
git \

若是下面的./configure爆出缺什麼的錯誤,就在上面命令中加一條 lib<缺的東西名字>-dev(el)html

./configure \ --prefix=/opt/php-7.0.9 \ --with-config-file-path=/opt/php-7.0.9/etc \ --with-zlib-dir \ --with-freetype-dir \ --enable-mbstring \ --with-libxml-dir=/usr \ --enable-soap \ --enable-calendar \ --with-curl \ --with-mcrypt \ --with-zlib \ --with-gd \ --disable-rpath \ --enable-inline-optimization \ --with-bz2 \ --with-zlib \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-pcntl \ --enable-mbregex \ --enable-exif \ --enable-bcmath \ --with-mhash \ --enable-zip \ --with-pcre-regex \ --with-pdo-mysql \ --with-mysqli \ --with-mysql-sock=/var/run/mysqld/mysqld.sock \ --with-jpeg-dir=/usr \ --with-png-dir=/usr \ --enable-gd-native-ttf \ --with-openssl \ --with-fpm-user=www-data \ --with-fpm-group=www-data \ --enable-ftp \ --with-imap \ --with-imap-ssl \ --with-kerberos \ --with-gettext \ --with-xmlrpc \ --with-xsl \ --enable-opcache \ --enable-fpm

 檢查配置文件成功後出現的界面:成功經過mysql

 阿里雲ubuntu16.0 可能出現的錯誤:linux

configure: error: Cannot find OpenSSL's libraries

解決辦法:nginx

find / -name libssl.so   -- 輸出結果爲 /usr/lib/x86_64-linux-gnu/libssl.so

初步判斷它可能只會在 /usr/lib/ 下尋找 libssl.so 文件,在這裏作一個軟鏈接便可git

ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/

從新編譯便可github

make -- 編譯 或者根據你當前正在編譯機器cpu核數調參數加速編譯,好比我虛擬機是2核 make -j2 就能夠同時跑2個job加速編譯,編譯了差很少15分鐘
sudo make install  -- 安裝
/opt/php-7.0.9/bin/php -i      -- 基本配置信息 
/opt/php-7.0.9/bin/php -v    -- 注意這裏是查看的php-cli 的版本

運行php-fpm服務前,須要把相關的配置文件放好:web

sudo mv /opt/php-7.0.9/etc/php-fpm.conf.default /opt/php-7.0.9/etc/php-fpm.conf 
sudo mv /opt/php-7.0.9/etc/php-fpm.d/www.conf.default /opt/php-7.0.9/etc/php-fpm.d/www.conf
sudo cp ./php.ini-production /opt/php-7.0.9/etc/php.ini

修改fpm監聽的端口:redis

sudo vi /opt/php-7.0.9/etc/php-fpm.d/www.conf 
;listen = 127.0.0.1:9000   -- 默認是打開的,在前面加; 註釋掉
listen = /var/run/php7.0.9-fpm.sock -- 添加這一行

啓動 php-fpm 服務sql

sudo /opt/php-7.0.9/sbin/php-fpm  -- 啓動 php-fpm 服務

提示錯誤信息

2017/03/23 20:07:53 [crit] 18683#0: *1 connect() to unix:/var/run/php7.0.9-fpm.sock failed (13: Permission denied) while connecting to upstream, client: 127.0.0.1, 
server: localhost, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7.0.9-fpm.sock:", host: "127.0.0.1"

解決辦法,修改 www.conf 文件

sudo vi /opt/php-7.0.9/etc/php-fpm.d/www.conf

修改以前:

user = www-data
group = www-data

listen.owner = www-data
listen.group = www-data
;listen.mode = 0660

修改以後(注意當前用戶爲 tinywan:tinywan)

user = tinywan group = tinywan listen.owner = tinywan listen.group = tinywan listen.mode = 0660

而後重啓php-fpm 服務,顯示一樣的錯誤!查看日誌文件信息

給tinywan用戶組分配權限:

chown tinywan:tinywan /opt/php-7.0.9/etc/php-fpm.d/www.conf

chown tinywan:tinywan /var/run/php7.0.9-fpm.sock

繼續重啓php-fpm 服務,正常顯示

查看php 安裝版本,注意:這裏查看服務版本(和cli 版本不同的),這樣子就和瀏覽器查看的同樣的了

tinywan@tinywan:~$ sudo /opt/php-7.0.9/sbin/php-fpm -v PHP 7.0.9 (fpm-fcgi) (built: Mar 23 2017 19:53:02) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies

瀏覽器查看:

php  cli 版本查看

tinywan@tinywan:~$ php -v PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.15-0ubuntu0.16.04.4, Copyright (c) 1999-2017, by Zend Technologies

 

配置Nginx 配置文件nginx.conf,

fastcgi_pass unix:/var/run/php7.0.9-fpm.sock;

注意:若是 php-fpm 服務沒有開啓則會在Nginx 日誌報告如下錯誤信息:

 

 ================= 【2】Nginx 1.10.3 編譯安裝===============

 下載、解壓

wget http://nginx.org/download/nginx-1.10.3.tar.gz
tar -zxvf nginx-1.10.3.tar.gz

 Nginx 配置文件檢測

./configure --prefix=/usr/local/nginx --with-debug --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --user=www --group=www

錯誤提示!!!:

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

解決方法:

apt-get install libreadline-dev libncurses5-dev libpcre3-dev \
libssl-dev perl make build-essential curl

修改配置文件: vi /usr/local/nginx/conf/nginx.conf 

修改後的代碼:

    location ~ \.php$ {
            fastcgi_pass   unix:/var/run/php7.0.9-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

重啓Nginx和php-fpm

/usr/local/nginx/sbin/nginx -s reload

安裝完畢,測試

http://127.0.0.1/index.php -- 在瀏覽器查看

 》》》》CLI添加php的環境變量,將php編譯生成的bin目錄添加到當前Linux系統的環境變量中

 

sudo vim /etc/profile 
//添加如下內容: export PATH
=$PATH:/usr/local/php-7.1.8/bin //使生效
source
/etc/profile

 

 

===================== 【3】Redis 3.0 編譯安裝==================

sudo git clone -b php7 https://github.com/phpredis/phpredis.git -- 下載 記得移動到 mv phpredis /usr/local/ 文件夾下面

 

 sudo apt install php7.0-dev  -- 不安裝則會提示下面錯誤信息

sudo phpize  -- phpize是用來擴展php擴展模塊的,經過phpize能夠創建php的外掛模塊

cd phpredis/  -- 不進入該目錄則會提示下面錯誤信息

sudo ./configure

sudo make 

 安裝:

^Cwww@i:/usr/local/phpredis$ sudo make install Installing shared extensions: /usr/lib/php/20151012/

生成的redis.so文件

 

 sudo vim /opt/php-7.0.9/etc/php.ini   -- 添加擴展文件 extension=/usr/local/phpredis/modules/redis.so

 

注意要點:若是是PHP7.1以上安裝擴展會出現如下問題,下載編譯的拓展和你的PHP版本不符合

www@iZbqqeZ:~/tinywan/phpredis$ sudo service php-fpm restart Stopping PHP-FPM Server ... [OK] Starting PHP-FPM Server ... [29-Aug-2017 09:55:53] NOTICE: PHP message: PHP Warning: PHP Startup: redis: Unable to initialize module Module compiled with module API=20151012 PHP compiled with module API=20160303 These options need to match in Unknown on line 0 [OK]

以上問題的解決辦法,從新編譯安裝 並加上  --with-php-config

生成依賴文件

www@iZbqeZ:~/tinywan/phpredis$ /usr/local/php-7.1.8/bin/phpize //寫全phpize的路徑
Configuring for: 
PHP Api Version:
20160303
Zend Module Api No:
20160303
Zend Extension Api No:
320160303
配置時要將php-config的路徑附上加上  --with-php-config
www@iZ5qqeZ:~/tinywan/phpredis$ ./configure --with-php-config=/usr/local/php-7.1.8/bin/php-config //配置時要將php-config的路徑附上加上
checking for grep that handles long lines and -e... /bin/grep

~/tinywan/phpredis$ make -j2 // 編譯

www@iZbp14hmrbm6jyw9sa5qqeZ:~/tinywan/phpredis$ sudo make install  //安裝
Installing shared extensions: /usr/local/php-7.1.8/lib/php/extensions/no-debug-non-zts-20160303/  //生成的擴展文件在這裏

修改配置文件:sudo vim /usr/local/php-7.1.8/etc/php.ini 添加擴展文件路徑

配置信息查看

ps -aux | grep php-fpm   -- 查看php-fpm 進程

sudo killall -9 php-fpm   -- 經過程序的名字,直接殺死全部進程 ,如:php-fpm

 

sudo /opt/php-7.0.9/sbin/php-fpm  -- 重啓 php-fpm 服務

 cat /usr/local/nginx/html/index.php   -- 寫個redis 測試文件

瀏覽器測試效果圖

Redis 安裝完畢!

 

==================== 【4】Phcalcon 3.0 編譯安裝=========================

小提示:

官方聲明:https://github.com/phalcon/cphalcon/issues/12476

To anyone trying to compile Phalcon for php7, you have to use Zephir:(對於任何想要爲php7編譯Phalcon的人,你必須使用Zephir:)

第一種、官方的方式安裝(按照這種方式PHP7根本安裝不了)失敗了結!!!!

官方安裝連接:https://phalconphp.com/zh/download/linux

git clone --depth=1 "git://github.com/phalcon/cphalcon.git"
cd cphalcon/build
sudo ./install

 

卡在這裏安裝不了,有莫有啊!O(∩_∩)O哈哈~!!!!!!!!Pass

第二種、官方的博客參考安裝(經過擴展方式安裝)還失敗了結!!!!

官方建議:https://forum.phalconphp.com/discussion/2797/install-halts-on-ubuntu-14-04 

cd cphalcon/ext
export CFLAGS="-O2 -finline-functions -fvisibility=hidden"
phpize 
./configure --enable-phalcon
make
sudo make install

安裝後提示的錯誤信息,因而乎?安裝不了了?O(∩_∩)O哈哈~

./install find . -name \*.gcno -o -name \*.gcda | xargs rm -f find . -name \*.lo -o -name \*.o | xargs rm -f find . -name \*.la -o -name \*.a | xargs rm -f find . -name \*.so | xargs rm -f find . -name .libs -a -type d|xargs rm -rf rm -f libphp.la modules/* libs/* Cleaning.. Configuring for: PHP Api Version: 20151012 Zend Module Api No: 20151012 Zend Extension Api No: 320151012 checking for grep that handles long lines and -e... /bin/grep checking for egrep... /bin/grep -E checking for a sed that does not truncate output... /bin/sed checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ISO C89... none needed checking how to run the C preprocessor... gcc -E checking for icc... no checking for suncc... no checking whether gcc and cc understand -c and -o together... yes checking for system library directory... lib checking if compiler supports -R... no checking if compiler supports -Wl,-rpath,... yes checking build system type... x86_64-unknown-linux-gnu checking host system type... x86_64-unknown-linux-gnu checking target system type... x86_64-unknown-linux-gnu checking for PHP prefix... /usr checking for PHP includes... -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib checking for PHP extension directory... /usr/lib/php/20151012 checking for PHP installed headers prefix... /usr/include/php/20151012 checking if debug is enabled... no checking if zts is enabled... no checking for re2c... re2c checking for re2c version... 0.13.5 (ok) checking for gawk... no checking for nawk... nawk checking if nawk is broken... no checking whether to enable phalcon... yes, shared checking whether HAVE_BUNDLED_PCRE is declared... no checking whether HAVE_JSON is declared... no checking how to print strings... printf checking for a sed that does not truncate output... (cached) /bin/sed checking for fgrep... /bin/grep -F checking for ld used by gcc... /usr/bin/ld checking if the linker (/usr/bin/ld) is GNU ld... yes checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B checking the name lister (/usr/bin/nm -B) interface... BSD nm checking whether ln -s works... yes checking the maximum length of command line arguments... 1572864 checking whether the shell understands some XSI constructs... yes checking whether the shell understands "+="... yes checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop checking for /usr/bin/ld option to reload object files... -r checking for objdump... objdump checking how to recognize dependent libraries... pass_all checking for dlltool... no checking how to associate runtime and link libraries... printf %s\n checking for ar... ar checking for archiver @FILE support... @ checking for strip... strip checking for ranlib... ranlib checking for gawk... (cached) nawk checking command to parse /usr/bin/nm -B output from gcc object... ok checking for sysroot... no checking for mt... mt checking if mt is a manifest tool... no checking for ANSI C header files... yes checking for sys/types.h... yes checking for sys/stat.h... yes checking for stdlib.h... yes checking for string.h... yes checking for memory.h... yes checking for strings.h... yes checking for inttypes.h... yes checking for stdint.h... yes checking for unistd.h... yes checking for dlfcn.h... yes checking for objdir... .libs checking if gcc supports -fno-rtti -fno-exceptions... no checking for gcc option to produce PIC... -fPIC -DPIC checking if gcc PIC flag -fPIC -DPIC works... yes checking if gcc static flag -static works... yes checking if gcc supports -c -o file.o... yes checking if gcc supports -c -o file.o... (cached) yes checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes checking whether -lc should be explicitly linked in... no checking dynamic linker characteristics... GNU/Linux ld.so checking how to hardcode library paths into programs... immediate checking whether stripping libraries is possible... yes checking if libtool supports shared libraries... yes checking whether to build shared libraries... yes checking whether to build static libraries... no configure: creating ./config.status config.status: creating config.h config.status: executing libtool commands /bin/bash /root/cphalcon/build/php7/64bits/libtool --mode=compile gcc -I. -I/root/cphalcon/build/php7/64bits -DPHP_ATOM_INC -I/root/cphalcon/build/php7/64bits/include -I/root/cphalcon/build/php7/64bits/main -I/root/cphalcon/build/php7/64bits -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib -DPHALCON_RELEASE -DHAVE_CONFIG_H -march=native -mtune=native -O2 -fomit-frame-pointer -fvisibility=hidden -c /root/cphalcon/build/php7/64bits/phalcon.zep.c -o phalcon.lo libtool: compile: gcc -I. -I/root/cphalcon/build/php7/64bits -DPHP_ATOM_INC -I/root/cphalcon/build/php7/64bits/include -I/root/cphalcon/build/php7/64bits/main -I/root/cphalcon/build/php7/64bits -I/usr/include/php/20151012 -I/usr/include/php/20151012/main -I/usr/include/php/20151012/TSRM -I/usr/include/php/20151012/Zend -I/usr/include/php/20151012/ext -I/usr/include/php/20151012/ext/date/lib -DPHALCON_RELEASE -DHAVE_CONFIG_H -march=native -mtune=native -O2 -fomit-frame-pointer -fvisibility=hidden -c /root/cphalcon/build/php7/64bits/phalcon.zep.c -fPIC -DPIC -o .libs/phalcon.o ^[[Agcc: internal compiler error: Killed (program cc1) Please submit a full bug report, with preprocessed source if appropriate. See <file:///usr/share/doc/gcc-5/README.Bugs> for instructions. Makefile:194: recipe for target 'phalcon.lo' failed make: *** [phalcon.lo] Error 1

第三種、經過zephir(php7 推薦也是隻有這種方式能夠)

如何安裝zephir,看這裏:http://blog.csdn.net/u011142688/article/details/51619811

這也是官方做者方恨的一句話:https://github.com/phalcon/cphalcon/issues/12476

進入剛纔git下來的源碼包:

tinywan@tinywan:~$ cd /usr/local tinywan@tinywan:/usr/local$ git clone --depth=1 "git://github.com/phalcon/cphalcon.git" tinywan@tinywan:/usr/local/cphalcon$ cd build/ tinywan@tinywan:/usr/local/cphalcon/build$ ls gccarch.c gcccpuopt gen-build.php install php5 php7 README.md _resource tinywan@tinywan:/usr/local/cphalcon/build$ cd php7/ tinywan@tinywan:/usr/local/cphalcon/build/php7$ ls 32bits 64bits safe tinywan@tinywan:/usr/local/cphalcon/build/php7$ cd 64bits/ tinywan@tinywan:/usr/local/cphalcon/build/php7/64bits$ ls config.m4 config.w32 phalcon.zep.c phalcon.zep.h php_phalcon.h tinywan@tinywan:/usr/local/cphalcon/build/php7/64bits$ sudo phpize Configuring for: PHP Api Version: 20151012 Zend Module Api No: 20151012 Zend Extension Api No: 320151012 tinywan@tinywan:/usr/local/cphalcon/build/php7/64bits$ ls acinclude.m4 autom4te.cache config.guess config.m4 configure config.w32 ltmain.sh missing phalcon.zep.c php_phalcon.h aclocal.m4 build config.h.in   config.sub  configure.in  install-sh  Makefile.global  mkinstalldirs  phalcon.zep.h  run-tests.php

 

記得安裝這個:

sudo apt-get install re2c libpcre3-dev   -- 否則會提示一下錯誤

開始了

 在這裏時候可能要多等會時間去編譯 ,完成輸出如下界面

 

root@iZbp1cvkjh1vlb7ff5tspdZ:/home/www# find / -name phalcon.so   -- 查找剛纔編譯的 phalcon.so 文件
/usr/lib/php/20151012/phalcon.so

修改配置文件:vim /opt/php-7.0.9/etc/php.ini  添加一下內容便可

重啓  php-fpm  (重啓前先kill掉之前的進程哦!!!!!!!)

/opt/php-7.0.9/sbin/php-fpm   --

 phpinfo()文件輸出,安裝好了!

 =========================【5】Swoole擴展 =================

說明:swoole項目已收錄到PHP官方擴展庫,除了手工下載編譯外,還能夠經過PHP官方提供的pecl命令,一鍵下載安裝swoole:

pecl install swoole

安裝完畢後一下界面

咱們能夠看到.so文件安裝的路徑了

/usr/lib/php/20151012/swoole.so

修改配置web配置文件:sudo vim /opt/php-7.0.9/etc/php.ini

重啓nginx和php-fpm 瀏覽器查看便可:

完成安裝

測試服務是否能夠啓用

官方案例:https://linkeddestiny.gitbooks.io/easy-swoole/content/book/chapter01/echo_server.html

至於出現的錯誤信息:

ERROR swFactoryProcess_finish (ERROR 1004): send 66 byte failed, because session#134 is closed.

本身去看官方github 提問解決:https://github.com/swoole/swoole-src/issues/650

======================上面的都忘記了給cli模式安裝擴展模式了

安裝:sudo apt install php7.0-cli

tinywan@tinywan:~$ php -v PHP 7.0.15-0ubuntu0.16.04.4 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.15-0ubuntu0.16.04.4, Copyright (c) 1999-2017, by Zend Technologies

一樣的找到cli 模式的配置文件

sudo vim /etc/php/7.0/cli/php.ini

注意:在命令行模式沒有安裝phalcon 擴展

能夠看出已經安裝成功了!( 參數 --ri 顯示擴展 的配置信息 )

命令行模式安裝:

curl -s "https://packagecloud.io/install/repositories/phalcon/stable/script.deb.sh" | sudo bash

# Ubuntu 16.04+, Debian 9+
sudo apt-get install php7.0-phalcon

====================【6】安裝SSH2擴展庫讓PHP經過SSH鏈接操做遠程服務器

一、編譯安裝libssh2

wget http://www.libssh2.org/download/libssh2-1.2.9.tar.gz tar zxvf libssh2-1.2.9.tar.gz cd libssh2-1.2.9 ./configure && make && make install

錯誤解決:Ubuntu 14.04 下安裝 Ceph 的錯誤: no suitable crypto library found

crypto是什麼呢? 是OpenSSL 加密庫(lib), 這個庫須要openssl-devel包 ,在ubuntu中就是 libssl-dev RedHat Fedora 平臺 yum -y install openssl-devel Debian ,ubunu 平臺 apt-get install libssl-dev

二、編譯安裝ssh2

(1)官方地址:http://pecl.php.net/package/ssh2

注意:這裏安裝的是要支持php7的,因此在這裏咱們選擇下載1.0的版本

(2)如下爲具體的安裝步驟

-- 下載
wget http://pecl.php.net/get/ssh2-1.0.tgz -- 解壓
tar -xvf ssh2-1.0.tgz -- 複製目錄到指定位置
sudo cp ssh2-1.0 -R /usr/bin/

-- 進入指定目錄
cd /usr/bin/ssh2-1.0/

-- 擴展模塊
sudo phpize -- 檢查配置文件
sudo ./configure --with-ssh2

-- 編譯
sudo make --安裝
sudo make install --查看安裝狀況
cd /usr/lib/php/20151012/

-- 修改配置文件
sudo vim /etc/php/7.0/cli/php.ini -- 添加如下內容
extension=/usr/lib/php/20151012/ssh2.so -- 查看模塊是否安裝成功
php -m | grep ssh2 ssh2 -- 安裝結束

(3)安裝成功

 

修改php.ini配置文件 sudo vim /usr/local/php-7.2.8/etc/php.ini,添加:extension=ssh2.so

 

(4)可能會出現的錯誤

【1】phpize 找不到,請使用絕對路徑:sudo /usr/local/php-7.2.8/bin/phpize

【2】configure: error: Cannot find php-config. Please use --with-php-config=PATH

  解決辦法:sudo ./configure --with-ssh2 --with-php-config=/usr/local/php-7.2.8/bin/php-config

【3】安裝錯誤

Installing shared extensions:     /usr/local/php-7.2.8/lib/php/extensions/no-debug-non-zts-20160303/
Makefile:88: recipe for target 'install-modules' failed make: *** [install-modules] Error 1 

 解決辦法:

cp /usr/bin/ssh2-1.1.2/modules/ssh2.so /usr/local/php-7.2.8/lib/php/extensions/no-debug-non-zts-20160303/  

 三、PHP經過SSH鏈接遠程服務器示例代碼,php登錄ssh執行命令

<?php $connection=ssh2_connect('172.16.10.3',22); ssh2_auth_password($connection,$user,$pass); $cmd="/data/script/start.sh knowledgelib_fix_2"; ssh2_exec($connection,$cmd); ?>

 四、遠程內存顯示案例

 

 composer 和php7.0遇到的一些坑 》》》》》》》》》》

 

剛開始覺得是編譯安裝的PHP7.0的問題,結果不是,是ThingPHP5.0 中的一些擴展不支持PHP7.0

 

 14.0 ----------------------

問題一:unable to locate package php7.0 and libapache2-mod-php7.0

解決辦法:https://wyldeplayground.net/unable-to-locate-package-php7-0libapache2-mod-php7-0/

 Phalcon 框架的第四種編譯方式(官方)

》》》》Ubuntu 14.04.1 LTS---------------Phalcon 框架的編譯

PHP 7.0.22 穩定版

1、安裝 php-zephir-parser

sudo apt-get install php7.0-dev gcc make re2c autoconf

提示錯誤:

解決:

一、php7的存儲庫的問題,添加php7 ppa

sudo add-apt-repository ppa:ondrej/php

二、而後更新

sudo apt-get update

三、如今作一個搜索來確認php7是有的

sudo apt search php7

四、如今安裝php7包

sudo apt install php7.0-mysql php7.0-curl php7.0-json php7.0-cgi  php7.0 libapache2-mod-php7.0

2、安裝Phalcon 擴展

 一、克隆下來

git clone https://github.com/phalcon/cphalcon.git 

二、按照如下說明爲您的平臺生成二進制擴展名:

git clone git://github.com/phalcon/cphalcon.git
cd cphalcon/build sudo ./install

三、配置php.ini

www@ubuntu1:~$ sudo find / -name phalcon.so [sudo] password for www: /usr/lib/php/20151012/phalcon.so /usr/local/cphalcon/build/php7/64bits/modules/phalcon.so /usr/local/cphalcon/build/php7/64bits/.libs/phalcon.so
sudo vim /opt/php7.0.22/etc/php.ini

》》》》》》》如下錯誤爲沒有更換阿里雲的問

error01: configure: error: Cannot find OpenSSL's libraries
--with-openssl=no wget https://openssl.org/source/openssl-1.1.0f.tar.gz
 configure: error: Please reinstall the BZip2 distribution apt-get install BZip2 Cannot find autoconf. Please check your autoconf installation and the 解決辦法: sudo apt-get install autoconf configure: error: Cannot find php-config. Please use --with-php-config=PATH 解決辦法: 通常出現這個錯誤說明你執行 ./configure 時 --with-php-config 這個參數配置路徑錯誤致使的。 www@ubuntu1:/usr/local/phpredis$ whereis php-config php-config: /opt/php7.1.8/bin/php-config sudo ./configure --with-php-config=/opt/php7.1.8/bin/php-config

 

 》》》》 Zephir 寫PHP擴展的,編譯Phalcon框架的源碼爲zep 編碼的問題與解決

PHP版本:7.0.22

系統:Ubuntu 14.04.1 LTS

出現的錯誤問題:

cphalcon$ zephir build --export-classes PHP Fatal error: Uncaught Error: Call to undefined function Zephir\utf8_decode() in /home/www/zephir/Library/Compiler.php:2023 Stack trace: #0 /home/www/zephir/Library/Compiler.php(1011): Zephir\Compiler->createProjectFiles('phalcon') #1 /home/www/zephir/Library/Compiler.php(1062): Zephir\Compiler->generate(Object(Zephir\Commands\CommandBuild)) #2 /home/www/zephir/Library/Compiler.php(1200): Zephir\Compiler->compile(Object(Zephir\Commands\CommandBuild), false) #3 /home/www/zephir/Library/Compiler.php(1297): Zephir\Compiler->install(Object(Zephir\Commands\CommandBuild), false) #4 /home/www/zephir/Library/Commands/CommandAbstract.php(107): Zephir\Compiler->build(Object(Zephir\Commands\CommandBuild)) #5 /home/www/zephir/Library/Bootstrap.php(200): Zephir\Commands\CommandAbstract->execute(Object(Zephir\Config), Object(Zephir\Logger)) #6 /home/www/zephir/compiler.php(22): Zephir\Bootstrap::boot() #7 {main} thrown in /home/www/zephir/Library/Compiler.php on line 2023 Fatal error: Uncaught Error: Call to undefined function Zephir\utf8_decode() in /home/www/zephir/Library/Compiler.php:2023 Stack trace: #0 /home/www/zephir/Library/Compiler.php(1011): Zephir\Compiler->createProjectFiles('phalcon') #1 /home/www/zephir/Library/Compiler.php(1062): Zephir\Compiler->generate(Object(Zephir\Commands\CommandBuild)) #2 /home/www/zephir/Library/Compiler.php(1200): Zephir\Compiler->compile(Object(Zephir\Commands\CommandBuild), false) #3 /home/www/zephir/Library/Compiler.php(1297): Zephir\Compiler->install(Object(Zephir\Commands\CommandBuild), false) #4 /home/www/zephir/Library/Commands/CommandAbstract.php(107): Zephir\Compiler->build(Object(Zephir\Commands\CommandBuild)) #5 /home/www/zephir/Library/Bootstrap.php(200): Zephir\Commands\CommandAbstract->execute(Object(Zephir\Config), Object(Zephir\Logger)) #6 /home/www/zephir/compiler.php(22): Zephir\Bootstrap::boot() #7 {main}

解決辦法:因爲缺乏xml擴展,安裝擴展便可:sudo apt-get install php7.0-xml

官方詳解:https://github.com/phalcon/zephir/issues/1575#issuecomment-325331159

之後遇到問題參考擴展:ubuntu全部php擴展 php-7.0 擴展列表

sudo apt-get install php7.0-bcmath sudo apt-get install php7.0-bz2 sudo apt-get install php7.0-calendar sudo apt-get install php7.0-ctype sudo apt-get install php7.0-curl sudo apt-get install php7.0-dom sudo apt-get install php7.0-enchant sudo apt-get install php7.0-exif sudo apt-get install php7.0-fileinfo sudo apt-get install php7.0-ftp sudo apt-get install php7.0-gd sudo apt-get install php7.0-gettext sudo apt-get install php7.0-gmp sudo apt-get install php7.0-iconv sudo apt-get install php7.0-intl sudo apt-get install php7.0-json sudo apt-get install php7.0-ldap sudo apt-get install php7.0-mbstring sudo apt-get install php7.0-mysqli sudo apt-get install php7.0-mysqlnd sudo apt-get install php7.0-opcache sudo apt-get install php7.0-pdo sudo apt-get install php7.0-phar sudo apt-get install php7.0-posix sudo apt-get install php7.0-pspell sudo apt-get install php7.0-readline sudo apt-get install php7.0-shmop sudo apt-get install php7.0-simplexml sudo apt-get install php7.0-snmp sudo apt-get install php7.0-soap sudo apt-get install php7.0-sockets sudo apt-get install php7.0-sqlite3 sudo apt-get install php7.0-sysvmsg sudo apt-get install php7.0-sysvsem sudo apt-get install php7.0-sysvshm sudo apt-get install php7.0-wddx sudo apt-get install php7.0-xml sudo apt-get install php7.0-xsl 如下不能一次性所有安裝,由於要選y sudo apt-get install php7.0-recode sudo apt-get install php7.0-dba sudo apt-get install php7.0-imap sudo apt-get install php7.0-interbase sudo apt-get install php7.0-odbc sudo apt-get install php7.0-pgsql sudo apt-get install php7.0-tidy sudo apt-get install php7.0-zip 如下部分沒法安裝 我使用的是ubuntu 16.04 32位系統,若是有不一樣狀況還請不寧賜教, xmlreader xmlrpc xmlwriter pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite com_dotnet date filter hash libxml mcrypt oci8 openssl pcntl pcre reflection session skeleton spl standard vtokenizer zlib php-7.0 擴展列表 bcmath bz2 calendar com_dotnet ctype curl date dba dom enchant exif fileinfo filter ftp gd gettext gmp hash iconv imap interbase intl json ldap libxml mbstring mcrypt mysqli mysqlnd oci8 odbc opcache openssl pcntl pcre pdo pdo_dblib pdo_firebird pdo_mysql pdo_oci pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix pspell readline recode reflection session shmop simplexml skeleton snmp soap sockets spl sqlite3 standard sysvmsg sysvsem sysvshm tidy vtokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip zlib

 

 PHP7.1.8 安裝

./configure \ --prefix=/usr/local/php-7.1.8 \ --with-config-file-path=/usr/local/php-7.1.8/etc \ --with-zlib-dir \ --with-freetype-dir \ --enable-mbstring \ --with-libxml-dir=/usr \ --enable-soap \ --enable-calendar \ --with-curl \ --with-mcrypt \ --with-zlib \ --with-gd \ --disable-rpath \ --enable-inline-optimization \ --with-bz2 \ --with-zlib \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-pcntl \ --enable-mbregex \ --enable-exif \ --enable-bcmath \ --with-mhash \ --enable-zip \ --with-pcre-regex \ --with-pdo-mysql \ --with-mysqli \ --with-mysql-sock=/var/run/mysqld/mysqld.sock \ --with-jpeg-dir=/usr \ --with-png-dir=/usr \ --enable-gd-native-ttf \ --with-openssl \ --with-fpm-user=www \ --with-fpm-group=www \ --enable-ftp \ --with-imap \ --with-imap-ssl \ --with-kerberos \ --with-gettext \ --with-xmlrpc \ --with-xsl \ --enable-opcache \ --enable-fpm

 

錯誤提示:

configure: error: Please reinstall the BZip2 distribution sudo apt-get install BZip2

 

 

 

PHP安裝參考:https://segmentfault.com/q/1010000006138364

不須要編譯的安裝:http://xhinliang.win/2016/04/03/LNMP_setup/

ubuntu完全乾淨卸載MySQL、Apache二、Php的方法(各版本通用

相關文章
相關標籤/搜索