最近使用了些php的开源东西,其中很多模块都要使用包管理工具composer,的确很方便。下面就直接开始安装过程。
源码下载,php官网下载有很多镜像。笔者选择的php版本php-7.1.17.tar.gz;
一般习惯去下载tar.gz,-_-||因为这个解压命令比较熟悉。
编译安装命令:
./configure --prefix=/usr/local/php7.1.17 \
--enable-fpm \
--enable-mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pdo-pgsql \
--with-pgsql \
--with-curl \
--with-freetype-dir \
--with-pear \
--enable-pdo \
--enable-opcache \
--enable-soap \
--with-curl \
--enable-ftp \
--with-pdo-sqlite \
--enable-mbstring
编译期间报错,都是一些依赖的问题;
# yum install libxml2-devel -y
# yum -y install postgresql-devel
# yum install openssl openssl-devel
# yum install curl-devel
编译错误大家去baidu,Google就行了。
下面安装composer,很简单两行命令:
# curl -sS https://getcomposer.org/installer | php
执行报错
Some settings on your machine make Composer unable to work properly.
Make sure that you fix the issues listed below and run this script again:
The openssl extension is missing, which means that secure HTTPS transfers are impossible.
If possible you should enable it or recompile php with --with-openssl
说php编译的时候没有开始OpenSSL。
进入php安装源码目录
# cd php-7.1.17/ext/openssl
这个地方需要手动把config0改名为config。然后再phpize
# mv config0.m4 config.m4
# phpize
# ./configure --with-php-config=/usr/local/php7.1.17/bin/php-config --with-openssl
# make && make install
安装完成扩展还得去php.ini把扩展 给打开,可能同学安装完了发现找不到php.ini文件。现在需要自己在源码包把php.ini拷贝到安装路径。
然后把扩展目录给添加好就ok了。
# php -m | grep openssl
查看是否安装成功,然后再执行安装composer。
到此安装php7完成。收尾工作是把安装php添加到PATH,再执行下sourse即可。