nginx服务器简单搭建配置

来源:互联网 发布:上海黄金行情软件 编辑:程序博客网 时间:2024/04/27 23:14

 下载nginx

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

安装nginx

安装依赖的程序

gzip 

pcre下载地址http://sourceforge.net/projects/pcre/files/pcre/

openssl

安装命令

tar -zxvf nginx-1.0.10.tar.gz

cd nginx-1.0.10

./configure

make;make install

nginx还有更多的选项可在安装时进行配置

配置nginx

配置文件路径/usr/local/nginx/conf/nginx.conf

user  nobody  nobody;worker_processes  1;error_log  logs/error.log;events {    worker_connections  1024;}#设定http服务器,利用它的反向代理功能提供负载均衡支持http {  include       mime.types; default_type  application/octet-stream; sendfile           on; keepalive_timeout  65; #访问地址 upstream localhost {  #设定负载均衡的服务器列表  server   localhost:8080;  server   localhost:8081; } #设定虚拟主机,默认为监听80端口    server {        listen       80;        server_name  localhost;        charset utf-8;        location / {            proxy_pass  http://localhost;        }    }}


启动nginx    linux命令 /usr/local/nginx/sbin/nginx

nginx -s stop             快速关闭nginx,可能不保存相关信息,并迅速终止web服务。(quick exit)
nginx -s quit              平稳关闭nginx,保存相关信息,有安排的结束web服务。(graceful exit)
nginx -s reload          因改变了nginx相关配置,需要重新加载配置而重载。(changing configuration,start a new worker,quitting an old worker gracefully.)
nginx -s reopen         重新打开日志文件。(reopenging log files)

 

原创粉丝点击