Nginx安装

  • cd /usr/local/src

(http://nginx.org/en/download.html)

#!/bin/bash
# chkconfig: -
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=
prog="Nginx"
start()
{
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
}
stop()
{
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
}
reload()
{
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}
restart()
{
stop
start
}
configtest()
{
$NGINX_SBIN -c $NGINX_CONF -t
return
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|configtest}"
RETVAL=
esac
exit $RETVAL

  • chmod 755 /etc/init.d/nginx
  • chkconfig --add nginx
  • chkconfig nginx on
  • cd /usr/local/nginx/conf/; mv nginx.conf nginx.conf.bak
  • vim nginx.conf //写入如下内容(参考)
user nobody nobody;
worker_processes ;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile ;
events
{
use epoll;
worker_connections ;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size ;
server_names_hash_max_size ;
log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
' $host "$request_uri" $status'
' "$http_referer" "$http_user_agent"';
sendfile on;
tcp_nopush on;
keepalive_timeout ;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size ;
client_header_buffer_size 1k;
large_client_header_buffers 4k;
request_pool_size 4k;
output_buffers 32k;
postpone_output ;
client_max_body_size 10m;
client_body_buffer_size 256k;
client_body_temp_path /usr/local/nginx/client_body_temp;
proxy_temp_path /usr/local/nginx/proxy_temp;
fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
fastcgi_intercept_errors on;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 8k;
gzip_comp_level ;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css text/htm
application/xml;
server
{
listen ;
server_name localhost;
index index.html index.htm index.php;
root /usr/local/nginx/html;
location ~ \.php$
{
include fastcgi_params;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
}
}
}

  • /usr/local/nginx/sbin/nginx -t
  • /etc/init.d/nginx  start
  • netstat -lntp |grep 80
  • 测试php解析

vi /usr/local/nginx/html/1.php //加入如下内容

<?php

echo "test php scripts.";

?>

curl localhost/1.php

最新文章

  1. JavaScript随笔7
  2. Cache,MemCache,Application,Cookie等其它缓存汇总
  3. 解决问题--VS2012中一个Panel覆盖另一个Panel时拖动时容易造成两个控件成父子关系的避免
  4. modbus协议讲义
  5. ActiveMQ 的安装
  6. 纠结的CLI C++与Native C++的交互
  7. RMI入门教程
  8. android 中webview调用js
  9. BUAA 2014级数据结构第五次上机 二叉树之数组转换广义表
  10. Guava 源码分析(Cache 原理 对象引用、事件回调)
  11. luogu3305/bzoj3130 费用流 (二分答案+dinic)
  12. stm32 延时函数 delay_ms 范围
  13. mac最常用快捷键
  14. 【php】基础学习3
  15. 经验搜索排名---google已经做过类似的了(我想多了)
  16. 排列算法(reverse...rotate...next_permutation)
  17. Transform动画初解 in Swift
  18. rsync | scp文件同步命令使用
  19. CSS3选择器、低版本解决方案及各浏览器私有前缀
  20. jvm性能监控工具

热门文章

  1. cf 366D D. Dima and Trap Graph (计算所有线段共同覆盖的某段区间)
  2. logrotate 日志轮询(转存)
  3. JAVA-JSP内置对象之session对象获得session的其他信息
  4. 基于jQuery实现的腾讯互动娱乐网站特效
  5. python matplotlib 画图
  6. 网页QQ弹出
  7. drupal8 管理入门
  8. Extjs4.x Tree树刷新,默认选中展开到最后一次选中的节点
  9. ajax 多个参数问题,如何既能表单序列化获取,又能加参数,加全部代码
  10. WebRTC 源码分析(四):VideoCRE 与内存抖动优化