该内容主要来自鲁玉成云的随笔,出自http://www.cnblogs.com/luyucheng/p/6084735.html

 

./configure --prefix=/usr/local/servers/php7 \(由于要用时使用PHP7和PHP5.6,故而给PHP7指定了目录)
--with-config-file-path=/usr/local/servers/php7/etc \
--with-mysqli \
--enable-fpm \
--enable-ftp \
--enable-xml \
--enable-zip \
--enable-soap \
--enable-pcntl \
--enable-shmop \
--enable-bcmath \
--enable-shared \
--enable-mysqlnd \
--enable-opcache \
--enable-session \
--enable-sockets \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-inline-optimization \
--with-gd \
--with-curl \
--with-zlib \
--with-mcrypt \
--with-mhash \
--with-iconv \
--with-xmlrpc \
--with-gettext \
--with-jpeg-dir \
--with-freetype-dir \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-openssl \
--without-gdbm \
--without-pear \
--disable-debug \
--disable-rpath \

//--with-iconv=/usr/local/libiconv \  (按照博主的configure一直不成功,报undefined reference to `libiconv_open'这样的错,故而先按照https://www.cnblogs.com/52php/p/6197428.html 这个先编译了 libiconv
--disable-fileinfo

事实上libconv编译成功之后仍然报错,又找到一个解决办法,https://blog.csdn.net/ikscher/article/details/51009584#reply

回到 cd /usr/local/src/php7-

在执行完 ./configure ... 之后,修改下 Makefile,(找不到Makefile 可以用ls看下 然后vim Makefile)找到其中的EXTRA_LIBS 在后面添加 -liconv

EXTRA_LIBS -lcrypt -lz -lcrypt -lrt -lmysqlclient -lmcrypt -lldap -llber -lfreetype -lpng -lz -ljpeg -lcurl -lz -lrt -lm -ldl -lnsl -lrt -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lcurl -ldl -lgssapi_krb5 -lkrb5 -lk5crypto 

-lcom_err -lidn -lssl -lcrypto -lz -lxml2 -lz -lm -lssl -lcrypto -ldl -lz -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lxml2-lz -lm -lcrypt  -liconv

 

----PHP5.6-----

./configure --prefix=/usr/local/servers/php \
--with-config-file-path=local/servers/php/etc
--with-mysql \
--with-mysqli \
--with-iconv-dir \
--with-zlib \
--with-zlib-dir \
--with-libxml-dir \
--enable-xml \
--with-curl \
--enable-dba \
--enable-fpm \
--enable-mbstring \
--with-gd \
--with-openssl \
--with-pdo-mysql \
--without-pdo-sqlite \
--with-mcrypt \
--with-mhash \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--with-libdir=/usr/lib64 \
--with-jpeg-dir=/usr/lib64 \
--with-freetype-dir=/usr/lib64 \
--with-png-dir=/usr/lib64 \
--with-iconv-dir=/usr/local/libiconv \
--enable-gd-native-ttf \
--with-gettext \
--enable-pcntl \
--enable-sysvmsg \
--enable-sysvsem \

 

make && make install

vim /etc/profile
PATH=/usr/local/mysql/bin:/usr/local/servers/php7/bin:$PATH(/usr/local/servers/php7/bin:加入环境变量)

PHP5.6的编译使用了同上的configure (注意修改--prefix=/usr/local/servers/php \ --exec-prefix=/usr/local/servers/php \ 目录以作区别)

 

mv php-fpm.conf.default php-fpm.conf
mv php-fpm.d/www.conf.default php-fpm.d/www.conf 
PHP7时这些命令均修改成(注意其他条命令目录)
mv php-fpm.conf.default php-fpm.conf
mv php-fpm.d/www.conf.default php-fpm.d/www.conf
cp /usr/local/src/php-7.1.3/sapi/fpm/init.d.php-fpm /etc/init.d/php7-fpm(只需将/etc/init.d/目录下的改成php7-fpm以作区分)
chmod +x /etc/init.d/php7-fpm

chkconfig --add php7-fpm
chkconfig php7-fpm on
./sbin/nginx -s reload(重启)

vim /usr/local/nginx/conf/nginx.conf (i 插入)

server
{
    listen 80;
    server_name localhost;
    index index.php index.html index.htm;
    root  /home/wwwroot/zpdydhl;
    charset utf-8;
    
    location ~* \.php$ {
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                fastcgi_intercept_errors on;
        }

  #  access_log  /home/wwwlogs/access.log  access;
}

server
{
    listen 8098;
    server_name localhost;
    index index.php index.html index.htm;
    root  /home/wwwroot/zpdydhl_api;

    location / {
        if (!-e $request_filename) {
           rewrite ^(.*)$ /index.php?s=$1 last;
            break;   
        }
        }

    location ~ .*\.php$ {
    fastcgi_pass 127.0.0.1:9001;(vim /usr/local/php7/etc/php-fpm.d/www.conf 将listen改为9001,重启./sbin/php-fpm)
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
    }
    

    access_log  /home/wwwlogs/access.log  access;
}

esc键 :wq(保存并退出)
/etc/init.d/php-fpm start
/etc/init.d/php-fpm stop
/etc/init.d/php-fpm restart
/etc/init.d/php-fpm reload

lsof -i:9000

PHP7如果是yaf框架还要安装yaf扩展以及yaconf扩展
http://pecl.php.net/package/yaconf http://pecl.php.net/package/yaf
posted on 2018-04-03 16:49  gypsy  阅读(191)  评论(0编辑  收藏  举报