centos7安装php7

准备工作:

公司专注于为企业提供成都做网站、成都网站设计、微信公众号开发、商城系统网站开发微信小程序定制开发,软件定制网站制作等一站式互联网企业服务。凭借多年丰富的经验,我们会仔细了解各客户的需求而做出多方面的分析、设计、整合,为客户设计出具风格及创意性的商业解决方案,创新互联公司更提供一系列网站制作和网站推广的服务。

Yum update & yum upgrade
Yum –y install gcc*  
yum -y install libevent-devel  
yum -y install gperftools

编译安装libmcrypt, mhash, mcrypt 二进制源码包 

这里之所以编译安装libmcrypt,原因是yum安装的貌似会报错

######编译安装libmcrypt-2.5.7

[root@vm172-31-48-28 soft]# tar zxvf libmcrypt-2.5.8.tar.gz

[root@vm172-31-48-28 soft]# cd libmcrypt-2.5.8

[root@vm172-31-48-28 libmcrypt-2.5.8]# ./configure--prefix=/usr/local/related/libmcrypt

[root@vm172-31-48-28 libmcrypt-2.5.8]# make &&make install

######编译安装mhash-0.9.9.9

[root@vm172-31-48-28 soft]# tar zxf mhash-0.9.9.9.tar.gz

[root@vm172-31-48-28 soft]# cd mhash-0.9.9.9

[root@vm172-31-48-28 mhash-0.9.9.9]# ./configure--prefix=/usr/local/related/mhash

[root@vm172-31-48-28 mhash-0.9.9.9]# make && makeinstall

######编译安装mcrypt-2.6.8

[root@vm172-31-48-28 soft]# tar zxf mcrypt-2.6.8.tar.gz&& cd mcrypt-2.6.8

[root@vm172-31-48-28 mcrypt-2.6.8]# exportLD_LIBRARY_PATH=/usr/local/related/libmcrypt/lib:/usr/local/related/mhash/lib

[root@vm172-31-48-28 mcrypt-2.6.8]# exportLDFLAGS="-L/usr/local/related/mhash/lib-I/usr/local/related/mhash/include/"

[root@vm172-31-48-28 mcrypt-2.6.8]# exportCFLAGS="-I/usr/local/related/mhash/include/"

[root@vm172-31-48-28 mcrypt-2.6.8]# ./configure--prefix=/usr/local/related/mcrypt--with-libmcrypt-prefix=/usr/local/related/libmcrypt

[root@vm172-31-48-28 mcrypt-2.6.8]# make && makeinstall

######其他依赖yum安装

[root@localhost ~]# yum -y install libxml2 libxml2-developenssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel -y

PHP 7编译参数的配置

注意,操作时一定要先把下面反斜杠“\”后面添加的注释文字去掉!!!

######生成配置文件

[root@vm172-31-48-28 soft]#tar -zxf php-7.0.0.tar.gz&& cd php-7.0.0

[root@vm172-31-48-28 php-7.0.13]# rm -rf configure

[root@vm172-31-48-28 php-7.0.13]# ./buildconf --force

Forcing buildconf

Removing configure caches

buildconf: checking installation...

buildconf: autoconf version 2.69 (ok)

rebuilding configure

rebuilding main/php_config.h.in

######开始配置

[root@vm172-31-48-28 php-7.0.13]# ./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-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 --enable-fastcgi --with-fpm-user=nginx--with-fpm-group=nginx --without-gdbm--with-mcrypt=/usr/local/related/libmcrypt --disable-fileinfo

执行上面的配置命令的运行结果如下:

centos7安装php7

开始编译安装PHP 7

[root@vm172-31-48-28php-7.0.13]#make clean &&make &&make install

PHP7编译安装成功 

centos7安装php7

[root@vm172-31-48-28php-7.0.13]# ls -lrt/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/

total 1368

-rwxr-xr-x 1 root root 256998Nov 30 11:04 mysqli.a

-rwxr-xr-x 1 root root 193651Nov 30 11:04 mysqli.so

-rwxr-xr-x 1 root root 501074Nov 30 11:04 opcache.a

-rwxr-xr-x 1 root root 342253Nov 30 11:04 opcache.so

-rwxr-xr-x 1 root root  51750 Nov 30 11:04 pdo_mysql.a

-rwxr-xr-x 1 root root  42613 Nov 30 11:04 pdo_mysql.so

[root@vm172-31-48-28php-7.0.13]# cp php.ini-production /usr/local/php7/etc/php.ini

[root@vm172-31-48-28php-7.0.13]# cd /usr/local/php7/etc/

[root@vm172-31-48-28 etc]# cpphp-fpm.conf.default php-fpm.conf

[root@vm172-31-48-28 etc]#vim php.ini

extension_dir= "/usr/local/php7/lib/php/extensions/no-debug-non-zts-20151012/"

安装memcached

 

先安装libmemcached

[root@vm172-31-48-28 soft]#tar -zxvf libmemcached-1.0.8.tar.gz

[root@vm172-31-48-28 soft]#cd libmemcached-1.0.8

[root@vm172-31-48-28libmemcached-1.0.8]# ./configure--prefix=/usr/local/libmemcached

