Nginx 编译安装
介绍
Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。Nginx是由伊戈尔·赛索耶夫为俄罗斯访问量第二的Rambler.ru站点(俄文:Рамблер)开发的,第一个公开版本0.1.0发布于2004年10月4日。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、简单的配置文件和低系统资源的消耗而闻名。2011年6月1日,nginx 1.0.4发布。
服务器系统: CentOS7
Nginx版本:1.24.0
Nginx下载地址: https://nginx.org/en/download.html
1 安装编译环境及Nginx依赖
$ yum install -y make gcc gcc-c++ openssl openssl-devel pcre-devel zlib-devel
2 解压Nginx压缩包
$ tar -zxvf nginx-1.24.0.tar.gz
$ mv nginx-1.24.0 nginx-1.24.0-source
3 进入nginx的文件夹,编译配置
$ cd nginx-1.24.0-source
./configure \
--prefix=../nginx-1.24.0 \
--conf-path=conf/nginx.conf \
--error-log-path=logs/error.log \
--http-log-path=logs/access.log \
--pid-path=logs/nginx.pid \
--lock-path=logs/nginx.lock \
--modules-path=modules \
--sbin-path=nginx \
--http-client-body-temp-path=client_temp \
--http-proxy-temp-path=proxy_temp \
--http-fastcgi-temp-path=fastcgi_temp \
--http-uwsgi-temp-path=uwsgi_temp \
--http-scgi-temp-path=scgi_temp \
--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 \
--with-file-aio \
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_ssl_preread_module \
--with-http_v2_module
配置编译会生成一个Makefile文件和objs目录,包含着我们的编译配置信息
4 编译安装
$ make && make install
make 程序会按照我们事先设定的配置打包生成可执行文件nginx,位于objs目录下 make install 程序会按照我们事先设定的配置移动刚刚生成的文件和文件夹
5 测试
# 查看当前Nginx版本
$ cd ../nginx-1.24.0
$ ./nginx -v
nginx version: nginx/1.24.0
- 启动测试
$ ./nginx
netstat -nltp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 11789/nginx: master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 940/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1113/master
tcp6 0 0 :::22 :::* LISTEN 940/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1113/master
```
版权声明:
本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自
运维小记!
喜欢就支持一下吧
打赏
微信
支付宝