您的位置:首页 > 运维架构 > Nginx

nginx安装

2016-05-31 17:44 489 查看
简单介绍:

Nginx 是一个高性能的 Web 和反向代理服务器, 它具有有很多非常优越的特性:

Web 服务器:相比 Apache,Nginx 使用更少的资源,支持更多的并发连接,体现更高的效率,这点使 Nginx 尤其受到虚拟主机提供商的欢迎。能够支持高达 50,000 个并发连接数的响应,感谢 Nginx 为我们选择了 epoll and kqueue 作为开发模型.

负载均衡服务器:Nginx 既可以在内部直接支持 Rails 和 PHP,也可以支持作为 HTTP代理服务器 对外进行服务。Nginx 用 C 编写, 不论是系统资源开销还是 CPU 使用效率都比 Perlbal 要好的多。

邮件代理服务器: Nginx 同时也是一个非常优秀的邮件代理服务器(最早开发这个产品的目的之一也是作为邮件代理服务器),Last.fm 描述了成功并且美妙的使用经验。

Nginx 安装非常的简单,配置文件 非常简洁(还能够支持perl语法),Bugs非常少的服务器

Nginx 启动特别容易,并且几乎可以做到7*24不间断运行,即使运行数个月也不需要重新启动。你还能够在 不间断服务的情况下进行软件版本的升级。

nginx处理动态内容,会把动态内容丢给cgi、fastcgi、apache这样的web服务器,然后把处理结果返回给nginx,nginx再返回给浏览器

1.安装前需要做的准备
#Nginx
yum -y install pcre-devel zlib-devel openssl openssl-devel
系统只安装了基本系统
先创建用于Nginx运行的用户和组: groupadd www useradd -g www www

2.1.安装
# tar zxvf nginx-0.8.54.tar.gz
# cd nginx-0.8.54
# ./configure --prefix=/opt/modules/nginx
# make
# make install

2.2.检查nginx是否安装成功
#cd /opt/modules/nginx/sbin/
#./nginx -t
结果显示:
nginx: the configuration file /opt/modules/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /opt/modules/nginx/conf/nginx.conf test is successful

2.3.启动nginx
#cd /usr/local/nginx/sbin
#./nginx

2.4.检查是否启动成功 客户端ie 浏览器中输入 http://ip(Linux)
2.5 修改配置需重启nginx
#./nginx -s reload

配置成功后:

Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library

nginx path prefix: "/opt/modules/nginx"
nginx binary file: "/opt/modules/nginx/sbin/nginx"
nginx modules path: "/opt/modules/nginx/modules"
nginx configuration prefix: "/opt/modules/nginx/conf"
nginx configuration file: "/opt/modules/nginx/conf/nginx.conf"
nginx pid file: "/opt/modules/nginx/logs/nginx.pid"
nginx error log file: "/opt/modules/nginx/logs/error.log"
nginx http access log file: "/opt/modules/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"

编译:

报错:make[1]: Leaving directory `/opt/modules/src/nginx-1.11.0'

解决办法:好像没事

其中参数: --with-pcre=/usr/local/pcre-8.20 指的是pcre-8.20 的源码路径,并不是安装路径。

安装成功后 /usr/local/webserver/nginx 目录下有四个子目录分别是:conf、html、logs、sbin 。其中 Nginx 的配置文件存放于 conf/nginx.conf,Nginx

只有一个程序文件位于 sbin 目录下的 nginx 文件。确保系统的 80 端口没被其他程序占用,运行 sbin/nginx 命令来启动 Nginx,打开浏览器访问此机器的

IP(地址栏输入:127.0.0.1),如果浏览器出现 Welcome to nginx! 则表示 Nginx 已经安装并运行成功。

安装过程中出现的问题 1.pcre :/configure: error: no acceptable C compiler found in $PATH See `config.log' for more details 原因是没装gcc 解决

办法:yum install gcc

2../configure :checking for C++ compiler default output file name... configure: error: C++ compiler cannot create executables See

`config.log' for more details. 原因是由于c++编译器的相关package没有安装 解决办法:yum install gcc-c++

3.pcre:make时报错:[pcrecpp.lo] Error 1 原因是由于c++编译器的相关package没有安装 解决办法:yum install gcc-c++,重新configure,make && make

install通过。

4../configure: error: the HTTP rewrite module requires the PCRE library 原因是需要PCRE library 解决办法:yum -y install pcre-devel

5../configure: error: the HTTP cache module requires md5 functions from OpenSSL library. You can either disable the module by using --

without-http-cache option, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx

by using --with-http_ssl_module --with-openssl=<path> options. 原因是需要OpenSSL library 解决办法:yum -y install openssl openssl-devel

nginx安装手记:http://www.cnblogs.com/siqi/p/3572695.html

nginx配置文件功能:http://blog.chinaunix.net/uid-11131943-id-3032686.html

Ngnix 安装、信号量、虚拟主机配置:http://www.linuxidc.com/Linux/2015-03/114655.htm
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: