centos7.5环境下编译安装php7.0.30并安装redis和mongo扩展

1.安装php7.0.30的脚本

# vim install_php.sh

#!/bin/bash
# 安装基本依赖
yum install -y gcc gcc-c++ htop telnet iotop iptraf iftop make logrotate xinetd ntsysv  sysstat perl autoconf libjpeg libjpeg-devel libpng libpng-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel e2fsprogs e2fsprogs-devel krb5-devel libidn libidn-devel libxml2 libxml2-devel libxslt-devel libevent-devel libtool libtool-ltdl bison  ntpdate  patch vim wget openssh-clients bind-utils
yum -y install libicu-devel libpng12 libpng12-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel mysql pcre-devel  libxslt-devel  curl-devel

## zlib
echo "*******************install zlib start*******************"
cd /usr/local/src && wget http://www.zlib.net/zlib-1.2.11.tar.gz
tar -xvzf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure --prefix=/usr/local/zlib
make && make install
ls -l /usr/local/zlib
echo "*******************install zlib end*******************"

## openssl

echo "*******************install openssl start*******************"
cd /usr/local/src && wget https://www.openssl.org/source/openssl-1.1.0e.tar.gz --no-check-certificate
tar -xzf openssl-1.1.0e.tar.gz
cd openssl-1.1.0e/
./config --prefix=/usr/local/openssl
./config -t
make && make install
ls /usr/local/bin/openssl  -l
echo "*******************install openssl end*******************"

## freetype
echo "*******************install freetype start*******************"
cd /usr/local/src && wget https://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.gz --no-check-certificate
tar -zxvf freetype-2.4.0.tar.gz
cd freetype-2.4.0/
./configure --prefix=/usr/local/freetype
make && make install
echo "*******************install freetype end*******************"

## PHP安装
echo "*******************install php-7.0.30 start*******************"

cd /usr/local/src && wget http://cn2.php.net/distributions/php-7.0.30.tar.gz
tar -zxvf php-7.0.30.tar.gz
cd php-7.0.30
./configure  --prefix=/usr/local/php7.0.30 --mandir=/usr/local/php7.0.30/share/man  --infodir=/usr/local/php7.0.30/share/info  --enable-fpm --enable-mbstring --enable-zib --enable-bcmath --enable-opcache --enable-pcnt --enable-soa --enable-calenda --enable-exif --enable-ftp --enable-intl --with-curl --with-gd --with-jpeg-dir=/usr/local/zlib --with-png-dir=/usr/local/zlib --with-mysql --with-pdo_mysql --with-mcrypt --with-freetype-dir=/usr/local/freetype --with-zlib=/usr/local/zlib --with-openssl

make && make install
if [ $? != 0 ];then
exit 7
fi
ln -s /usr/local/php7.0.30  /usr/local/php
cp /usr/local/src/php-7.0.30/php.ini-development /usr/local/php7.0.30/lib/php.ini
cp /usr/local/php7.0.30/etc/php-fpm.conf.default /usr/local/php7.0.30/etc/php-fpm.conf
cp  /usr/local/php7.0.30/etc/php-fpm.d/www.conf.default /usr/local/php7.0.30/etc/php-fpm.d/www.conf

echo "*******************install php-7.0.30 end*******************"

## Mongo扩展
echo "*******************install Mongo扩展 start*******************"
cd /usr/local/src && wget http://pecl.php.net/get/mongodb-1.5.2.tgz
tar -zxvf mongodb-1.5.2.tgz
cd mongodb-1.5.2/
/usr/local/php7.0.30/bin/phpize
./configure --with-php-config=/usr/local/php7.0.30/bin/php-config
make && make install
ls /usr/local/php7.0.30/lib/php/extensions/no-debug-non-zts-20151012/

echo "*******************install Mongo扩展 end*******************"

## Redis扩展
echo "*******************install Redis扩展 start*******************"
cd /usr/local/src && wget http://pecl.php.net/get/redis-4.0.2.tgz
tar -zxvf redis-4.0.2.tgz
cd redis-4.0.2/
/usr/local/php7.0.30/bin/phpize
./configure --with-php-config=/usr/local/php7.0.30/bin/php-config
make && make install
ls /usr/local/php7.0.30/lib/php/extensions/no-debug-non-zts-20151012/
echo "*******************install Redis扩展 end*******************"

