【服务器环境搭建-Centos】Nginx1.9.9 安装(编译源码)
nginx官网不同版本下载地址:http://nginx.org/download/
我使用的是nginx-1.9.8.tar.gz
- 安装其他支持软件
- 可以使用rpm –q xxx 查询库是否已经安装成功
- gcc、make工具
- rewrite 模块需要 pcre 库 ( 下载: http://www.pcre.org/ )
- gzip 模块需要 zlib 库 ( 下载: http://www.zlib.net/ )
- ssl 功能需要 openssl 库 ( 下载: http://www.openssl.org/ )
-
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
- 支持Rewrite(但是我没有装这个)
PCRE 作用是让 Ngnix 支持 Rewrite 功能。
使用yum源安装: yum -y install pcre*
或使用wget方式安装
1,下载 PCRE 安装包 [root@bogon src]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz 2、解压安装包: [root@bogon src]# tar zxvf pcre-8.35.tar.gz 3、进入安装包目录 [root@bogon src]# cd pcre-8.35 4、编译安装 [root@bogon pcre-8.35]# ./configure [root@bogon pcre-8.35]# make && make install 5、查看pcre版本 [root@bogon pcre-8.35]# pcre-config --version - 源码安装nginx1.9.9
- 切换到root目录下
- 下载:wget http://nginx.org/download/nginx-1.9.8.tar.gz
- 解压缩 tar -zxvf nginx-1.9.8.tar.gz
- 编译安装
- cd nginx-1.9.9
- ./configure --prefix=/usr/local/nginx --with-http_stub_status_module
这里也可以添加其他模块,例如:rewrit模块(--with-pcre) --prefix指定安装的目录
--with-http_stub_status_module启用状态统计 - 如果是使用wget方式则configure时,需要指定pcre
123./configure --prefix=/usr/local/nginx \
--with-http_ssl_module --with-http_spdy_module \
--with-http_stub_status_module --with-pcre
- make && make install
- 检测配置或安装是否成功:/usr/local/nginx/sbin/nginx -t
如果出现下列信息,则标识安装或配置成功
the configuration file /usr/local/nginx/conf/nginx.conf syntax is o
the configuration file /usr/local/nginx/conf/nginx.conf was tested successfully
- 启动,停止nginx服务
12
#/usr/local/nginx/sbin/nginx
#/usr/local/nginx/sbin/nginx -s stop
- nginx启动好后启动tomcat,此时输入http://主机ip地址即可看到“My web!”
- 在/etc/profile 添加nginx的path全局环境变量,则可以直接使用nginx命令
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人