Linux下的nginx反向代理

本文介绍了Nginx服务器的安装过程及配置方法,包括依赖软件包的安装、配置文件详解,并展示了Nginx服务启动后的进程情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

[root@localhost nginx-1.4.7]# yum install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre pcre-devel   -y

[root@localhost pcre-8.33]# ./configure --enable-utf8 --enable-rebuild-chartables --enable-newline-is-any --enable-pcregrep-libz

[root@localhost nginx-1.4.7]# yum install perl perl-devel perl-ExtUtils-Embed

[root@localhost nginx-1.4.7]# yum install libxslt  libxslt-devel   -y

 

 

[root@localhost nginx-1.4.7]# ./configure --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx/nginx.pid --user=nginx --group=nginx --with-rtsig_module --with-select_module --with-poll_module --with-http_ssl_module --with-http_realip_module  --with-http_addition_module --with-http_xslt_module --with-http_image_filter_module --with-http_sub_module --with-http_dav_module --with-http_gzip_static_module --with-http_flv_module --with-http_perl_module --with-perl=/usr/bin/perl --http-log-path=/var/log/nginx/access.log --with-pcre --with-pcre=/softs/pcre-8.33/  --with-http_stub_status_module

[root@localhost nginx-1.4.7]# make

[root@localhost nginx-1.4.7]# make install

修改nginx配置文件

[root@localhost conf]# cat /usr/local/nginx/conf/nginx.conf| more 


user  nginx;                      ##指定运行的用户
worker_processes  4;      ##启动的进程数目


error_log  /var/log/nginx/error.log error;   ###重新定义错误日志的路径和级别

pid        /var/run/nginx/nginx.pid;           ###进程


events {
    worker_connections  1024;               ##连接数
}




http {
    include       mime.types;
    default_type  application/octet-stream;


    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

  access_log  /var/log/nginx/access.log  main;                        ###定义日志格式


    sendfile        on;
    #tcp_nopush     on;


    #keepalive_timeout  0;
    keepalive_timeout  65;               #会话保持时间


    gzip  on;


    server {
        listen       80;
        server_name  localhost;


        #charset koi8-r;


        #access_log  logs/host.access.log  main;


        location / {
            root   /www;                              ####DocumentRoot
            index  index.html index.htm index.php;
        }


        #error_page  404              /404.html;


        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }


  
    }

 

 

[root@localhost nginx]# ps -ef |grep nginx
root     14416     1  0 15:56 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nginx    14417 14416  0 15:56 ?        00:00:00 nginx: worker process                                          
nginx    14418 14416  0 15:56 ?        00:00:00 nginx: worker process                                          
nginx    14419 14416  0 15:56 ?        00:00:00 nginx: worker process                                          
nginx    14420 14416  0 15:56 ?        00:00:00 nginx: worker process                                          
root     15619 35790  0 16:00 pts/0    00:00:00 grep nginx

这里总共四个进程,就是前面配置文件中的所指定的process。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值