## tideways扩展
echo "*******************install tideways扩展 start*******************"
cd /usr/local/src && wget https://s3-eu-west-1.amazonaws.com/tideways/extension/5.0.18/tideways-php-5.0.18-x86_64.tar.gz --no-check-certificate
tar -zxf tideways-php-5.0.18-x86_64.tar.gz
cd tideways-5.0.18
/usr/local/php7.0.30/bin/phpize
cp tideways-php-7.0.so /usr/local/php7.0.30/lib/php/extensions/no-debug-non-zts-20151012/
cd /usr/local/php7.0.30/lib/php/extensions/no-debug-non-zts-20151012/
mv tideways-php-7.0.so tideways.so
echo "*******************install tideways扩展 end*******************"

## ioncube_loaders 扩展
echo "*******************install ioncube_loaders start*******************"
cd /usr/local/src && wget https://downloads.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz --no-check-certificate
tar -zxvf  ioncube_loaders_lin_x86-64.tar.gz
cd ioncube/
ls
cp ioncube_loader_lin_7.0.so  /usr/local/php7.0.30/lib/php/extensions/no-debug-non-zts-20151012/
echo "*******************install ioncube_loaders end*******************"

2.修改配置文件

# php.ini配置文件

# vim /usr/local/php7.0.30/lib/php.ini
[dba]

extension_dir=/usr/local/php/lib/php/extensions/no-debug-non-zts-20151012/
extension=redis.so
extension=mongodb.so

[tideways]
extension=tideways.so
;不需要自动加载,在程序中控制就行
tideways.auto_prepend_library=0
;频率设置为100,在程序调用时能改
tideways.sample_rate=100

[ionCube Loader]
zend_extension=ioncube_loader_lin_7.0.so

# php-fpm.conf文件
[[email protected]_filmora_file01:/usr/local/php]# egrep -v ‘^$|^;‘ /usr/local/php/etc/php-fpm.conf
[global]
 process.max = 256