[root@vm172-31-48-28libmemcached-1.0.8]# make&& make install

下载php7的memcached

[root@vm172-31-48-28 soft]# gitclone https://github.com/php-memcached-dev/php-memcached  

[root@vm172-31-48-28 soft]# cdphp-memcached   

[root@vm172-31-48-28 php-memcached]# git checkoutphp7    //非常重要

Branch php7 set up to track remote branch php7 fromorigin.

Switched to a new branch 'php7'

[root@vm172-31-48-28php-memcached]#/usr/local/php7/bin/phpize

[root@vm172-31-48-28php-memcached]# ./configure --enable-memcached--with-php-config=/usr/local/php7/bin/php-config --with-zlib-dir--prefix=/usr/local/phpmecached --disable-memcached-sasl--with-libmemcached-dir=/usr/local/libmemcached/

[root@vm172-31-48-28php-memcached]#make && make install

[root@vm172-31-48-28php-memcached]# vim /usr/local/php7/etc/php.ini

extension="memcached.so"

下载nginx1.10.2最新稳定版本

[root@vm172-31-48-28 soft]#wgethttp://219.239.26.14/files/321500000944715A/nginx.org/download/nginx-1.10.2.tar.gz

[root@vm172-31-48-28 soft]#tar -zxvf nginx-1.10.2.tar.gz

[root@vm172-31-48-28 soft]#cd nginx-1.10.2

[root@vm172-31-48-28nginx-1.10.2]# useradd nginx

[root@vm172-31-48-28 nginx-1.10.2]#./configure --prefix=/usr/local/nginx --with-pcre--with-http_stub_status_module --user=nginx --group=nginx

 

 

配置nginx.conf

user  nginx nginx;

worker_processes 4;

worker_cpu_affinity 0000000100000010 00000100 0000100;

worker_processes 8;

worker_cpu_affinity 0000000100000010 00000100 00001000 00010000 00100000 01000000 10000000;

error_log  logs/nginx_error.log  notice;

#pid        /usr/local/nginx/logs/nginx.pid

 

#Specifies the value formaximum file descriptors that can be opened by this process.

worker_rlimit_nofile 65535;

 

events

{

  use epoll;

  worker_connections 65535;

}

 

http

{

  include      mime.types;

  default_type application/octet-stream;

  #charset gb2312;

  server_names_hash_bucket_size 128;

  client_header_buffer_size 2k;

  large_client_header_buffers 4 4k;

  client_max_body_size 8m;

     

  sendfile on;

  tcp_nopush    on;

 

  keepalive_timeout 60;

 

 

  fastcgi_connect_timeout 300;

  fastcgi_send_timeout 300;

  fastcgi_read_timeout 300;

  fastcgi_buffer_size 64k;

  fastcgi_buffers 8 64k;

  fastcgi_busy_buffers_size 128k;

  fastcgi_temp_file_write_size 128k;

#  fastcgi_temp_path/usr/local/nginx/fastcgi_temp;

#  # fastcgi_cache_path /usr/local/nginx/fastcgi_cache levels=2:2keys_zone=ngx_fcgi_cache:512m inactive=1d max_size=40g;

#  # fastcgi_cache_valid 200 301 302 1d;

#  # fastcgi_cache_use_stale error timeout invalid_header http_500;

#  # fastcgi_cache_key $request_method://$host$request_uri;

#  # fastcgi_cache ngx_fcgi_cache;

#  #

#  # open_file_cache max=204800 inactive=20s;

#  # open_file_cache_min_uses 1;

#  # open_file_cache_valid 30s;

  tcp_nodelay on;

  server_tokens off;

 

  gzip on;

  gzip_min_length  1k;

  gzip_buffers 4 16k;

  gzip_http_version 1.0;

  gzip_comp_level 2;

  gzip_types       text/plain application/x-javascripttext/css application/xml;

  gzip_vary on;

  #limit_zone myzone_wq $binary_remote_addr  10m;

  # #limit_req_zone $binary_remote_addr zone=wq:10m rate=1r/s;

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

  include/usr/local/nginx/conf/vhost_conf/*.conf;

}

 

[root@vm172-31-48-28 conf]#mkdir vhost_conf/

[root@vm172-31-48-28vhost_conf]# vim service.conf

 

server {

    listen  80;

    server_name www.example.com;

    access_log /usr/local/nginx/logs/example.com.access.log; 

 

    location / {

        root /usr/local/nginx/html;

        index index.php index.html index.htm;

    }

 

    location /p_w_picpaths {

        autoindex on;

    }

 

    location ~ \.php$ {

        fastcgi_pass   127.0.0.1:9000;

        fastcgi_index  index.php;

        fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;

        include fastcgi_params;

    }

}

[root@vm172-31-48-28vhost_conf]# vim nginx_status.conf

 

server

{

    listen 4444;

    server_name 127.0.0.1;

    location /nginx_status {

        stub_status on;

        access_log off;

    }

}

完成!

错误提示:

ERROR: ld.so: object'/usr/local/lib/libtcmalloc_minimal.so' from LD_PRELOAD cannot be preloaded:ignored.

解决:安装 gperftools 即可!


当前文章:centos7安装php7
网站路径:http://myzitong.com/article/pdgpsh.html