centos7 安装 nginx1.9.2

2024-09-06 00:18
文章标签 安装 centos7 nginx1.9

本文主要是介绍centos7 安装 nginx1.9.2,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一、准备工作:

1、安装必备工具:

$ yum -y install gcc gcc-c++ autoconf automake$ yum -y install zlib zlib-devel openssl openssl-devel pcre-devel


?
说明:

pcre: 用来作地址重写的功能。

zlib:nginx 的gzip模块,传输数据打包,省流量(但消耗资源)。

openssl:提供ssl加密协议。

2、新建一个系统级用户组和匿名用户,以及下面编译时使用

$ sudo groupadd -r nginx$ sudo useradd -s /sbin/nologin -g nginx -r nginx-user


?

二、Nginx编译安装:

1、下载Nginx:http://nginx.org/en/download.html

2、解压编译:

$ tar -zxvf nginx-1.9.2.tar.gz$ cd nginx-1.9.2/


./configure \
--prefix=/etc/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/cache/nginx/client_temp \
--http-proxy-temp-path=/var/cache/nginx/proxy_temp \
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \
--http-scgi-temp-path=/var/cache/nginx/scgi_temp \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-ipv6 \
--with-http_spdy_module \
--with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'


?

上面的参数的作用可以通过--help来查看下文附加1中有提供

./configure --help


?

编译日志:

checking for OS+ Linux 3.10.0-229.4.2.el7.x86_64 x86_64
checking for C compiler ... found+ using GNU C compiler+ gcc version: 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) 
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for O_PATH ... found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for sched_setaffinity() ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for SO_SETFIB ... not found
checking for SO_REUSEPORT ... found
checking for SO_ACCEPTFILTER ... not found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... not found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for eventfd() ... found
checking for int size ... 4 bytes
checking for long size ... 8 bytes
checking for long long size ... 8 bytes
checking for void * size ... 8 bytes
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 8 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 8 bytes
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... not found
checking for POSIX semaphores in libpthread ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for OpenSSL library ... found
checking for zlib library ... found
creating objs/MakefileConfiguration summary+ using system PCRE library+ using system OpenSSL library+ md5: using OpenSSL library+ sha1: using OpenSSL library+ using system zlib librarynginx path prefix: "/usr"nginx binary file: "/usr/sbin/nginx"nginx configuration prefix: "/etc/nginx"nginx configuration file: "/etc/nginx/nginx.conf"nginx pid file: "/var/run/nginx/nginx.pid"nginx error log file: "/var/log/nginx/error.log"nginx http access log file: "/var/log/nginx/http.log"nginx http client request body temporary files: "/var/tmp/nginx/client"nginx http proxy temporary files: "/var/tmp/nginx/proxy"nginx http fastcgi temporary files: "/var/tmp/nginx/fcgi"nginx http uwsgi temporary files: "uwsgi_temp"nginx http scgi temporary files: "scgi_temp"



好像很成功。

3、安装:

make&& make install


?

4、启动:

nginx -c /etc/nginx/nginx.conf
修改配置文件后重新加载,无需重启
nginx -c /etc/nginx/nginx.conf -s reload



?

如果提示缺什么包,直接用yum安装

 yum installxxxxx


?


(1)如果提示:
nginx: [emerg] mkdir() "/var/tmp/nginx/client_temp" failed (2: No such file or directory)
则用管理员去mkdir  /var/tmp/nginx文件夹 后再启动。




(2)在配置nginx 时提示如下错误时:
nginx: [emerg] getpwnam(“www”) failed

解决方案一
在nginx.conf中 把user nobody的注释去掉既可

解决方案二

错误的原因是没有创建www这个用户,应该在服务器系统中添加www用户组和用户www,如下命令:

/usr/sbin/groupadd -f www
/usr/sbin/useradd -g www www


对于nginx的操作,指令比较长,也不便于操作,因此可以使用脚本,教程中转:


CentOS 7 Nginx 控制脚本

附加1:

