nginx安装
2022/1/6 7:09:56
本文主要是介绍nginx安装,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1 安装依赖库
yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
2 下载nginx
在nginx下载页面获取一个最新的稳定版本的下载链接,使用wget下载,然后解压缩
cd /usr/local wget http://nginx.org/download/nginx-1.20.2.tar.gz tar -zxvf nginx-1.20.2.tar.gz
3 安装nginx
- ./configure
检测系统中的环境,可以通过在 configure 后加上参数来对下一步编译进行控制,比如可以通过--prefix
指定安装路径,--with-http_ssl_module
添加ssl模块支持https,执行完会生成Makefile文件
–prefix 指定安装路径
./configure ... Configuration summary + using system PCRE library + OpenSSL library is not used + using system zlib library nginx path prefix: "/usr/local/nginx" nginx binary file: "/usr/local/nginx/sbin/nginx" nginx modules path: "/usr/local/nginx/modules" nginx configuration prefix: "/usr/local/nginx/conf" nginx configuration file: "/usr/local/nginx/conf/nginx.conf" nginx pid file: "/usr/local/nginx/logs/nginx.pid" nginx error log file: "/usr/local/nginx/logs/error.log" nginx http access log file: "/usr/local/nginx/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp" ./configure --prefix=/usr/local/nginx20 --with-http_ssl_module ... Configuration summary + using system PCRE library + using system OpenSSL library + using system zlib library nginx path prefix: "/usr/local/nginx20" nginx binary file: "/usr/local/nginx20/sbin/nginx" nginx modules path: "/usr/local/nginx20/modules" nginx configuration prefix: "/usr/local/nginx20/conf" nginx configuration file: "/usr/local/nginx20/conf/nginx.conf" nginx pid file: "/usr/local/nginx20/logs/nginx.pid" nginx error log file: "/usr/local/nginx20/logs/error.log" nginx http access log file: "/usr/local/nginx20/logs/access.log" nginx http client request body temporary files: "client_body_temp" nginx http proxy temporary files: "proxy_temp" nginx http fastcgi temporary files: "fastcgi_temp" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
- make && make install
编译并且安装,安装完会在prefix路径生成指定文件夹
make && make install
4 启动nginx
启动时可以先使用./nginx -t
检查nginx配置语法是否正确,使用./nginx
启动,./nginx -s reload
重启,./nginx -s stop
停止服务
cd nginx20/sbin ./nginx
5 其他
nginx使用的过程中缺失模块,./nginx -V
查看当前configure ,然后在当前配置基础上添加相应配置,make编译(不需要make install 安装) ,将obj
文件夹中的nginx替换掉安装路径sbin
中nginx文件。
./nginx -V nginx version: nginx/1.20.2 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/usr/local/nginx20 --with-http_ssl_module
这篇关于nginx安装的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-10-29Nginx发布学习:从入门到实践的简单教程
- 2024-10-28Nginx发布:新手入门教程
- 2024-10-21nginx 怎么设置文件上传最大20M限制-icode9专业技术文章分享
- 2024-10-17关闭 nginx的命令是什么?-icode9专业技术文章分享
- 2024-09-17Nginx实用篇:实现负载均衡、限流与动静分离
- 2024-08-21宝塔nginx新增8022端口方法步骤-icode9专业技术文章分享
- 2024-08-21nginx配置,让ws升级为wss访问的方法步骤-icode9专业技术文章分享
- 2024-08-15nginx ws代理配置方法步骤-icode9专业技术文章分享
- 2024-08-14nginx 让访问带有/relid的地址返回404 ,例子 /relid-x-0.36-y-131.html-icode9专业技术文章分享
- 2024-08-14nginx 判断地址有/statics/的路径,指向到/home/html/statics/目录-icode9专业技术文章分享