rlimit_files = 65535
events.mechanism = epoll
include=/usr/local/php7.0.30/etc/php-fpm.d/*.conf

sed -i ‘s#user = nobody#user = apache#g‘ /usr/local/php7.0.30/etc/php-fpm.d/www.conf
sed -i ‘s#group = nobody#group = users#g‘ /usr/local/php7.0.30/etc/php-fpm.d/www.conf

# www.conf文件
[[email protected]_filmora_file01:/usr/local/php]# egrep -v ‘^$|^;‘ /usr/local/php/etc/php-fpm.d/www.conf
[www]
user = apache
group = users
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 500
pm.start_servers = 32
pm.min_spare_servers = 16
pm.max_spare_servers = 64
pm.process_idle_timeout = 10s;
pm.max_requests = 10240
request_terminate_timeout = 100
rlimit_core = 8

##################启动脚本

# 生成软连接
[[email protected]_filmora_file02:/usr/local/src]# rm -f /usr/local/php
[[email protected]_filmora_file02:/usr/local/src]# ln -s /usr/local/php7.0.30/ /usr/local/php

[[email protected]_filmora_file01:/usr/local/src/tideways-5.0.18]# vim /etc/init.d/php-fpm
#! /bin/sh

### BEGIN INIT INFO
# Provides:          php-fpm
# Required-Start:    $remote_fs $network
# Required-Stop:     $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts php-fpm
# Description:       starts the PHP FastCGI Process Manager daemon
### END INIT INFO

prefix=/usr/local/php
exec_prefix=${prefix}

php_fpm_BIN=${exec_prefix}/sbin/php-fpm
php_fpm_CONF=${prefix}/etc/php-fpm.conf
php_fpm_PID=${prefix}/var/run/php-fpm.pid

php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"

wait_for_pid () {
    try=0

    while test $try -lt 35 ; do

        case "$1" in
            ‘created‘)
            if [ -f "$2" ] ; then
                try=‘‘
                break
            fi
            ;;

            ‘removed‘)
            if [ ! -f "$2" ] ; then
                try=‘‘
                break
            fi
            ;;
        esac

        echo -n .
        try=`expr $try + 1`
        sleep 1

    done

}

case "$1" in
    start)
        echo -n "Starting php-fpm "

        $php_fpm_BIN --daemonize $php_opts

        if [ "$?" != 0 ] ; then
            echo " failed"
            exit 1
        fi

        wait_for_pid created $php_fpm_PID

        if [ -n "$try" ] ; then
            echo " failed"
            exit 1
        else
            echo " done"
        fi
    ;;

    stop)
        echo -n "Gracefully shutting down php-fpm "

        if [ ! -r $php_fpm_PID ] ; then
            echo "warning, no pid file found - php-fpm is not running ?"
            exit 1
        fi

        kill -QUIT `cat $php_fpm_PID`

        wait_for_pid removed $php_fpm_PID

        if [ -n "$try" ] ; then
            echo " failed. Use force-quit"
            exit 1
        else
            echo " done"
        fi
    ;;

    force-quit)
        echo -n "Terminating php-fpm "

        if [ ! -r $php_fpm_PID ] ; then
            echo "warning, no pid file found - php-fpm is not running ?"
            exit 1
        fi

        kill -TERM `cat $php_fpm_PID`

        wait_for_pid removed $php_fpm_PID

        if [ -n "$try" ] ; then
            echo " failed"
            exit 1
        else
            echo " done"
        fi
    ;;

    restart)
        $0 stop
        $0 start
    ;;

    reload)

        echo -n "Reload service php-fpm "

        if [ ! -r $php_fpm_PID ] ; then
            echo "warning, no pid file found - php-fpm is not running ?"
            exit 1
        fi

        kill -USR2 `cat $php_fpm_PID`

        echo " done"
    ;;

    *)
        echo "Usage: $0 {start|stop|force-quit|restart|reload}"
        exit 1
    ;;

esac

#######################

测试的域名
# vim /usr/local/nginx/conf/vhost.d/film.chinasoft.com.conf
server {
        listen 80;

        server_name     film.chinasoft.com;

        proxy_connect_timeout 1800s;
        proxy_read_timeout 1800s;
        proxy_send_timeout 1800s;
            access_log      /data/www/logs/nginx_log/access/film.chinasoft.com_access.log main ;
        access_log on;
            error_log       /data/www/logs/nginx_log/error/film.chinasoft.com_error.log ;
            root            /data/www/vhosts/film.chinasoft.com/httpdocs/api/public ;
            index           index.html index.shtml index.php ;
        error_page  404 403              /404.html;    

            location / {
                    index  index.php index.html index.htm;
                    try_files $uri $uri/ /index.php?$query_string;
            }

            location ~ \.php$ {
                    #fastcgi_pass   unix:/tmp/php-cgi.sock;
                    fastcgi_pass 127.0.0.1:9000;
                    fastcgi_index  index.php;
                    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                    include        fastcgi_params;
            }

            location ^~ /logs/
            {
                    deny all;
            }

    }

server {
        listen 443;
        ssl on;

        ssl_certificate         cert2016/chinasoft_com.crt;
        ssl_certificate_key     cert2016/chinasoft_com.key;
        ssl_dhparam     cert2016/dh_2048.pem;

        ssl_session_timeout     5m;
        ssl_protocols   TLSv1 TLSv1.1 TLSv1.2;

        ssl_ciphers     "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:!AES128-GCM-SHA256:!AES256-GCM-SHA384:!AES128-SHA256:!AES256-SHA256:!AES128-SHA:!AES256-SHA:AES:!CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA";

        ssl_prefer_server_ciphers       on;

        server_name     film.chinasoft.com;
        access_log      /data/www/logs/nginx_log/access/film.chinasoft.com_access.log main ;
        error_log       /data/www/logs/nginx_log/error/film.chinasoft.com_error.log ;

        root            /data/www/vhosts/film.chinasoft.com/httpdocs/api/public ;
        index           index.html index.shtml index.php ;
        error_page  404 403              /404.html;

        location / {
                index  index.php index.html index.htm;
                try_files $uri $uri/ /index.php?$query_string;
        }

        location ~ \.php$ {

                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
        }           

}

# 创建测试页面
[[email protected]_filmora_file01:/usr/local/php]# mkdir -p /data/www/vhosts/film.chinasoft.com/httpdocs/api/public
[[email protected]_filmora_file01:/usr/local/php]# echo "<?php echo phpinfo(); ?>"> /data/www/vhosts/film.chinasoft.com/httpdocs/api/public/index.php

原文地址:https://www.cnblogs.com/reblue520/p/9689622.html

时间: 2024-11-08 20:45:43

centos7.5环境下编译安装php7.0.30并安装redis和mongo扩展的相关文章

centos7.2源码安装php7.0.9和nginx1.10.3服务器

下载nginx-1.10.3.tar.gz,php-7.0.9.tar.gz.也可以去nginx官网,php官网下载想要的版本.我选择nginx1.10.3稳定版和php7.0.9最新版.php源码包下载速度可能会很慢,建议使用迅雷等工具,下载完成后通过stfp工具把源码包上传到服务器上,为方便测试,我直接放置在root家目录下: 使用源码安装要确保服务器安装好gcc(编辑工具)和make(安装工具),若没安装可以执行命令安装: # yum install gcc # yum install m

Linux Centos7.2 编译安装PHP7.0.2

操作环境: 1.系统:Centos7.2 2.服务:Nginx 1.下载PHP7.0.2的安装包解压,编译,安装: $ cd /usr/src/ $ wget http://cn2.php.net/distributions/php-7.0.2.tar.gz $ tar -zxvf php-7.0.2.tar.gz $ cd php-7.0.2 1.1 编译前检查 请检查是否安装了gcc ,没有的话执行yum install gcc 检查是否安装了libxml2 ,没有的话执行yum insta

CentOS 7.2 下编译安装PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法

这篇文章主要介绍了CentOS 7.2 mini版本下编译安装PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法,非常不错,具有参考借鉴价值,需要的朋友可以参考下一.安装前的准备工作 1.yum update #更新系统 2.yum install gcc gcc-c++ autoconf automake cmake bison m4 libxml2 libxml2-devel libcurl-devel libjpeg-devel libpng-devel libicu

centos7.3安装php7.0

需求:在Centos7.3下搭建LNMP环境 文章转载自:http://blog.csdn.net/wszll_alex/article/details/76285324 作者:狂热森林 1. 关闭防火墙和selinux 打开文件selinux vim /etc/sysconfig/selinux 将文件中SELINUX=enforcing改为disabled,然后执行"setenforce 0″不用重启地关闭selinux. SELINUX=disabled 关闭放火墙 systemctl s

【甘道夫】Win7x64环境下编译Apache Hadoop2.2.0的Eclipse插件

目标: 编译Apache Hadoop2.2.0在win7x64环境下的Eclipse插件 环境: win7x64家庭普通版 eclipse-jee-kepler-SR1-win32-x86_64.zip Apache Ant(TM) version 1.8.4 compiled on May 22 2012 java version "1.7.0_45" 参考文章: http://kangfoo.u.qiniudn.com/article/2013/12/build-hadoop2x

libCURL开源库在VS2010环境下编译安装,配置详解

libCURL开源库在VS2010环境下编译安装,配置详解 转自:http://my.oschina.net/u/1420791/blog/198247 CURL开源库VS2010环境下编译安装,配置详解 一 准备 1.1 CURL官网下载地址:http://curl.haxx.se/download.html 1.2 找到源码包,我这里下载的是7.32.0版:http://curl.haxx.se/download/curl-7.32.0.zip 二 步骤 2.1 打开curl-7.32.0\

图解Linux下源码安装PHP7.0.9 +Nginx

上一次,在<Linux下源码安装php7.0.6>,安装过PHP7.0.3,本文将记录安装PHP7.0.9过程. 测试环境 Linux 2.6.32-279.el6.i686 nginx-1.9.15.tar http://nginx.org/download/nginx-1.9.15.tar.gz php-7.0.9.tar.gz http://am1.php.net/distributions/php-7.0.9.tar.gz 安装Nginx wget http://nginx.org/d

CentOS7.X环境下源码包安装部署RabbitMQ3.7.17

本文介绍在CentOS7.X环境下源码包安装部署RabbitMQ3.7.17,使用docker安装很简单,这里我就不往文章中添加.在CentOS7.X环境下使用源码包安装还是有遇到不少坑的(使用yum安装的方式官方网站有介绍,比较简单),通过这篇我的个人实践操作,能够帮助到有需要的人.搭建环境:操作系统:CentOS7.5内存大小:16GB硬盘:100G注:正文中的参数与部署路径等,请根据实际需求修改.1.软件准备:wxWidgets-3.1.2.tar.bz2otp_src_22.0.tar.

Windows环境下Android Studio v1.0安装教程

Windows环境下Android Studio v1.0安装教程 Windows环境下Android Studio v1.0安装教程 准备工具 JDK安装包. 要求:JDK 7以及以上版本. Android Studio安装文件. Windows: exe(包含SDK) (813 MB) exe(不包含SDK) (250 MB) zip (235 MB) Mac dmg (234 MB) zip (233 MB) Linux: zip (233 MB) 说明: 32位系统和64位系统是同一个安