nginx+php7.0.x+redis+memcached環境搭建編譯命令

yum install gcc.x86_64  gcc-c++.x86_64 pcre-devel.x86_64javascript


nginx+php+mysql 服務架設php

wget http://www.openssl.org/source/openssl-1.0.2e.tar.gzcss

./configjava

makenode


wget http://zlib.net/zlib-1.2.8.tar.gzmysql

./configurelinux

makenginx


wget http://nginx.org/download/nginx-1.9.9.tar.gzc++

./configure --prefix=/usr/local/nginx --without-select_module --without-poll_module  --with-threads --with-http_ssl_module --with-http_v2_module --with-stream --with-pcre --with-openssl=/opt/software/openssl-1.0.2e/   --with-zlib=/opt/software/zlib-1.2.8git


*unix 系統內核參數的配置

vi /etc/sysctl.conf 

net.ipv4.ip_forward = 0

net.ipv4.conf.default.rp_filter = 1

net.ipv4.conf.default.accept_source_route = 0

kernel.sysrq = 0

kernel.core_uses_pid = 1

net.ipv4.tcp_syncookies = 1

kernel.msgmnb = 65536

kernel.msgmax = 65536

kernel.shmmax = 68719476736

kernel.shmall = 4294967296

net.ipv4.tcp_max_tw_buckets = 6000

net.ipv4.tcp_sack = 1

net.ipv4.tcp_window_scaling = 1

net.ipv4.tcp_rmem = 4096 87380 4194304

net.ipv4.tcp_wmem = 4096 16384 4194304

net.core.wmem_default = 8388608

net.core.rmem_default = 8388608

net.core.rmem_max = 16777216

net.core.wmem_max = 16777216

net.core.netdev_max_backlog = 262144

net.core.somaxconn = 262144

net.ipv4.tcp_max_orphans = 3276800

net.ipv4.tcp_max_syn_backlog = 262144

net.ipv4.tcp_timestamps = 0

net.ipv4.tcp_synack_retries = 1

net.ipv4.tcp_syn_retries = 1

net.ipv4.tcp_tw_recycle = 1

net.ipv4.tcp_tw_reuse = 1

net.ipv4.tcp_mem = 94500000 915000000 927000000

net.ipv4.tcp_fin_timeout = 1

net.ipv4.tcp_keepalive_time = 30

net.ipv4.ip_local_port_range = 1024 65535

使配置當即生效可以使用以下命令:

/sbin/sysctl -p


ulimit -SHn 65535

1. 在/etc/rc.local 中增長一行 ulimit -SHn 65535

2. 在/etc/profile 中增長一行 ulimit -SHn 65535

3. 在/etc/security/limits.conf 最後增長:

* soft nofile 65535

* hard nofile 65535

* soft nproc 65535

* hard nproc 65535


nignx 編譯以後配置

user  nobody;

worker_processes  8;

error_log  logs/error.log;

pid        logs/nginx.pid;

events {

        use epoll;

        multi_accept on;

        worker_connections      655350;

}



http {

        include       mime.types;

        default_type  application/octet-stream;


        charset utf-8;

        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;

tcp_nodelay on;

        keepalive_timeout  65;


        fastcgi_cache_path /usr/local/nginx/fastcgi_cache levels=1:2 keys_zone=cache_php:64m inactive=5m;

        fastcgi_connect_timeout 300;

        fastcgi_send_timeout 300;

        fastcgi_read_timeout 300;

        fastcgi_buffer_size 4k;

        fastcgi_buffers 8 4k;

        fastcgi_busy_buffers_size 8k;

        fastcgi_temp_file_write_size 8k;

        fastcgi_cache cache_php;

        fastcgi_cache_key $request_method://$host$request_uri;

        fastcgi_cache_valid 200 302 1h;

        fastcgi_cache_valid 301 1d;

        fastcgi_cache_valid any 1m;

        fastcgi_cache_min_uses 1;

        fastcgi_cache_use_stale error timeout invalid_header http_500;

        open_file_cache max=204800 inactive=20s;

        open_file_cache_min_uses 1;

        open_file_cache_valid 30s;

        

        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;


server_tokens off;

        log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

            '$status $body_bytes_sent "$http_referer" '

            '"$http_user_agent" "$http_x_forwarded_for"';


        include vhost/*.conf;

}




/usr/sbin/sestatus -v      ##若是SELinux status參數爲enabled即爲開啓狀態

SELinux status:                 enabled

getenforce                 ##也能夠用這個命令檢查

臨時關閉(不用重啓機器):

setenforce 0               ##設置SELinux 成爲permissive模式

                           ##setenforce 1 設置SELinux 成爲enforcing模式

修改/etc/selinux/config 文件

將SELINUX=enforcing改成SELINUX=disabled



下載php

wget http://am1.php.net/distributions/php-7.0.2.tar.gz

yum  install epel-release

yum makecache

yum install freetype.x86_64 freetype-devel.x86_64  readline-devel.x86_64 libjpeg-turbo-devel.x86_64 libjpeg-turbo.x86_64 libpng-devel.x86_64 libpng.x86_64 libXpm.x86_64 libXpm-devel.x86_64 libxml2-devel.x86_64  libcurl-devel.x86_64

yum install libmcrypt.x86_64 libmcrypt-devel.x86_64


./configure --prefix=/usr/local/php7 --enable-fpm --enable-gd-native-ttf --enable-mbstring  --enable-sockets  --enable-sysvmsg  --enable-sysvsem  --enable-pcntl  --enable-shmop  --enable-sysvshm  --enable-mysqlnd  --enable-zip --with-libxml-dir=/usr --with-openssl  --with-zlib=/usr --with-gd --with-freetype-dir=/usr --with-curl=/usr --with-jpeg-dir=/usr --with-png-dir=/usr --with-mcrypt=/usr --with-mhash=/usr --with-pcre-dir=/usr --enable-ftp --with-tsrm-pthreads --with-mysqli=/usr/lib64/mysql/mysql_config --with-pdo-mysql=/usr --with-readline=/usr



make && make install


memcached -d -p 11211 -u memcached -m 64 -c 10240 -P /var/run/memcached/memcached.pid -l 127.0.0.1 -U 0

yum install  unzip.x86_64 


安裝memcached-php擴展

wget https://codeload.github.com/php-memcached-dev/php-memcached/zip/php7

mv php7  php-memcached-php7.zip

unzip php-memcached-php7.zip

cd php-memcached-php7


須要注意,這裏的libmemcached不須要1.0.1以上版本,目前yum裏面的有些版本過低了

/usr/local/php7/bin/phpize

./configure --with-php-config=/usr/local/php7/bin/php-config   --disable-memcached-sasl

make && make install


安裝redis-php擴展

wget https://codeload.github.com/phpredis/phpredis/zip/php7

mv php7 phpredis-php7.zip

unzip phpredis-php7.zip

cd phpredis-php7

/usr/local/php7/bin/phpize

./configure --with-php-config=/usr/local/php7/bin/php-config

make && make install


編輯php.ini,opcache緩存目錄要本身建立

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

extension=memcached.so

extension=redis.so

zend_extension=opcache.so

opcache.enable=1

opcache.enable_cli=1

opcache.file_cache=/tmp/opcache


引擎後端腳本的版本號信息

expose_php=Off

相關文章
相關標籤/搜索