@源码安装nginx及源码包下载

1|0一、下载源码包

复制链接打开 链接:*https://pan.baidu.com/s/17gUkX-UC9GHTf3rkY8aV_Q* 提取码:**1314** ~~~~复制这段内容后打开,操作更方便哦~~~~

1|0二、安装nginx

#下载Nginx源码包 [root@web01 ~]# wget http://nginx.org/download/nginx-1.12.2.tar.gz #解压Nginx源码包到/opt目录下,并查看Nginx源文件结构 [root@web01 ~]# tar -xzvf nginx-1.12.2.tar.gz #安装nginx编译安装所需要的的依赖 [root@web01 ~]# yum install -y pcre-devel zlib-devel openssl-devel wget gcc tree vim Nginx依赖于pcre、zlib、openssl,在编译前配置时如果有问题 使用yum方式安装三个包(pcre-devel、zlib-devel、openssl-devel) #进行编译前配置 [root@web01 opt]# cd /opt [root@web01 opt]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module #执行多核编译安装 [root@web01 opt]# make - && make install #启动nginx,提前先关闭防火墙、seLinux [root@web01 opt]# setenforce 0 [root@web01 opt]# systemctl stop firewalld [root@web01 opt]# systemctl disable firewalld #切换到安装目录/usr/local/nginx,查看目录的结构 [root@web01 opt]# cd /usr/local/nginx [root@web01 nginx ]# pwd [root@web01 nginx ]# ls #然后启动Nginx [root@web01 nginx ]# /usr/local/nginx/sbin/nginx #检查Nginx进程是否启动 [root@web01 ~ ]# ps aux | grep nginx root 3949 0.0 0.1 46436 1152 ? Ss 4月30 0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf www 3950 0.0 0.2 46836 2180 ? S 4月30 0:00 nginx: worker process root 6295 0.0 0.0 112676 976 pts/1 S+ 03:00 0:00 grep --color=auto nginx 3查看Nginx使用的端口号 [root@web01 ~]# netstat -tlnp |grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3949/nginx: master #使用本地主机的浏览器访问虚拟机上的Nginx服务器 停止nginx 停止Nginx的三种方式 # 1). 立即停止Nginx服务 [root@web01 ~]# /usr/local/nginx/sbin/nginx -s stop # 2).完成当前任务后停止 [root@web01 ~]# /usr/local/nginx/sbin/nginx -s quit # 3).杀死Nginx进程(两种方式) [root@web01 ~]# killall nginx [root@web01 ~]# pkill nginx #nginx添加环境变量(使用软连接将nginx链接到/usr/local/sbin) [root@web01 ~]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin #建立软连接 [root@web01 ~]# ll /usr/local/sbin/ | grep "nginx" #显示当前环境变量PATH [root@web01 ~]# echo $PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin #编辑.bash_profile文件(添加环境变量) [root@web01 ~]# vim ~/.bash_profile .......... export PATH=$PATH:/usr/local/nginx/sbin ...... #重载引用.bash_profile文件(生效配置文件) [root@web01 ~]# source ~/.bash_profile #常用nginx命令(启动、停止、) # 启动nginx [root@web01 ~]# nginx # 停止nginx [root@web01 ~]# nginx -s stop [root@web01 ~]# nginx -s quit

1|0三、源码安装nginx,自动化安装脚本实现

#!/bin/bash # installation configuration NGINX_VERSION=1.12.2 NGINX_SRC_PATH=/root NGINX_BIN_PATH=/usr/local/nginx # disable firewall systemctl stop firewalld setenforce 0 # installation dependence yum install -y pcre-devel zlib-devel openssl-devel wget gcc # download nginx source package cd ${NGINX_SRC_PATH} wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz # unzip source package tar -xzvf nginx-${NGINX_VERSION}.tar.gz cd ./nginx-${NGINX_VERSION} # install nginx ./configure --prefix=${NGINX_BIN_PATH} --with-http_ssl_module make & make install # start nginx service cd ${NGINX_BIN_PATH}/sbin ./nginx # END

__EOF__

本文作者ଲ小何才露煎煎饺
本文链接https://www.cnblogs.com/zeny/p/15121567.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   ଲ小何才露煎煎饺  阅读(210)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
点击右上角即可分享
微信分享提示