1. 程式人生 > >編譯安裝PHP7

編譯安裝PHP7

agent http session cli centos sendfile oca ttf connect

CentOS6.6編譯安裝PHP7

  • 首先安裝依賴包

yum install gcc gcc-c++ pcre* openssl* gd-devel* zlib-devel pcre-devel libxml2-devel curl-devel

  

下載安裝libmcrypt

地址:http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/

編譯安裝即可

tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make && make install

編輯 /etc/ld.so.conf 末行添加

/usr/local/lib

  

  • 下載PHP7

wget http://cn2.php.net/distributions/php-7.0.1.tar.gz
tar zxvf php-7.0.1.tar.gz
  • 編譯安裝PHP7

技術分享
./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-mcrypt=/usr/include --with-mhash --with-openssl --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 --without-gdbm --disable-fileinfo
View Code
make && make install
  • 配置文件

cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf 
cp php.ini-production /usr/local/php/etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
  • 啟動

/etc/init.d/php-fpm start
  • nginx鏈接php

cat /etc/nginx/nginx.conf

技術分享
user  nginx;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  $remote_addr - $remote_user [$time_local] "$request" 
                     $status $body_bytes_sent "$http_referer" 
                      "$http_user_agent" "$http_x_forwarded_for";

   # access_log  logs/access.log  main;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 300m;
sendfile        on;
tcp_nopush     on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
keepalive_timeout  60;
tcp_nodelay on;
server_tokens off;
gzip  on;
gzip_min_length  1k;
gzip_buffers     4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types       text/plain application/x-javascript text/css application/xml;
gzip_vary on;


    server {
        listen       80;
        server_name  www.qy.com;


        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;

       }

   }

include /etc/nginx/vhost/*.conf;

}
View Code

cat /etc/nginx/vhost/zabbix.conf

技術分享
server
        {
                listen       80;
                server_name 192.168.80.11;
                index index.php index.html index.htm default.html default.htm default.php;
                root  /usr/local/nginx/html;

        location ~ \.php$ {
        root           /usr/local/nginx/html;
        fastcgi_pass   192.168.80.11:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name;
        include        fastcgi_params;
 }
                  



  
       location /status {
                stub_status on;
                access_log   off;
                }

       location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
              
 {     expires 30d;
                                     }
       location ~ .*\.(js|css)?$
 {
       expires 12h;
                                    }

       access_log off;
                                    }
View Code

編譯安裝PHP7