Nginx的安装-Linux
下载地址
#如果没有gcc环境,需要安装gcc:
[root@localhost local]# yum install gcc-c++ -y
#安装依赖包
[root@localhost local]# yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
# 进入文件夹
[root@localhost local]# cd /usr/local
#在线下载或者上传已下载安装包
[root@localhost local]# wget http://nginx.org/download/nginx-1.22.1.tar.gz
#解压安装包
[root@localhost local]# tar -xvf nginx-1.22.1.tar.gz
#解压之后不需要重新命名直接进去解压目录
#进入nginx-1.22.1目录
[root@localhost local]# cd /usr/local/nginx-1.22.1
#执行配置命令
#↓↓↓↓参数说明↓↓↓↓
#prefix= 指向安装目录(编译安装)
#conf-path= 指向配置文件(nginx.conf)
#error-log-path= 指向错误日志目录
#pid-path= 指向pid文件(nginx.pid)
#http-log-path= 设定access log路径
#with-http_gzip_static_module 启用ngx_http_gzip_static_module支持(在线实时压缩输出数据流)
#with-http_stub_status_module 启用ngx_http_stub_status_module支持(获取nginx自上次启动以来的工作状态)
#with-http_ssl_module 启用ngx_http_ssl_module支持(使支持https请求,需已安装openssl)
[root@localhost nginx-1.22.1]# ./configure --prefix=/nginx \
--conf-path=/nginx/conf/nginx.conf \
--error-log-path=/nginx/logs/error.log \
--pid-path=/nginx/logs/nginx.pid \
--http-log-path=/nginx/logs/access.log \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-stream \
--with-stream_ssl_preread_module
#执行make命令
[root@localhost nginx-1.22.1]# make
#执行make install命令
[root@localhost nginx-1.22.1]# make install
#切换到sbin目录
[root@localhost nginx-1.22.1]# cd /usr/local/nginx/sbin
#启动验证
[root@localhost sbin]# ./nginx
#查看nginx进程,存在下面记录,说明启动成功
[root@localhost sbin]# ps -ef | grep nginx
root 34692 1 0 20:16 ? 00:00:00 nginx: master process ./nginx
#指定配置启动
[root@localhost sbin]# ./nginx -c /usr/local/nginx/conf/nginx.conf
#编辑配置文件/usr/local/nginx/conf/nginx.conf
#也可以通过工具下载到本地进行编辑后上传
[root@localhost sbin]# vi /usr/local/nginx/conf/nginx.conf
#指定配置重启
[root@localhost sbin]# ./nginx -s reload -c /usr/local/nginx/conf/nginx.conf
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了