博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
nginx 安装在ubuntu上
阅读量:6942 次
发布时间:2019-06-27

本文共 1868 字,大约阅读时间需要 6 分钟。

hot3.png

Nginx是一个高性能的HTTP和反向代理服务器.

Nginx 使用 Unix 下常用的 './configure && make && make install' 过程来编译安装.

configure 确定系统所具有一些特性,特别是 nginx 用来处理连接的方法。然后,它创建 Makefile 文件。

官网:

下载页面:
1、模块依赖性
gzip 模块需要 zlib 库
rewrite 模块需要 pcre 库
ssl 功能需要 openssl 库
预先编译好的安装包
sudo apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev

 

2、nginx的准备工作

下载nginx-1.2.6.tar.gz包到你指定的目录下后,解压:
tar zxvf nginx-1.2.6.tar.gz
解压后在当前目录下会生成一个nginx-1.2.6的目录
进入解压后的目录,运行configure命令,
 ./configure --prefix=/usr/local/nginx
这时会报出一个如下错误:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.
这是因为没有PCRE library的原因所致,通过下面的命令安装相关的lib即可解决

3、PCRE库的安装:
官网:
下载页面:
选择最新版本下载:
1)解压:
tar –zxvf pcre-8.10.tar.gz
解压目录为:pcre-8.10
然后进入到 cd pcre-8.10,进行配置、编译、安装
2)配置
./configure --prefix=/usr/local/pcre
3)编译pcre
make
make pcre时会出错
libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] Error 1
make[1]: Leaving directory `/home/mfcai/pcre-8.10'
make: *** [all] Error 2
安装build-essential
apt-get install build-essential
4)安装pcre
make install

4、nginx的安装

1)配置
./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/pcre/
注意:此处而不是安装的路径,应该是pcre源文件的路径
正确的命令是:
./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/src/pcre-8.10
2)编译
make
3)安装
make install

 

Nginx会被安装在/usr/local/nginx目录下(也可以使用参数--prefix=指定自己需要的位置),

安装成功后 /usr/local/nginx 目录下有四个子目录分别是:conf、html、logs、sbin 。
其中 Nginx 的配置文件存放于 conf/nginx.conf,
bin文件是位于 sbin 目录下的 nginx 文件。
确保系统的 80 端口没被其他程序占用,运行 sbin/nginx 命令来启动 Nginx,
打开浏览器访问此机器的 IP,如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功

 

转载于:https://my.oschina.net/floristgao/blog/359804

你可能感兴趣的文章
vue资源精选-前端组件库资源-前端选型
查看>>
HTML5学习之路——HTML 5 应用程序缓存
查看>>
关于JQ 查找不到对象的clientHeight,
查看>>
linux top监控的使用
查看>>
Cesium官方教程8-- 几何体和外观效果
查看>>
管理现有数据库-web系统
查看>>
全局变量:global与$GLOBALS的区别和使用
查看>>
无缝滚动
查看>>
HDU 17新生赛 身份证验证【模拟】
查看>>
HDU 1060 Leftmost Digit【log10/求N^N的最高位数字是多少】
查看>>
注定与众不同
查看>>
ios arc __strong与__weak的一个小实例
查看>>
uC/OS-II应用程序代码
查看>>
JVM(四)垃圾收集器_分代收集器
查看>>
每日例会
查看>>
根据图片路径生成二进制流,下载图片
查看>>
解决Linux下启动Tomcat遇到Neither the JAVA_HOME nor the JRE_HOME environment variable is defined...
查看>>
C#在Json反序列化中处理键的特殊字符
查看>>
Eclipse for Java EE软件操作集锦(一)
查看>>
文本分类之六分类结果评估
查看>>