shisgmei 发表于 2018-11-7 07:49:20

linux+php5.5+nginx+支持redis安装部署

系统环境
  # cat /etc/redhat-release
  CentOSrelease 6.5 (Final)
  # uname -a
  Linuxlocalhost.localdomain 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013x86_64 x86_64 x86_64 GNU/Linux
php5.5 yum源
  rpm -Uvhhttp://mirror.webtatic.com/yum/el6/latest.rpm
安装php以及要支持的库
  yum -yinstall libjpeg* php55w-imap php55w-ldap php55w-odbc php55w-pear php55w-xml php55w-xmlrpcphp55w-mbstring php55w-mcrypt php55w-bcmath php55w-mhash libmcryptlibmcrypt-devel php55w-fpm php55w-devel php55w-mysql php55w-mysqliphp55w-pdo php55w-opcache php55w-gd
查看php的版本
  # php -v
  PHP 5.5.12(cli) (built: May1 2014 20:34:46)
  Copyright (c)1997-2014 The PHP Group
  Zend Enginev2.5.0, Copyright (c) 1998-2014 Zend Technologies
  with Zend OPcache v7.0.4-dev, Copyright (c)1999-2014, by Zend Technologies
修改php-fpm和开机自启动
  修改php-fpm
  sed -i's/user = apache/user = nginx/g' /etc/php-fpm.d/www.conf
  sed -i 's/group= apache/group = nginx/g' /etc/php-fpm.d/www.conf
  sed -i's/;rlimit_files = 1024/rlimit_files = 51200/g' /etc/php-fpm.d/www.conf
  sed -i's/^pm.max_children.*/pm.max_children = 300/g' /etc/php-fpm.d/www.conf
  启动php-fpm
  /etc/init.d/php-fpmstart
  # netstat -lnt|grep 9000
  tcp      0   0 127.0.0.1:9000             0.0.0.0:*                   LISTEN
  #chkconfig php-fpm on
添加nginx yum源码
  # cat /etc/yum.repos.d/nginx.repo
  
  name=nginx repo
  baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
  gpgcheck=0
  enabled=1
创建站点目录和授权
  mkdir -p/data/www/wwwyouxi.com
  chown -Rnginx:nginx /data/www/wwwyouxi.com
安装nginx和配置支持php
  yum -yinstall nginx                  ##安装nginx
  # nginx -v
  nginxversion: nginx/1.6.0
  chkconfignginx on
  # cat /etc/nginx/conf.d/www.youxi.conf |egrep -v *#
  server {
  listen      80;
  server_name www.youxi.com;
  access_log /var/log/nginx/log/www.youxi.log main;
  error_log/opt/log/nginx/www.youxi.error.log error;
  location / {
  root/data/www/www.youxi.com;
  index index.php index.html index.htm;
  }
  error_page500 502 503 504/50x.html;
  location = /50x.html {
  root/usr/share/nginx/html;
  }
  ###########################支持php配置#######################################
  location ~ \.php$ {
  root         html;
  fastcgi_pass   127.0.0.1:9000;
  fastcgi_indexindex.php;
  fastcgi_paramSCRIPT_FILENAME /data/www/www.youxi.com $fastcgi_script_name;
  include      fastcgi_params;
  }
  }
