linux安装nginx
来自: http://my.oschina.net/u/2246410/blog/617586
linux安装nginx
1、介绍
nginx [engine x] is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP proxy server, originally written by Igor Sysoev. For a long time, it has been running on many heavily loaded Russian sites including Yandex, Mail.Ru, VK, and Rambler. According to Netcraft, nginx served or proxied 24.33% busiest sites in January 2016. Here are some of the success stories: Netflix, Wordpress.com, FastMail.FM.
NGINX(engine x)是一个http和反向代理服务器,也是一个邮件代理服务器和一个TCP代理服务器。他是由Igor Sysoev原创并开源。诞生以来,已经在一个俄罗斯的很多高访问量网站使用,例如:Yandex,Mail.rU,VK和Rambler。2016年一月统计显示,在广播领域,NGINX已经有24.33%的占有率,包括很多成功的音乐商店:Netflix,Wordpress.com,FastMail.FM.
2、安装
a)安装依赖
#有些系统自带了pcre,openssl,zlib 1.检测 pcre (用于nginx的核心和重写模块,而且支持正则表达式) :rpm -ql pcre ( 如果没有就下载安装: : wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz $ tar -zxf pcre-8.37.tar.gz $ cd pcre-8.37$ $./configure $ make $ sudo make install ) 2.检测 zlib (nginx的 GZIP模块,也就是页面压缩模块需要) # rpm -ql zlib ( 如果没有: $ wget http://zlib.net/zlib-1.2.8.tar.gz $ tar -zxf zlib-1.2.8.tar.gz $ cd zlib-1.2.8 $ ./configure $ make$ sudo make install ) 3. 检测 openssl (ssl模块,现在都追求全网ssl) #:rpm -ql openssl ( 安装: $ wget http://www.openssl.org/source/openssl-1.0.2d.tar.gz $ tar -zxf openssl-1.0.2d.tar.gz $ cd openssl-1.0.2d $ ./Configure darwin64-x86_64-cc --prefix=/usr $ make$ sudo make install )
b)配置安装环境(二进制安装)
: wget http://nginx.org/download/nginx-1.8.1.tar.gz :tar -zxvf nginx-1.8.1.tar.gz :cd nginx-1.8.1/ :配置: $:./configure --with-openssl=/usr/bin/openssl
nginx path prefix: "/usr/local/nginx" <nginx的安装目录> nginx binary file: "/usr/local/nginx/sbin/nginx" <nginx的启动文件> nginx configuration prefix: "/usr/local/nginx/conf" <nginx的配置文件存放文件夹> nginx configuration file: "/usr/local/nginx/conf/nginx.conf" <nginx的配置文件> nginx pid file: "/usr/local/nginx/logs/nginx.pid" <nginx的运行时的Pid文件> nginx error log file: "/usr/local/nginx/logs/error.log" <nginx的错误日志文件> nginx http access log file: "/usr/local/nginx/logs/access.log" <nginx的访问日志文件> nginx http client request body temporary files: "client_body_temp" <访问的request体临时文件> nginx dso module path: "/usr/local/nginx/modules/" <nginx的模块文件目录> nginx http proxy temporary files: "proxy_temp" <nginx的启动代理模块文件> nginx http fastcgi temporary files: "fastcgi_temp" <nginx的fastcgi模块文件> nginx http uwsgi temporary files: "uwsgi_temp" <nginx的uwsig模块临时文件> nginx http scgi temporary files: "scgi_temp" <nginx的scgi模块临时文件> 安装 $ make $ make install 开启 $ cd nginx $ sbin/nginx ######## 操作命令 ################# $ nginx -s stop --快速关闭 $ nginx -s quit --安全关闭 $ nginx -s reload --重新加载,包括配置文件 $ nginx -s reopen --重启日志文件 $ kill -s QUIT nginx.pid
3、测试
打开浏览器:输入localshot:80
4、configure的配置
--prefix=path defines a directory that will keep NGINX files. The directory will be also used for all relative paths set by the ./configure script (excluding paths to libraries) and for the path to the nginx.conf configuration file. By default the path is set to /usr/local/nginx. 定义保存NGINX的文件夹。这个文件夹将用来在./configure脚本和nginx.cnf中使用。 默认的是 /usr/local/nginx --sbin-path=path sets the name of NGINX executable file. This name is used only during installation. By default the file is named to prefix/sbin/nginx. NGINX的启动文件存放位置,只有在Make install时使用。 默认:prefix/sbin/nginx --conf-path=path sets the name of the NGINX configuration file. By default the file is named prefix/conf/nginx.conf. Note that regardless of this option you can always start NGINX with a different configuration file by specifying it with the -c option in command-line. 设置NGINX的配置文件存放位置。 默认是 prefix/conf/nginx.conf 注意也可以不用关系这个值,因为NGINX可以使用不同的配置来启动:nginx -c xxx/nginx.conf --pid-path=path sets the name of the nginx.pid file that stores the process ID of the main process. After installation, the path to the file name can always be changed in the nginx.conf configuration file using the pid directive. By default the file is named prefix/logs/nginx.pid . 设置 nginx.pid 的文件夹,nginx.pid用来存放 主程序的PID。 安装后,也可以通过 nginx.conf 来配置新的文件存放地址。 默认:prefix/logs/nginx.pid --error-log-path=path sets the name of the primary error, warnings, and diagnostic file. After installation, the file name can always be changed in the nginx.conf configuration file using the error_log directive. By default the file is named prefix/logs/error.log. 主要错误日志文件夹。可以通过nginx.conf的 error_log 来修改。 默认:prefix/logs/error.log --http-log-path=path sets the name of the primary request log file of the HTTP server. After installation, the file name can always be changed in the nginx.conf configuration file using the access_log directive. By default the file is named prefix/logs/access.log. 设置主要的访问日志,可以通过nginx.conf的 access_log 来修改 默认:prefix/logs/access.log --user=name sets the name of an unprivileged user whose credentials will be used by NGINX worker processes. After installation, the name can be changed in the nginx.conf configuration file using the user directive. The default user name is nobody. 设置 worker 线程的 授权用户。 可以通过nginx.conf的user来修改。 默认是nobody --group=name sets the name of a group whose credentials will be used by NGINX worker processes. After installation, the name can always be changed in the nginx.conf configuration file using the user directive. By default, a group name is set to the name of an unprivileged user. 设置 worker 线程的 授权用户组。 可以通过nginx.conf的user来修改。 默认是不授权的一组。 --with-pcre=path sets the path to the sources of the PCRE library. The library is required for regular expressions support in the location directive and for the ngx_http_rewrite_module module. 设置pcre库地址(就是安装地址),用于ngx_http_rewrite_module模块、正则表达使用 --with-pcre-jit builds the PCRE library with “just-in-time compilation” support (the pcre_jit directive). 创建PCRE的运行时编译支持,pcre_jit的文件地址 --with-zlib=path sets the path to the sources of the zlib library. The library is required for the ngx_http_gzip_module module. 设置zlib的库地址,用户ngx_http_gzip_module模块(压缩模块)
本文由用户 Mel6545 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
转载本站原创文章,请注明出处,并保留原始链接、图片水印。
本站是一个以用户分享为主的开源技术平台,欢迎各类分享!