ubantu16.04安装 nginx
来源:互联网 发布:育知同创学费 编辑:程序博客网 时间:2024/06/07 00:48
Nginx (“engine x”) 是一个高性能的 HTTP 和 反向代理 服务器,也是一个 IMAP/POP3/SMTP 代理服务器。 Nginx 是由 Igor Sysoev 为俄罗斯访问量第二的 Rambler.ru 站点开发的,第一个公开版本0.1.0发布于2004年10月4日。其将源代码以类BSD许可证的形式发布,因它的稳定性、丰富的功能集、示例配置文件和低系统资源的消耗而闻名。
安装Nginx依赖库
安装gcc g++的依赖库
ubuntu平台可以使用如下命令。
apt-get install build-essential
apt-get install libtool
centeros平台可以使用如下命令。
安装make:
yum -y install gcc automake autoconf libtool make安装g++:
yum install gcc gcc-c++
安装 pcre依赖库(http://www.pcre.org/)
sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
安装 zlib依赖库(http://www.zlib.net)
apt-get install zlib1g-dev
安装 ssl依赖库
apt-get install openssl
安装Nginx(http://nginx.org)
#下载最新版本:wget http://nginx.org/download/nginx-1.11.3.tar.gz#解压:tar -zxvf nginx-1.11.3.tar.gz#进入解压目录:cd nginx-1.11.3#配置:./configure --prefix=/usr/local/nginx #编辑nginx:make注意:这里可能会报错,提示“pcre.h No such file or directory”,具> 体详见:http://stackoverflow.com/questions/22555561/error-> > building-fatal-error-pcre-h-no-such-file-or-directory需要安装 libpcre3-dev,命令为:sudo apt-get install libpcre3-dev#安装nginx:sudo make install#启动nginx:sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf注意:-c 指定配置文件的路径,不加的话,nginx会自动加载默认路径的配置文件,可以通过 -h查看帮助命令。#查看nginx进程:ps -e | grep nginx
Nginx常用命令
启动 Nginx
/usr/local/nginx/sbin/nginx./sbin/nginx
停止 Nginx
./sbin/nginx -s stop./sbin/nginx -s quit
-s都是采用向 Nginx 发送信号的方式。
Nginx重新加载配置
./sbin/nginx -s reload
指定配置文件
./sbin/nginx -c /usr/local/nginx/conf/nginx.conf
-c表示configuration,指定配置文件
查看 Nginx 版本
有两种可以查看 Nginx 的版本信息的参数。第一种如下:
./sbin/nginx -vnginx: nginx version: nginx/1.0.0
另一种显示的是详细的版本信息:
root@zyt:/usr/local/nginx$ ./sbin/nginx -Vnginx: nginx version: nginx/1.0.0nginx: built by gcc 4.3.3 (Ubuntu 4.3.3-5ubuntu4)nginx: TLS SNI support enablednginx: configure arguments: --with-http_ssl_module --with-openssl=/home/luming/openssl-1.0.0d/
检查配置文件是否正确
poechant@ubuntu:/usr/local/nginx$ ./sbin/nginx -tnginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (13: Permission denied)nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok2012/01/09 16:45:09 [emerg] 23898#0: open() "/usr/local/nginx/logs/nginx.pid" failed (13: Permission denied)nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
如果出现如上的提示信息,表示没有访问错误日志文件和进程,可以sudo(super user do)一下:
poerchant@ubuntu:/usr/local/nginx$ sudo ./sbin/nginx -tnginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is oknginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
如果显示如上,则表示配置文件正确。否则,会有相关提示。
显示帮助信息
poechant@ubuntu:/user/local/nginx$ ./sbin/nginx -h
或者:
poechant@ubuntu:/user/local/nginx$ ./sbin/nginx -?
阅读全文
1 0
- ubantu16.04安装 nginx
- Ubantu16.04安装Qt5.4.0
- ubantu16.04安装卸载nodejs
- ubantu16.04+caffe下的matcaffe安装
- win10下安装ubantu16.04LTS注意事项
- win10下安装ubantu16.04LTS注意事项
- ubantu16.04下源码编译安装tensorflow
- ubantu16.04安装英伟达显卡驱动
- ubantu16.04下安装codeblocks(2分钟安装)
- ubantu16.04在Firefox上安装Adobe Flash Player
- ubantu16.04安装tensorflow(GPU)+cuda8.0+cudnn6.0
- 记VirtualBox下安装Ubantu16.04配置联网
- win10安装ubantu16.04遇到的一些问题
- win8 下安装 ubantu16.04(双系统)+ ubantu无线上网
- 笔记本双显卡Ubantu16.04 Nvidia驱动安装指导
- ubantu16.04 配置samba
- Ubantu16.04配置Matcaffe
- Ubantu16.04配置Matconvnet
- spring-batch预研篇
- 回顾大一·C语言编程4.3(2)
- 原来Hadoop也是无心下的产物
- 【数据库范式详解】1NF-BCNF
- 程序在点击返回按钮是弹出AlertDialog
- ubantu16.04安装 nginx
- 九月 29, 2017 10:38:30 上午 org.apache.catalina.loader.WebappClassLoader loadClass 信息: Illegal access: t
- Angular最新教程-第十一节 路由四 (嵌套路由)
- ActiveMq+Zookeeper的高可用集群环境搭建
- iOS 二维码的扫描使用,以及图片预览,类似于相册
- cocos2dx Lua 定时器
- 项目报错“JavaServer Faces 2.2 can not be installed : One or more constraints”等一系列问题
- 简洁风格的Tab
- php连接oracle类 分页查询和乱码问题