nginx.conf配置文件
  # cat nginx.conf
  usernginx nginx;
  worker_processes1;
  error_log/var/log/nginx/error.log warn;
  pid      /var/run/nginx.pid;
  events {
  use epoll;
  worker_connections1024;
  }
  http {
  include       /etc/nginx/mime.types;
  default_typeapplication/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 /var/log/nginx/access.logmain;
  #tcp_nopush   on;
  keepalive_timeout65;
  server_names_hash_bucket_size 128;
  client_header_buffer_size 128k;
  large_client_header_buffers 4 256k;
  client_header_timeout1m;
  client_body_timeout    1m;
  send_timeout         1m;
  sendfile       on;
  tcp_nopush   on;
  tcp_nodelay    on;
  client_max_body_size 50m;
  client_body_buffer_size 50m;
  #charset gb2312;
  fastcgi_temp_path/dev/shm/fastcgi_temp;
  client_body_temp_path/dev/shm/client_body_temp;
  gzip on;
  gzip_min_length 1k;
  gzip_buffers   4 16k;
  gzip_comp_level 2;
  gzip_http_version 1.1;
  gzip_types text/plainapplication/x-javascript text/css application/xml;
  gzip_vary on;
  include /etc/nginx/conf.d/*.conf;
  }
php支持redis
  下载phpredis-master.zip并解压
  # phpize
  # ./configure
  # make && make install
  /etc/php.ini下面添加redis模块
  extension="redis.so"
  重启php-fpm和nginx
  /etc/init.d/php-fpmrestart
  /etc/init.d/nginxreload
查看支持的模块
  # ll /usr/lib64/php/modules/
  总用量 7560
  -rwxr-xr-x 1root root   29264 May1 13:58 bcmath.so
  -rwxr-xr-x 1root root   22440 May1 13:58 bz2.so
  -rwxr-xr-x 1root root   30616 May1 13:58 calendar.so
  -rwxr-xr-x 1root root   12712 May1 13:58 ctype.so
  -rwxr-xr-x 1root root   77544 May1 13:58 curl.so
  -rwxr-xr-x 1root root171256 May1 13:58 dom.so
  -rwxr-xr-x 1root root   60584 May1 13:58 exif.so
  -rwxr-xr-x 1root root 2708016 May1 13:58fileinfo.so
  -rwxr-xr-x 1root root   49608 May1 13:58 ftp.so
  -rwxr-xr-x 1root root390192 May1 13:58 gd.so
  -rwxr-xr-x 1root root   12432 May1 13:58 gettext.so
  -rwxr-xr-x 1root root   46472 May1 13:58 gmp.so
  -rwxr-xr-x 1root root   42192 May1 13:58 iconv.so
  -rwxr-xr-x 1root root   99752 May1 13:58 imap.so
  -rwxr-xr-x 1root root   42696 May1 13:58 json.so
  -rwxr-xr-x 1root root   59912 May1 13:58 ldap.so
  -rwxr-xr-x 1root root 1408328 May1 13:58 mbstring.so
  -rwxr-xr-x 1root root   42200 May1 13:58 mcrypt.so
  -rwxr-xr-x 1root root139352 May1 13:58 mysqli.so
  -rwxr-xr-x 1root root   53800 May1 13:58 mysql.so
  -rwxr-xr-x 1root root   64936 May1 13:58 odbc.so
  -rwxr-xr-x 1root root130960 May1 13:58 opcache.so
  -rwxr-xr-x 1root root   32800 May1 13:58 pdo_mysql.so
  -rwxr-xr-x 1root root   24160 May1 13:58 pdo_odbc.so
  -rwxr-xr-x 1root root101784 May1 13:58 pdo.so
  -rwxr-xr-x 1root root   25984 May1 13:58 pdo_sqlite.so
  -rwxr-xr-x 1root root265424 May1 13:58 phar.so
  -rwxr-xr-x 1root root936484 Jun5 02:05 redis.so
  -rwxr-xr-x 1root root   11880 May1 13:58 shmop.so
  -rwxr-xr-x 1root root   47608 May1 13:58 simplexml.so
  -rwxr-xr-x 1root root   87728 May1 13:58 sockets.so
  -rwxr-xr-x 1root root   45744 May1 13:58 sqlite3.so
  -rwxr-xr-x 1root root   15376 May1 13:58 tokenizer.so
  -rwxr-xr-x 1root root   33256 May1 13:58 wddx.so
  -rwxr-xr-x 1root root   30192 May1 13:58 xmlreader.so
  -rwxr-xr-x 1root root   77992 May1 13:58 xmlrpc.so
  -rwxr-xr-x 1root root   48576 May1 13:58 xml.so
  -rwxr-xr-x 1root root   44912 May1 13:58 xmlwriter.so
  -rwxr-xr-x 1root root   33928 May1 13:58 xsl.so
  -rwxr-xr-x 1root root   94808 May1 13:58 zip.so

页: [1]
查看完整版本: linux+php5.5+nginx+支持redis安装部署