编译安装php7

来源:互联网 发布:网络驱动器异常 编辑:程序博客网 时间:2024/04/28 14:00

记录一下编译安装PHP7的过程,希望大家能够用得上。另外,推荐大家多多使用编译安装,不要排斥,编译安装有很多好处。


第一步,准备工作

新申请的机器是CensOS 7.4的系统,可以直接用yum安装工具包

yum -y groupinstall "Development tools"yum -y install gcc gcc-c++ autoconf automake libtool make cmake zlib zlib-devel openssl openssl-devel pcre-devel libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt-devel gd-devel libcurl-devel openssl-devel libxslt



第二步,下载PHP7源代码

用github下载或者其他源都可以,这里我用的是github的源

wget https://github.com/php/php-src/archive/master.zip
或者

git clone https://github.com/php/php-src.git   //需要安装git

下载下来后解压


第三步,编译安装

运行configure

./configure \--prefix=/usr/local/php7 \--exec-prefix=/usr/local/php7 \--bindir=/usr/local/php7/bin \--sbindir=/usr/local/php7/sbin \--includedir=/usr/local/php7/include \--libdir=/usr/local/php7/lib/php \--mandir=/usr/local/php7/php/man \--with-config-file-path=/usr/local/php7/etc \--with-mysql-sock=/var/run/mysql/mysql.sock \--with-mcrypt=/usr/include \--with-mhash \--with-openssl \--with-mysql=shared,mysqlnd \--with-mysqli=shared,mysqlnd \--with-pdo-mysql=shared,mysqlnd \--with-gd \--with-iconv \--with-zlib \--enable-zip \--enable-inline-optimization \--disable-debug \--disable-rpath \--enable-shared \--enable-xml \--enable-bcmath \--enable-shmop \--enable-sysvsem \--enable-mbregex \--enable-mbstring \--enable-ftp \--enable-gd-native-ttf \--enable-pcntl \--enable-sockets \--with-xmlrpc \--enable-soap \--without-pear \--with-gettext \--enable-session \--with-curl \--with-jpeg-dir \--with-freetype-dir \--enable-opcache \--enable-fpm \--with-fpm-user=nginx \--with-fpm-group=nginx \--without-gdbm
然后执行

make & make test & make install



第四步,准备配置文件

上面的步骤已经安装好了php7,路径在/usr/local/php7下面,但是默认是没有配置文件的,需要准备一下

cp php.ini-production /usr/local/php7/etc/php.inicp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.confcp /usr/local/php7/etc/php-fpm.d/www.conf.default  /usr/local/php7/etc/php-fpm.d/www.conf

至此,可以使用php7了。


原创粉丝点击