文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>使用nginx做静态文件服务器

使用nginx做静态文件服务器

时间:2008-12-03  来源:szszszsz

1.系统环境

操作系统:centos5.2

文件服务器只是提供静态文件服务

2.安装nginx

需安装pcre-devel-6.6-2.el5_1.7 

tar zxvf nginx-0.6.32.tar.gz

shell>./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module

shell>make

shell>make install

3.配置nginx

编辑/usr/local/nginx/conf文件

全局参数设置:

user  nobody;                               ##使用普通帐号nobody启动服务##

worker_processes  8;                   ##工作进程设置##

error_log  logs/error.log;

pid        logs/nginx.pid;

events {

    worker_connections  5000;        ##每worker_processes进程的最大连接数##

    use epoll;                                  ##使用epoll##

}

http{ }项参数设置:

server_names_hash_bucket_size 64;  ##当设置多个虚拟主机sever时,需增大此参数,默认32#

server_tokens off;                         ##禁止显示nginx软件的版本号##

sendfile      on;

tcp_nodelay       on;

keepalive_timeout  30;

4.虚拟主机的设置

" www.test.com "的设置:

 server {

        listen       80;

        server_name  www.test.com ;

        charset utf-8;

        root   /data/www.test.com ;

        index  index.html index.htm;

       }

5.服务的启动停止

设置自启动

nginx的启动脚本可由支持centos版本的nginx的rpm的安装文件取得,拷贝到

/etc/init.d/目录下。修改启动脚本的两个参数项:

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

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

   执行以下命令
   chkconfig --add nginx
   chkconfig nginx on
   执行/etc/init.d/nginx start   启动
   /etc/init.d/nginx stop     停止

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载