yum remove php yum remove php-common.x86_64
yum install -y gcc gcc-c++ make cmake bison autoconf wget lrzsz yum install -y libtool libtool-ltdl-devel yum install -y freetype-devel libjpeg.x86_64 libjpeg-devel libpng-devel gd-devel yum install -y python-devel patch sudo yum install -y openssl* openssl openssl-devel ncurses-devel yum install -y bzip* bzip2 unzip zlib-devel yum install -y libevent* yum install -y libxml* libxml2-devel yum install -y libcurl* curl-devel yum install -y readline-devel yum install libmcrypt libmcrypt-devel mcrypt mhash
wget http://cn2.php.net/distributions/php-7.0.17.tar.gz tar -zvxf php-7.0.17.tar.gz ./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc --with-config-file-scan-dir=/usr/local/php7/etc/php.d --with-mcrypt=/usr/include --enable-mysqlnd --with-mysqli --with-pdo-mysql --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-gd --with-iconv --with-zlib --enable-xml --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache make && make install
[php] expose_php=off max_file_uploads=30 post_max_size=30M [opcache] zend_extension=opcache.so opcache.enable=1 opcache.memory_consumption=128 opcache.max_accelerated_files=4000 opcache.revalidate_freq=60 [date] date.timezone=Asia/Shanghai [session] session.sid_length=40
[global] pid = run/php-fpm.pid error_log = log/php-fpm.log daemonize = yes include=/usr/local/php7/etc/php-fpm.d/*.conf
[www] user = www group = www listen = /dev/shm/php-cgi.sock listen.owner = www listen.group = www listen.mode = 0660 listen.allowed_clients = 127.0.0.1 pm = static pm.max_children = 560 pm.start_servers = 30 pm.min_spare_servers = 20 pm.max_spare_servers = 40 pm.max_requests = 500 request_terminate_timeout = 300
vim /etc/init.d/php-fpm7
#! /bin/sh # Comments to support chkconfig on CentOS # chkconfig: 2345 65 37 #set -e PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="php-fpm7 daemon" NAME=php-fpm DAEMON=/usr/local/php7/sbin/$NAME CONFIGFILE=/usr/local/php7/etc/php-fpm.conf PIDFILE=/usr/local/php7/var/run/$NAME.pid SCRIPTNAME=/etc/init.d/$NAME # Gracefully exit if the package has been removed.test -x $DAEMON || exit 0 d_start() { $DAEMON -y $CONFIGFILE || echo -n " already running" } d_stop() { kill -QUIT `cat $PIDFILE` || echo -n " not running" } d_reload() { kill -HUP `cat $PIDFILE` || echo -n " can't reload" } case "$1" in start)echo -n "Starting $DESC is success" d_start echo "." ;; stop) echo -n "Stopping $DESC is success" d_stop echo "." ;; reload) echo -n "Reloading $DESC configuration..." d_reload echo "reloaded." ;; restart) echo -n "Restarting $DESC is success" d_stop sleep 1 d_start echo "." ;; *) echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2 exit 3 ;;esac
chmod 755 /etc/init.d/php-fpm7 chkconfig php-fpm7 on service php-fpm7 start #啓動服務 killall php-fpm #中止php-fpm
cd /usr/local/src/nginx-1.8.1 ./configure --prefix=/usr/local/nginx --sbin-path=/usr/sbin/nginx --conf-path=/usr/local/nginx/config/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --user=www --group=www --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/tmp/nginx/client --http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fcgi --with-http_stub_status_module make cp objs/nginx /usr/local/nginx/sbin/nginx
http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 50m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 600; fastcgi_send_timeout 600; fastcgi_read_timeout 600; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; 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-javascript text/css application/xml; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; server_tokens off; log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; include vhost/*.conf; }
server { listen 80; server_name api.gnfenqi.com; access_log /alidata/log/nginx/api.log combined; index index.html index.htm index.php; root /alidata/www/api.gnfenqi.com; if ( $query_string ~* ".*[\;'\<\>].*" ){ return 404; } location / { try_files $uri $uri/ /index.php; } location ~ .*\.(php|php5)?$ { fastcgi_pass unix:/dev/shm/php-cgi.sock; fastcgi_index index.php; include fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 7d; } }
Memcached 是高性能的分佈式內存緩存服務器,而PHP memcache 和 memcached 都是 Memcached 服務器的 PHP 擴展。其中memcache 比 memcached 早出現,因此一些老的代碼可能還在用 memcache 擴展。memcached 後來出現,而且大部分框架都支持 memcached,如今相對較流行。能夠根據本身須要,安裝一個就能夠。這裏兩個的安裝方法都說一下。javascript
參考:http://www.lnmp.cn/install-memcache-and-memcached-extends-under-php7.htmlphp
wget https://launchpad.net/libmemcached/1.0/1.0.18/+download/libmemcached-1.0.18.tar.gz tar -zvxf libmemcached-1.0.18.tar.gz cd libmemcached-1.0.8 ./configure --prefix=/usr/local/libmemcached make && make install
wget https://github.com/php-memcached-dev/php-memcached/archive/php7.zip # https://github.com/php-memcached-dev/php-memcached/tree/php7 unzip php7.zip cd php-memcached-php7 /usr/local/php7/bin/phpize ./configure --with-php-config=/usr/local/php7/bin/php-config --with-libmemcached-dir=/usr/local/libmemcached --disable-memcached-sasl make && make install
wget https://github.com/websupport-sk/pecl-memcache/archive/NON_BLOCKING_IO_php7.zip # https://github.com/websupport-sk/pecl-memcache/tree/NON_BLOCKING_IO_php7 unzip NON_BLOCKING_IO_php7.zip cd pecl-memcache-NON_BLOCKING_IO_php7 /usr/local/php7/bin/phpize ./configure --with-php-config=/usr/local/php7/bin/php-config make && make install
vi /usr/local/php7/etc/php.ini # shift + g # 尾行插入以下內容並保存: extension=memcache.so extension=memcached.so