[root@node1 ~]# chkconfig --add nginx[root@node1 ~]# chkconfig nginx on配置nginx
[root@node1 ~]# vim /etc/nginx/nginx.confworker_processes 2; #worker进程的个数error_log /var/log/nginx/error.log notice; #错误日志路径及级别events { worker_connections 1024; #每个worker能够并发响应的最大请求数}http { include mime.types; #支持多媒体类型 default_type Application/octet-stream; sendfile on; #由内核直接转发 #keepalive_timeout 0; keepalive_timeout 5; #持久连接5s gzip on; #开启压缩功能 server { listen 80; server_name bbs.scholar.com; add_header X-via $server_addr; #让客户端能够看到代理服务器的IP location / { root /www/bbs; index index.php index.html index.htm; } location ~* .(jpg|jpeg|png|gif|js|css)$ { #匹配静态内容 root /www/bbs;} location ~ .php$ { #匹配动态内容 root /www/bbs; fastcgi_pass 172.16.10.110:9000; #代理到的服务器 fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME scripts$fastcgi_script_name; include fastcgi_params; } }}[root@node1 ~]# vim /etc/nginx/fastcgi_params fastcgi_param GATEWAY_INTERFACE CGI/1.1;fastcgi_param SERVER_SOFTWARE nginx;fastcgi_param QUERY_STRING $query_string;fastcgi_param REQUEST_METHOD $request_method;fastcgi_param CONTENT_TYPE $content_type;fastcgi_param CONTENT_LENGTH $content_length;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;fastcgi_param SCRIPT_NAME $fastcgi_script_name;fastcgi_param REQUEST_URI $request_uri;fastcgi_param DOCUMENT_URI $document_uri;fastcgi_param DOCUMENT_ROOT $document_root;fastcgi_param SERVER_PROTOCOL $server_protocol;fastcgi_param REMOTE_ADDR $remote_addr;fastcgi_param REMOTE_PORT $remote_port;fastcgi_param SERVER_ADDR $server_addr;fastcgi_param SERVER_PORT $server_port;fastcgi_param SERVER_NAME $server_name;[root@node1 ~]# service nginx start安装配置memcached
#解决依赖关系[root@scholar ~]# yum groupinstall "Development Tools" "Server Platform Deveopment" -y#安装libevent#memcached依赖于libevent API,因此要事先安装之[root@scholar ~]# tar xf libevent-2.0.22-stable.tar.gz [root@scholar ~]# cd libevent-2.0.22-stable[root@scholar libevent-2.0.22-stable]# ./configure --prefix=/usr/local/libevent[root@scholar libevent-2.0.22-stable]# make && make install[root@scholar ~]# echo "/usr/local/libevent/lib" > /etc/ld.so.conf.d/libevent.conf[root@scholar ~]# ldconfig #安装配置memcached[root@scholar ~]# tar xf memcached-1.4.24.tar.tar [root@scholar ~]# cd memcached-1.4.24[root@scholar memcached-1.4.24]# ./configure --prefix=/usr/local/memcached --with-libevent=/usr/local/libevent[root@scholar memcached-1.4.24]# make && make install提供脚本
[root@scholar ~]# vim /etc/init.d/memcached#!/bin/bash## Init file for memcached## chkconfig: - 86 14# description: Distributed memory caching daemon## processname: memcached# config: /etc/sysconfig/memcached. /etc/rc.d/init.d/functions## Default variablesPORT="11211"USER="nobody"MAXCONN="1024"CACHESIZE="64"RETVAL=0prog="/usr/local/memcached/bin/memcached"desc="Distributed memory caching"lockfile="/var/lock/subsys/memcached"start() { echo -n $"Starting $desc (memcached): " daemon $prog -d -p $PORT -u $USER -c $MAXCONN -m $CACHESIZE RETVAL=$? [ $RETVAL -eq 0 ] && success && touch $lockfile || failure echo return $RETVAL}stop() { echo -n $"Shutting down $desc (memcached): " killproc $prog RETVAL=$? [ $RETVAL -eq 0 ] && success && rm -f $lockfile || failure echo return $RETVAL}restart() { stop start}reload() { echo -n $"Reloading $desc ($prog): " killproc $prog -HUP RETVAL=$? [ $RETVAL -eq 0 ] && success || failure echo return $RETVAL}case "$1" in start) start ;; stop) stop ;; restart) restart ;; condrestart) [ -e $lockfile ] && restart RETVAL=$? ;;reload) reload ;; status) status $prog RETVAL=$? ;; *) echo $"Usage: $0 {start|stop|restart|condrestart|status}" RETVAL=1esacexit $RETVAL授权并启动服务
[root@scholar ~]# vim /etc/init.d/memcached[root@scholar ~]# chmod +x /etc/init.d/memcached[root@scholar ~]# chkconfig --add memcached[root@scholar ~]# service memcached start安装配置php
#解决依赖关系[root@scholar ~]# yum groupinstall "Development tools" "Server Platform Development" -y[root@scholar ~]# yum -y groupinstall "Desktop Platform Development"[root@scholar ~]# yum -y install bzip2-devel libmcrypt-devel[root@scholar ~]# tar xf php-5.4.26.tar.bz2 [root@scholar ~]# cd php-5.4.26[root@scholar php-5.4.26]# ./configure --prefix=/usr/local/php --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --enable-fpm --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-openssl[root@scholar php-5.4.26]# make && make install
推荐阅读
- API网关的背景、架构以及落地方案
- 用SQL语句实现随机抽奖,小函数包含大智慧
- Python入门:4段简短代码实现Excel读写
- 产品架构图到底是怎么“画”出来的?
- 在MySQL中实现Rank高级排名函数
- 实现扫码登陆的最简单方案与原理
- 飞碟飞行原理是什么?我们有可能实现吗? 飞碟原理
- js实现继承的方法以及优缺点
- go语言网络编程之session的实现
- 如何做高并发架构设计!