工作笔记-- 源码安装nginx

 源码安装nginx

1、安装nginx的依赖包

[root@localhost ~]# yum -y install gcc gcc-c++ openssl openssl-devel pcre pcre-devel zlib zlib-devel

 2、解压安装

[root@localhost dxwh8078]# mv nginx-1.15.9.tar.gz /usr/local/src/

[root@localhost dxwh8078]# cd /usr/local/src/

[root@localhost src]# tar zxf nginx-1.15.9.tar.gz

[root@localhost nginx-1.15.9]# ./configure --prefix=/usr/local/nginx

[root@localhost nginx-1.15.9]# make && make install

[root@localhost nginx]# cd /usr/local/nginx/sbin/

[root@localhost sbin]# ./nginx

[root@localhost ~]# cp /usr/local/nginx/conf/nginx.conf{,_`date +%F`.bak}

3、nginx配置

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

user  dxwh8078;

worker_processes  2;

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

events {

    worker_connections  1024;

}

http {

    include       mime.types;

    default_type  application/octet-stream;

    #access_log  logs/access.log  main;

    sendfile        on;

    #tcp_nopush     on;

    keepalive_timeout  65;

    gzip  on;

    server {

        listen       80;

        server_name  localhost;

        charset utf-8;

        #access_log  logs/host.access.log  main;

        location / {

            root   /data/nginx/;

            autoindex on;

            autoindex_exact_size off;

            autoindex_localtime on;

        }

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

    }

原文地址:https://www.cnblogs.com/zhaop8078/p/11400189.html