?
--help                             print this message--prefix=PATH                     setinstallation prefix--sbin-path=PATH                  setnginx binary pathname--conf-path=PATH                  setnginx.conf pathname--error-log-path=PATH             seterror log pathname--pid-path=PATH                   setnginx.pid pathname--lock-path=PATH                  setnginx.lock pathname--user=USER                       setnon-privileged user forworker processes--group=GROUP                     setnon-privileged group forworker processes--build=NAME                      setbuild name--builddir=DIR                    setbuild directory--with-select_module              enableselect module--without-select_module            disable selectmodule--with-poll_module                enablepoll module--without-poll_module              disable poll module--with-threads                    enablethread pool support--with-file-aio                   enablefile AIO support--with-ipv6                       enableIPv6 support--with-http_ssl_module            enablengx_http_ssl_module--with-http_spdy_module           enablengx_http_spdy_module--with-http_realip_module         enablengx_http_realip_module--with-http_addition_module       enablengx_http_addition_module--with-http_xslt_module           enablengx_http_xslt_module--with-http_image_filter_module   enablengx_http_image_filter_module--with-http_geoip_module          enablengx_http_geoip_module--with-http_sub_module            enablengx_http_sub_module--with-http_dav_module            enablengx_http_dav_module--with-http_flv_module            enablengx_http_flv_module--with-http_mp4_module            enablengx_http_mp4_module--with-http_gunzip_module         enablengx_http_gunzip_module--with-http_gzip_static_module    enablengx_http_gzip_static_module--with-http_auth_request_module   enablengx_http_auth_request_module--with-http_random_index_module   enablengx_http_random_index_module--with-http_secure_link_module    enablengx_http_secure_link_module--with-http_degradation_module    enablengx_http_degradation_module--with-http_stub_status_module    enablengx_http_stub_status_module--without-http_charset_module      disable ngx_http_charset_module--without-http_gzip_module         disable ngx_http_gzip_module--without-http_ssi_module          disable ngx_http_ssi_module--without-http_userid_module       disable ngx_http_userid_module--without-http_access_module       disable ngx_http_access_module--without-http_auth_basic_module   disable ngx_http_auth_basic_module--without-http_autoindex_module    disable ngx_http_autoindex_module--without-http_geo_module          disable ngx_http_geo_module--without-http_map_module          disable ngx_http_map_module--without-http_split_clients_module disable ngx_http_split_clients_module--without-http_referer_module      disable ngx_http_referer_module--without-http_rewrite_module      disable ngx_http_rewrite_module--without-http_proxy_module        disable ngx_http_proxy_module--without-http_fastcgi_module      disable ngx_http_fastcgi_module--without-http_uwsgi_module        disable ngx_http_uwsgi_module--without-http_scgi_module         disable ngx_http_scgi_module--without-http_memcached_module    disable ngx_http_memcached_module--without-http_limit_conn_module   disable ngx_http_limit_conn_module--without-http_limit_req_module    disable ngx_http_limit_req_module--without-http_empty_gif_module    disable ngx_http_empty_gif_module--without-http_browser_module      disable ngx_http_browser_module--without-http_upstream_hash_moduledisable ngx_http_upstream_hash_module--without-http_upstream_ip_hash_moduledisable ngx_http_upstream_ip_hash_module--without-http_upstream_least_conn_moduledisable ngx_http_upstream_least_conn_module--without-http_upstream_keepalive_moduledisable ngx_http_upstream_keepalive_module--without-http_upstream_zone_moduledisable ngx_http_upstream_zone_module--with-http_perl_module           enablengx_http_perl_module--with-perl_modules_path=PATH     setPerl modules path--with-perl=PATH                  setperl binary pathname--http-log-path=PATH              sethttp access log pathname--http-client-body-temp-path=PATH setpath to storehttp client request body temporary files--http-proxy-temp-path=PATH       setpath to storehttp proxy temporary files--http-fastcgi-temp-path=PATH     setpath to storehttp fastcgi temporary files--http-uwsgi-temp-path=PATH       setpath to storehttp uwsgi temporary files--http-scgi-temp-path=PATH        setpath to storehttp scgi temporary files--without-http                     disable HTTP server--without-http-cache               disable HTTP cache--with-mail                       enablePOP3/IMAP4/SMTPproxy module--with-mail_ssl_module            enablengx_mail_ssl_module--without-mail_pop3_module         disable ngx_mail_pop3_module--without-mail_imap_module         disable ngx_mail_imap_module--without-mail_smtp_module         disable ngx_mail_smtp_module--with-stream                     enableTCP proxy module--with-stream_ssl_module          enablengx_stream_ssl_module--without-stream_access_module     disable ngx_stream_access_module--without-stream_upstream_hash_moduledisable ngx_stream_upstream_hash_module--without-stream_upstream_least_conn_moduledisable ngx_stream_upstream_least_conn_module--without-stream_upstream_zone_moduledisable ngx_stream_upstream_zone_module--with-google_perftools_module    enablengx_google_perftools_module--with-cpp_test_module            enablengx_cpp_test_module--add-module=PATH                 enablean external module--with-cc=PATH                    setC compiler pathname--with-cpp=PATH                   setC preprocessor pathname--with-cc-opt=OPTIONS             setadditional C compiler options--with-ld-opt=OPTIONS             setadditional linker options--with-cpu-opt=CPU                 build forthe specified CPU, valid values:pentium, pentiumpro, pentium3, pentium4,athlon, opteron, sparc32, sparc64, ppc64--without-pcre                     disable PCRE library usage--with-pcre                        force PCRE library usage--with-pcre=DIR                   setpath to PCRE library sources--with-pcre-opt=OPTIONS           setadditional build options forPCRE--with-pcre-jit                    build PCRE with JIT compilation support--with-md5=DIR                    setpath to md5 library sources--with-md5-opt=OPTIONS            setadditional build options formd5--with-md5-asm                     use md5 assembler sources--with-sha1=DIR                   setpath to sha1 library sources--with-sha1-opt=OPTIONS           setadditional build options forsha1--with-sha1-asm                    use sha1 assembler sources--with-zlib=DIR                   setpath to zlib library sources--with-zlib-opt=OPTIONS           setadditional build options forzlib--with-zlib-asm=CPU                use zlib assembler sources optimizedforthe specified CPU, valid values:pentium, pentiumpro--with-libatomic                   force libatomic_ops library usage--with-libatomic=DIR              setpath to libatomic_ops library sources--with-openssl=DIR                setpath to OpenSSL library sources--with-openssl-opt=OPTIONS        setadditional build options forOpenSSL--with-debug                      enabledebug logging

