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;
}
}
}