nginx安装

来源:互联网 发布:微星显卡保修几年 淘宝 编辑:程序博客网 时间:2024/05/01 20:27

通过yum安装

安装yum源

# Centos6 yum源rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm# Centos7 yum源rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

如果其他版本的官方源修改url即可,复制nginx的yum源安装包地址,替换上面命令的URL地址即可安装,如图

enter description here

手动配置yum源

vim /etc/yum.repos.d/nginx.repo  # 写入以下内容[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/6/$basearch/gpgcheck=0enabled=1

编译安装

安装所包

# Centos# 安装编译工具gccyum groupinstall "Development Tools" yum groupinstall "开发工具"     # 若为中文yum install pcre pcre-devel# 要Perl兼容的正则表达式(PCRE)库来编译Nginx。 Nginx的Rewrite和HTTP核心模块使用PCRE作为其正则表达式的语法,# 需要两个包pcre和pcre-devel,第一个包提供了编译版本的库,而第二个包提供了开发头文件和源文件来编译项目。yum install zlib zlib-devel# zlib库为开发人员提供了压缩算法。在Nginx的各个模块中使用的gzip压缩功能需要zlib库。 yum install openssl openssl-devel# Nginx使用OpenSSL库来提供ssl连接。因此,我们需要安装openssl库及其开发包。
# ubuntu所需包一样,包名有所区别apt-get install build-essentials  zlib1g zlib1g-dev openssl openssl-dev

nginx软件包官方下载

# 最好去官方下载最新版本,知道你们懒。。。wget http://nginx.org/download/nginx-1.12.1.tar.gz

解压编译安装

tar -zxf nginx-1.12.1.tar.gzcd nginx-1.12.1./configuremake && make install  

编译参数说明

--prefix #nginx安装目录,默认在/usr/local/nginx--pid-path #pid问件位置,默认在logs目录--lock-path #lock问件位置,默认在logs目录--with-http_ssl_module #开启HTTP SSL模块,以支持HTTPS请求。--with-http_dav_module #开启WebDAV扩展动作模块,可为文件和目录指定权限--with-http_flv_module #支持对FLV文件的拖动播放--with-http_realip_module #支持显示真实来源IP地址--with-http_gzip_static_module #预压缩文件传前检查,防止文件被重复压缩--with-http_stub_status_module #取得一些nginx的运行状态--with-mail #允许POP3/IMAP4/SMTP代理模块--with-mail_ssl_module #允许POP3/IMAP/SMTP可以使用SSL/TLS--with-pcre=../pcre-8.11 #注意是未安装的pcre路径--with-zlib=../zlib-1.2.5 #注意是未安装的zlib路径--with-debug #允许调试日志--http-client-body-temp-path #客户端请求临时文件路径--http-proxy-temp-path #设置http proxy临时文件路径--http-fastcgi-temp-path #设置http fastcgi临时文件路径--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi #设置uwsgi 临时文件路径--http-scgi-temp-path=/var/tmp/nginx/scgi #设置scgi 临时文件路径

附录

默认安装选项

without-http_charset_module–without-http_gzip_module–without-http_ssi_module–without-http_userid_module–without-http_access_module–without-http_access_module–without-http_autoindex_module–without-http_geo_module–without-http_map_module–without-http_referer_module–without-http_rewrite_module–without-http_proxy_module–without-http_fastcgi_module–without-http_uwsgi_module–without-http_scgi_module–without-http_memcached_module–without-http_limit_conn_module–without-http_limit_req_module–without-http_empty_gif_module–without-http_browser_module–without-http_upstream_ip_hash_module–without-http_upstream_least_conn_module–without-http_split_clients_module

默认禁用选项

with-http_ssl_modulewith-http_realip_modulewith-http_addition_modulewith-http_xslt_modulewith-http_image_filter_modulewith-http_geoip_modulewith-http_sub_modulewith-http_dav_modulewith-http_flv_modulewith-http_mp4_modulewith-http_gzip_static_modulewith-http_random_index_modulewith-http_secure_link_modulewith-http_stub_status_modulewith-google_perftools_modulewith-http_degradation_modulewith-http_perl_modulewith-http_spdy_modulewith-http_gunzip_modulewith-http_auth_request_module
原创粉丝点击