nginx配置

1 在nginx官方网站下载一个rpm包,下载地址是:http://nginx.org/en/download.html

wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

2 安装这个rpm包

rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm 

3. 正式安装nginx

 yum -y install nginx

4. php重启脚本

!/bin/bash


PHP_PATH=/usr/local
DESC="php-fpm daemon"
NAME=php-fpm


DAEMON=$PHP_PATH/php5/sbin/$NAME
CONFIGFILE=$PHP_PATH/php5/etc/php-fpm.conf
PIDFILE=$PHP_PATH/php5/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME


test -x $DAEMON || exit 0


rh_start() {
    $DAEMON -y $CONFIGFILE || echo -n " already running"
}


rh_stop() {
    kill -QUIT `cat $PIDFILE` || echo -n " not running"
}


rh_reload() {
    kill -HUP `cat $PIDFILE` || echo -n " can't reload"
}


case "$1" in
    start)
        echo -n "Starting $DESC: $NAME"
        rh_start
        echo "."
        ;;  
    stop)
        echo -n "Stopping $DESC: $NAME"
        rh_stop
        echo "."
        ;;  
    reload)
        echo -n "Reloading $DESC configuration..."
        rh_reload
        echo "reloaded."
        ;;  
    restart)
        echo -n "Restarting $DESC: $NAME"
        rh_stop
        sleep 1
        rh_start
        echo "."
        ;;
    *)
        echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
        exit 3
        ;;
esac
exit 0



重启nginx脚本

#!/bin/sh 
# 
# nginx - this script starts and stops the nginx daemin 
#

[ "$NETWORKING" = "no" ] && exit 0 

nginx="/usr/local/nginx/sbin/nginx" 

NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" 

lockfile=/var/lock/subsys/nginx 

start() { 
    [ -x $nginx ] || exit 5 
    [ -f $NGINX_CONF_FILE ] || exit 6 
    $nginx -c $NGINX_CONF_FILE 
    ps aux | grep nginx
    retval=$? 
    echo 
    [ $retval -eq 0 ] && touch $lockfile 
    return $retval 
} 

stop() { 
    retval=$? 
    pkill nginx
    ps aux| grep nginx
    return $retval 
} 

restart() { 
    configtest || return $?  
    stop 
    start 
} 

reload() { 
    configtest || return $?  
    killproc $nginx -HUP 
    RETVAL=$? 
    echo 
} 




worker_processes  1;  
events {
    worker_connections  1024;
}




http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on; 
    keepalive_timeout  65; 
    server {
        listen      222.128.111.111:9998;
        server_name www.dlanes.mobi dlanes.mobi;
        location / { 
            root   html;
            index  index.html index.htm;
        }   


        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }   


        location ~ \.php$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html/$fastcgi_script_name;
            include        fastcgi_params;
        }   
            
        location ~ .*\.(gif|xml|jpg|jpeg|png|bmp|swf|js|css|html|ipa)$ #设定访问静态文件直接读取不经过tomcat
        {   
            expires 30d;
        }   
    }   
}


评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值