PHP7 学习笔记(一)Ubuntu 16.04 编译安装Nginx-1.10.3、 PHP7.0.9、Redis3.0 扩展、Phalcon3.1 扩展、Swoole1.9.8 扩展、ssh2扩展(全程编译安装)

 ==================== PHP 7.0 编译安装==================

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)

./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

 检查配置文件成功后出现的界面:成功通过

 阿里云ubuntu16.0 可能出现的错误:

configure: error: Cannot find OpenSSL's libraries

解决办法:

find / -name libssl.so   -- 输出结果为 /usr/lib/x86_64-linux-gnu/libssl.so

初步判断它可能只会在 /usr/lib/ 下寻找 libssl.so 文件,在这里做一个软连接即可

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

重新编译即可

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服务前,需要把相关的配置文件放好:

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监听的端口:

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 服务

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连接操作远程服务器

1、编译安装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

2、编译安装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/  

 3、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);
?>

 4、远程内存显示案例

 

 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 稳定版

一、安装 php-zephir-parser

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

提示错误:

解决:

1、php7的存储库的问题,添加php7 ppa

sudo add-apt-repository ppa:ondrej/php

2、然后更新

sudo apt-get update

3、现在做一个搜索来确认php7是有的

sudo apt search php7

4、现在安装php7包

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

二、安装Phalcon 扩展

 1、克隆下来

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

2、按照以下说明为您的平台生成二进制扩展名:

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

3、配置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、Apache2、Php的方法(各版本通用

posted @ 2017-03-23 21:18  Tinywan  阅读(3269)  评论(1编辑  收藏  举报