阅读 80

nginx搭建-源码

【创建用户】

[root@web01 etc]# useradd -s /sbin/nologin -M www

【安装环境依赖】

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

openssl openssl-devel

【下载解压安装包】

[root@web01 ~]# wget http://nginx.org/download/nginx-1.18.0.tar.gz

[root@web01]# tar xzvf nginx-1.18.0.tar.gz

[root@web01 nginx-1.18.0]# cd nginx-1.18.0/

【编译安装-指定参数】

./configure  --user=nginx --group=nginx --prefix=/application/nginx-1.16.0/ \

--with-http_stub_status_module  --with-http_ssl_module --with-pcre&&make&&make install

###configure参数的作用

--prefix=<path> 《==Nginx安装的根路径,所有其它路径都要依赖该选项

--sbin-path=<path> 《==指定nginx二进制文件的路径,没指定的话 这个路径依赖--prefix选项

--conf-path=<path> 《==如果在命令行未指定配置文件,那么将会通过这里指定的路径,nginx将会去那里查找他的配置文件

--error-log-path=<path> 《==错误文件路径,nginx写入错误日志文件地址,除非有其他配置

--pid-path=<path> 《==nginx master进程pid写入的文件位置,通常在var/run下

--lock-path=<path> 《==共享存储器互斥锁文件路径

--user=<user> 《==worker进程运行的用户

--group=<group> 《==worker进程运行的组

--width-debug 《==启用调试日志,生产环境不推荐

--with-pcre 《==伪静态用到的

--with-http_stub_status_module 《==状态

--with-http_ssl_module      《==加密 443

【做软连接】

###目的就是为了以后改变版本开发那边不需要修改目录,告诉开发软连接即可

[root@web01 nginx-1.18.0]# ln -s /application/nginx-1.16.0/ /application/nginx

【启动并测试】

[root@web01 nginx-1.18.0]# /application/nginx/sbin/nginx  《==启动服务

nginx -s stop    《==停止服务

nginx -s reload  《==平滑重载服务

nginx -t        《==检查语法

【目录文件解释】

[root@web01 nginx-1.18.0]# tree /application/nginx

/application/nginx

├── client_body_temp

├── conf

│   ├── fastcgi.conf《==和PHP有关配置文件

│   ├── fastcgi.conf.default

│   ├── fastcgi_params

│   ├── fastcgi_params.default

│   ├── koi-utf

│   ├── koi-win

│   ├── mime.types《==媒体类型

│   ├── mime.types.default《==媒体类型模板

│   ├── nginx.conf《==主配置文件

│   ├── nginx.conf.default《==主配置文件模板

│   ├── scgi_params

│   ├── scgi_params.default《==都是动态服务接口配置

│   ├── uwsgi_params《==配合python服务

│   ├── uwsgi_params.default

│   └── win-utf

├── fastcgi_temp《==临时文件

├── html

│   ├── 50x.html《==默认错误跳转页

│   └── index.html《==默认首页

├── logs

│   ├── access.log《==访问日志

│   ├── error.log《==错误日志

│   └── nginx.pid《==进程pid文件

├── proxy_temp《==临时文件

├── sbin

│   └── nginx《==启动命令

├── scgi_temp《==临时文件

└── uwsgi_temp《==临时文件

【nginx编译常用参数】

./configure \

--prefix=/application/nginx-1.18 \

--user=www \

--group=www \

--with-http_ssl_module \

--with-http_flv_module \

--with-http_stub_status_module \

--with-http_gzip_static_module \

--with-pcre \

--with-file-aio \

--with-http_secure_link_module \

--with-threads

作者:神马琦

原文链接:https://www.jianshu.com/p/8232297d24fd

文章分类
后端
文章标签
版权声明:本站是系统测试站点,无实际运营。本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 XXXXXXo@163.com 举报,一经查实,本站将立刻删除。
相关推荐