linux (Centos7) 编译安装nginx

在引用的博客上面作了修改
html

  • 1、安装前

        如下部分引用
        一、安装必备工具:nginx

$ yum -y install gcc gcc-c++ autoconf automake
 
$ yum -y install zlib zlib-devel openssl openssl-devel pcre-devel

说明:c++

pcre: 用来做地址重写的功能。shell

zlib:nginx 的gzip模块,传输数据打包,省流量(但消耗资源)。dom

openssl:提供ssl加密协议。工具


二、新建一个系统级用户组和匿名用户,以及下面编译时使用加密

$ sudo groupadd -r nginx
 
$ sudo useradd -s /sbin/nologin -g nginx -r nginx-user
  • 2、Nginx编译安装:

    一、下载Nginx:http://nginx.org/en/download.htmlspa

    二、编译:日志

$ tar -zxvf nginx-1.9.2.tar.gz
 
$ cd nginx-1.9.2/
 
$ ./configure \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
...
...
...
    用下面的命令查看每一项的做用
$ ./configure --help

    编译日志就不写了code

三、安装

$ make && make install

四、添加进环境变量

$ vi /etc/profile

装到哪,就写哪一个文件的路径,我是默认的

PATH=/usr/local/nginx/sbin:$PATH
export PATH

五、启动

ginx -c /usr/local/nginx/conf/nginx.conf
相关文章
相关标签/搜索