系统环境
[root@localhost~]# cat /etc/redhat-release
CentOSrelease 6.5 (Final)
[root@localhost~]# 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的版本
[root@localhostphpredis-master]# php -v
PHP 5.5.12(cli) (built: May 1 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
[root@localhost~]# netstat -lnt|grep 9000
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN
[root@localhost~]#chkconfig php-fpm on
添加nginx yum源码
[root@localhost~]# cat /etc/yum.repos.d/nginx.repo
[nginx]
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
[root@localhostphpredis-master]# nginx -v
nginxversion: nginx/1.6.0
chkconfignginx on
[root@localhostconf.d]# 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_page 500 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_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www/www.youxi.com $fastcgi_script_name;
include fastcgi_params;
}
}
nginx.conf配置文件
[root@localhostnginx]# cat nginx.conf
user nginx nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
use epoll;
worker_connections 1024;
}
http {
include /etc/nginx/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 /var/log/nginx/access.log main;
#tcp_nopush on;
keepalive_timeout 65;
server_names_hash_bucket_size 128;
client_header_buffer_size 128k;
large_client_header_buffers 4 256k;
client_header_timeout 1m;
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并解压
[root@localhost~]# phpize
[root@localhost~]# ./configure
[root@localhost~]# make && make install
/etc/php.ini下面添加redis模块
extension="redis.so"
重启php-fpm和nginx
/etc/init.d/php-fpmrestart
/etc/init.d/nginxreload
查看支持的模块
[root@localhostphpredis-master]# ll /usr/lib64/php/modules/
总用量 7560
-rwxr-xr-x 1root root 29264 May 1 13:58 bcmath.so
-rwxr-xr-x 1root root 22440 May 1 13:58 bz2.so
-rwxr-xr-x 1root root 30616 May 1 13:58 calendar.so
-rwxr-xr-x 1root root 12712 May 1 13:58 ctype.so
-rwxr-xr-x 1root root 77544 May 1 13:58 curl.so
-rwxr-xr-x 1root root 171256 May 1 13:58 dom.so
-rwxr-xr-x 1root root 60584 May 1 13:58 exif.so
-rwxr-xr-x 1root root 2708016 May 1 13:58fileinfo.so
-rwxr-xr-x 1root root 49608 May 1 13:58 ftp.so
-rwxr-xr-x 1root root 390192 May 1 13:58 gd.so
-rwxr-xr-x 1root root 12432 May 1 13:58 gettext.so
-rwxr-xr-x 1root root 46472 May 1 13:58 gmp.so
-rwxr-xr-x 1root root 42192 May 1 13:58 iconv.so
-rwxr-xr-x 1root root 99752 May 1 13:58 imap.so
-rwxr-xr-x 1root root 42696 May 1 13:58 json.so
-rwxr-xr-x 1root root 59912 May 1 13:58 ldap.so
-rwxr-xr-x 1root root 1408328 May 1 13:58 mbstring.so
-rwxr-xr-x 1root root 42200 May 1 13:58 mcrypt.so
-rwxr-xr-x 1root root 139352 May 1 13:58 mysqli.so
-rwxr-xr-x 1root root 53800 May 1 13:58 mysql.so
-rwxr-xr-x 1root root 64936 May 1 13:58 odbc.so
-rwxr-xr-x 1root root 130960 May 1 13:58 opcache.so
-rwxr-xr-x 1root root 32800 May 1 13:58 pdo_mysql.so
-rwxr-xr-x 1root root 24160 May 1 13:58 pdo_odbc.so
-rwxr-xr-x 1root root 101784 May 1 13:58 pdo.so
-rwxr-xr-x 1root root 25984 May 1 13:58 pdo_sqlite.so
-rwxr-xr-x 1root root 265424 May 1 13:58 phar.so
-rwxr-xr-x 1root root 936484 Jun 5 02:05 redis.so
-rwxr-xr-x 1root root 11880 May 1 13:58 shmop.so
-rwxr-xr-x 1root root 47608 May 1 13:58 simplexml.so
-rwxr-xr-x 1root root 87728 May 1 13:58 sockets.so
-rwxr-xr-x 1root root 45744 May 1 13:58 sqlite3.so
-rwxr-xr-x 1root root 15376 May 1 13:58 tokenizer.so
-rwxr-xr-x 1root root 33256 May 1 13:58 wddx.so
-rwxr-xr-x 1root root 30192 May 1 13:58 xmlreader.so
-rwxr-xr-x 1root root 77992 May 1 13:58 xmlrpc.so
-rwxr-xr-x 1root root 48576 May 1 13:58 xml.so
-rwxr-xr-x 1root root 44912 May 1 13:58 xmlwriter.so
-rwxr-xr-x 1root root 33928 May 1 13:58 xsl.so
-rwxr-xr-x 1root root 94808 May 1 13:58 zip.so