原文链接 http://my.oschina.net/liucao/blog/470241?fromerr=d9Kj1nub#OSC_h2_1

这篇关于centos7 安装 nginx1.9.2的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1140465

相关文章

Zookeeper安装和配置说明

一、Zookeeper的搭建方式 Zookeeper安装方式有三种,单机模式和集群模式以及伪集群模式。 ■ 单机模式:Zookeeper只运行在一台服务器上,适合测试环境; ■ 伪集群模式:就是在一台物理机上运行多个Zookeeper 实例; ■ 集群模式:Zookeeper运行于一个集群上,适合生产环境,这个计算机集群被称为一个“集合体”(ensemble) Zookeeper通过复制来实现

CentOS7安装配置mysql5.7 tar免安装版

一、CentOS7.4系统自带mariadb # 查看系统自带的Mariadb[root@localhost~]# rpm -qa|grep mariadbmariadb-libs-5.5.44-2.el7.centos.x86_64# 卸载系统自带的Mariadb[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7

Centos7安装Mongodb4

1、下载源码包 curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.1.tgz 2、解压 放到 /usr/local/ 目录下 tar -zxvf mongodb-linux-x86_64-rhel70-4.2.1.tgzmv mongodb-linux-x86_64-rhel70-4.2.1/

Centos7安装JDK1.8保姆版

工欲善其事,必先利其器。这句话同样适用于学习Java编程。在开始Java的学习旅程之前,我们必须首先配置好适合的开发环境。 通过事先准备好这些工具和配置,我们可以避免在学习过程中遇到因环境问题导致的代码异常或错误。一个稳定、高效的开发环境能够让我们更加专注于代码的学习和编写,提升学习效率,减少不必要的困扰和挫折感。因此,在学习Java之初,投入一些时间和精力来配置好开发环境是非常值得的。这将为我

安装nodejs环境

本文介绍了如何通过nvm(NodeVersionManager)安装和管理Node.js及npm的不同版本,包括下载安装脚本、检查版本并安装特定版本的方法。 1、安装nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash 2、查看nvm版本 nvm --version 3、安装

计算机毕业设计 大学志愿填报系统 Java+SpringBoot+Vue 前后端分离 文档报告 代码讲解 安装调试

🍊作者:计算机编程-吉哥 🍊简介:专业从事JavaWeb程序开发,微信小程序开发,定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事,生活就是快乐的。 🍊心愿:点赞 👍 收藏 ⭐评论 📝 🍅 文末获取源码联系 👇🏻 精彩专栏推荐订阅 👇🏻 不然下次找不到哟~Java毕业设计项目~热门选题推荐《1000套》 目录 1.技术选型 2.开发工具 3.功能

SWAP作物生长模型安装教程、数据制备、敏感性分析、气候变化影响、R模型敏感性分析与贝叶斯优化、Fortran源代码分析、气候数据降尺度与变化影响分析

查看原文>>>全流程SWAP农业模型数据制备、敏感性分析及气候变化影响实践技术应用 SWAP模型是由荷兰瓦赫宁根大学开发的先进农作物模型,它综合考虑了土壤-水分-大气以及植被间的相互作用;是一种描述作物生长过程的一种机理性作物生长模型。它不但运用Richard方程,使其能够精确的模拟土壤中水分的运动,而且耦合了WOFOST作物模型使作物的生长描述更为科学。 本文让更多的科研人员和农业工作者

K8S(Kubernetes)开源的容器编排平台安装步骤详解

K8S(Kubernetes)是一个开源的容器编排平台,用于自动化部署、扩展和管理容器化应用程序。以下是K8S容器编排平台的安装步骤、使用方式及特点的概述: 安装步骤: 安装Docker:K8S需要基于Docker来运行容器化应用程序。首先要在所有节点上安装Docker引擎。 安装Kubernetes Master:在集群中选择一台主机作为Master节点,安装K8S的控制平面组件,如AP

衡石分析平台使用手册-单机安装及启动

单机安装及启动​ 本文讲述如何在单机环境下进行 HENGSHI SENSE 安装的操作过程。 在安装前请确认网络环境,如果是隔离环境,无法连接互联网时,请先按照 离线环境安装依赖的指导进行依赖包的安装,然后按照本文的指导继续操作。如果网络环境可以连接互联网,请直接按照本文的指导进行安装。 准备工作​ 请参考安装环境文档准备安装环境。 配置用户与安装目录。 在操作前请检查您是否有 sud

mac安装brew 与 HomeBrew

/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)" curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh >> brew_install BREW_REPO="