Ubuntu 安装 nginx

Posted schips

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Ubuntu 安装 nginx相关的知识,希望对你有一定的参考价值。

本文永久更新链接地址http://www.linuxidc.com/Linux/2017-09/147157.htm
1、安装依赖项
sudo apt-get update
sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev libssl-dev libxslt1-dev libxml2-dev libgd2-xpm-dev libgeoip-dev libgoogle-perftools-dev libperl-dev libtool libpcrecpp0v5 openssl -y
2、下载新版本
wget http://nginx.org/download/nginx-1.13.5.tar.gz && tar -xf nginx-1.13.5.tar.gz
 
4、编译安装
# 进入解压目录:
cd nginx-1.13.5
# 配置:这里额外安装几个模块
 
./configure --sbin-path=/usr/local/nginx/nginx
--prefix=/usr/local/nginx
--conf-path=/usr/local/nginx/nginx.conf
--pid-path=/usr/local/nginx/nginx.pid
--add-module=../nginx-rtmp-module-master
--with-http_ssl_module
--with-stream --with-mail=dynamic
 
# 编辑安装nginx:
sudo make && sudo make install
# 启动nginx:
sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
#注意:-c 指定配置文件的路径,不加的话,nginx会自动加载默认路径的配置文件,可以通过 -h查看帮助命令。
 
# 查看nginx进程:
ps -ef | grep nginx
 
# 建立软链接(由于/usr/local/bin包含于$PATH当中,这样就不需要额外的设置环境变量了,这意味着可以在其他路径下直接运行nginx命令)
sudo ln -s /opt/dotnet/dotnet /usr/local/bin #(创建链接)
 编译选项说明:
 
--prefix=path 如果在编译的不指定安装位置,那么默认的位置/usr/local/nginx目录
--sbin-path=path 设置nginx执行脚本的位置,这里如果设置在path变量里面,就可以在bash环境下,任意使用nginx命令,默认位置prefix/sbin/nginx  注意这里的prefix是在配置文件里面配置的路径
--conf-path=path 配置nginx配置文件的路径,如果不指定这个选项,那么配置文件的默认路径就会是 prefix/conf/nginx.conf
--pid-path =path 配置nginx.pid file的路径,一般来说,进程在运行的时候的时候有一个进程id,这个id会保存在pid file里面,默认的pid file的放置位置是prefix/logs/nginx.pid
--error-log-path=path 设置错误日志的存放路径,如果不指定,就默认 prefix/logs/error.log
--http-log-path= path 设置http访问日志的路径,如果不指定,就默认 prefix/logs/access.log
--user=name 设置默认启动进程的用户,如果不指定,就默认 nobody
--group=name 设置这个用户所在的用户组,如果不指定,依然是nobody
--with-http_ssl_module 开启HTTP SSL模块,使NGINX可以支持HTTPS请求。需要安装了OPENSSL
--with-http_flv_module
--with-http_stub_status_module 启用 "server status" 页
--without-http_gzip_module 禁用 ngx_http_gzip_module. 如果启用,需要 zlib
--without-http_ssi_module 禁用 ngx_http_ssi_module
--without-http_referer_module 禁用 ngx_http_referer_module
--without-http_rewrite_module 禁用 ngx_http_rewrite_module. 如果启用需要 PCRE 。
--without-http_proxy_module 禁用 ngx_http_proxy_module
--without-http_fastcgi_module 禁用 ngx_http_fastcgi_module
--without-http_memcached_module 禁用 ngx_http_memcached_module
--without-http_browser_module 禁用 ngx_http_browser_module
--http-proxy-temp-path=PATH 设置路径到the http proxy temporary files
--http-fastcgi-temp-path=PATH 设置路径到Set path to the http fastcgi temporary files
--without-http 禁用 HTTP server
--with-mail 启用 IMAP4/POP3/SMTP 代理模块
--with-mail_ssl_module 启用ngx_mail_ssl_module
--with-openssl=DIR 设置路径到OpenSSL library sources
--with-stream 用来实现四层协议的转发、代理或者负载均衡等
 

 

以上是关于Ubuntu 安装 nginx的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu安装Nginx

Ubuntu安装Nginx

Ubuntu18.04系统安装nginx

ubuntu安装Nginx

ubuntu16下安装Nginx+php+phpMyAdmin全纪录!

ubuntu下安装nginx -php