编译安装Nginx步骤详解
1,去Nginx官方网站下载源码包并解压
curl -O 或wget 跟下载链接
tar -xf 解压
2,进入nginx解压后的目录执行./configure …
./configure --prefix=/usr/local/sc_nginx --user cali --group cali --with stream --with threads --with-http_ssl_module --with-http_realip_module --with-http_stub_status_module
参数解释:
–prefix 用于指定nginx编译安装后的目录
–user 指定用户
–group 指定组
–with stream 启动nginx四层负载均衡(传输层)
–with threads 启动进程池模块
–with-http_ssl_module 启动nginx的https服务
–with-http_realip_module 启动realip模块
–with-http_stub_status_module 启动nignx的状态查看模块
其他模块:
日志记录模块ngx_http_log_module
压缩相关选项ngx_http_gzip_module
重定向模块ngx_http_rewrite_module
引用模块ngx_http_referer_module
反向代理模块ngx_http_proxy_module
更多模块详情 请点击此处
注:
直接执行上述的./configure 命令 可能会出错,需要我们手动解决依赖关系,根据提示安装一些依赖包,一般需要安装:
yum install pcre-devel gcc openssl-devel -y
3,编译安装
make && make install
安装后可看到指定目录的目录结构
4,启动nginx
- 先创建一个软链接:ln -s /usr/local/sc_nginx/sbin/nginx /usr/bin/nginx
- nginx start 启动nginx
- ps aux |grep nginx 查看nginx进程是否启动
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)