nginx1.9.7安装

  • Post author:
  • Post category:其他


介绍

官网:http://www.nginx.org/


Nginx是一个很强大的高性能Web和反向代理服务器

,它具有很多非常优越的特性,在连接高并发的情况下,Nginx是Apache服务器不错的替代品:Nginx在反向代理上是经常被选择的软件之一,能够支持高达50,000个并发连接数的响应。


安装


依赖安装


[root@k8smaster yum.repos.d]#

yum -y install gcc-c++  #编译使用


[root@k8smaster yum.repos.d]#

yum install -y pcre pcre-devel #rewrite模块需要pcre库


[root@k8smaster yum.repos.d]#

yum -y install zlib-devel #nginx gzip模块需要zlib库


[root@k8smaster yum.repos.d]#

wget https://www.openssl.org/source/openssl-1.0.2h.tar.gz  #ssl模块需要openssl库

root@k8smaster nginx]#

wget http://nginx.org/download/nginx-1.9.7.tar.gz #下载nginx软件包

[root@k8smaster nginx]#

tar -xvf nginx-1.9.7.tar.gz  #解压nginx软件包


[root@k8smaster nginx]#

tar -xvf openssl-1.0.2h.tar.gz   #解压openssl,不需要安装


[root@k8smaster nginx]#

ls -lrt


total 6024

drwxr-xr-x  8 1001 1001     147 Nov 17  2015 nginx-1.9.7

-rw-r–r–  1 root root  885562 Nov 17  2015 nginx-1.9.7.tar.gz

-rw-r–r–  1 root root 5274412 May  3  2016 openssl-1.0.2h.tar.gz

drwxr-xr-x 20 root root    4096 Feb 13 00:59 openssl-1.0.2h

[root@k8smaster nginx]#


安装nginx


[root@k8smaster nginx-1.9.7]#


./configure  –prefix=/data/nginxinstall –with-openssl=/data/nginx/openssl-1.0.2h –without-http_rewrite_module –with-http_stub_status_module –with-http_ssl_module –with-http_realip_module  –with-stream_ssl_module  –with-http_gzip_static_module –with-stream



checking for OS


#如果想要安装openssl模块,安装时需指定 ./configure  –prefix=/data/nginxinstall –with-openssl=/data/nginx/openssl-1.0.2h



+ Linux 3.10.0-123.el7.x86_64 x86_64

checking for C compiler … found

+ using GNU C compiler

+ gcc version: 4.8.5 20150623 (Red Hat 4.8.5-39) (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 nobody group … 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 … 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 zlib library … found

creating objs/Makefile

Configuration summary

+ PCRE library is not used

+ using OpenSSL library: /data/nginx/openssl-1.0.2h

+ md5: using OpenSSL library

+ sha1: using OpenSSL library

+ using system zlib library

nginx path prefix: “/data/nginxinstall”

nginx binary file: “/data/nginxinstall/sbin/nginx”

nginx configuration prefix: “/data/nginxinstall/conf”

nginx configuration file: “/data/nginxinstall/conf/nginx.conf”

nginx pid file: “/data/nginxinstall/logs/nginx.pid”

nginx error log file: “/data/nginxinstall/logs/error.log”

nginx http access log file: “/data/nginxinstall/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”

[root@k8smaster nginx-1.9.7]#

[root@k8smaster nginx-1.9.7]#


make



-lpthread -lcrypt /data/nginx/openssl-1.0.2h/.openssl/lib/libssl.a /data/nginx/openssl-1.0.2h/.openssl/lib/libcrypto.a -ldl -lz

make[1]: Leaving directory `/data/nginx/nginx-1.9.7′

make -f objs/Makefile manpage

make[1]: Entering directory `/data/nginx/nginx-1.9.7′

sed -e “s|%%PREFIX%%|/data/nginxinstall|” \

-e “s|%%PID_PATH%%|/data/nginxinstall/logs/nginx.pid|” \

-e “s|%%CONF_PATH%%|/data/nginxinstall/conf/nginx.conf|” \

-e “s|%%ERROR_LOG_PATH%%|/data/nginxinstall/logs/error.log|” \

< man/nginx.8 > objs/nginx.8

make[1]: Leaving directory `/data/nginx/nginx-1.9.7′

[root@k8smaster nginx-1.9.7]#

[root@k8smaster nginx-1.9.7]#


make install



make -f objs/Makefile install

make[1]: Entering directory `/data/nginx/nginx-1.9.7′

test -d ‘/data/nginxinstall’ || mkdir -p ‘/data/nginxinstall’

test -d ‘/data/nginxinstall/sbin’         || mkdir -p ‘/data/nginxinstall/sbin’

test ! -f ‘/data/nginxinstall/sbin/nginx’         || mv ‘/data/nginxinstall/sbin/nginx’             ‘/data/nginxinstall/sbin/nginx.old’

cp objs/nginx ‘/data/nginxinstall/sbin/nginx’

test -d ‘/data/nginxinstall/conf’         || mkdir -p ‘/data/nginxinstall/conf’

cp conf/koi-win ‘/data/nginxinstall/conf’

cp conf/koi-utf ‘/data/nginxinstall/conf’

cp conf/win-utf ‘/data/nginxinstall/conf’

test -f ‘/data/nginxinstall/conf/mime.types’         || cp conf/mime.types ‘/data/nginxinstall/conf’

cp conf/mime.types ‘/data/nginxinstall/conf/mime.types.default’

test -f ‘/data/nginxinstall/conf/fastcgi_params’         || cp conf/fastcgi_params ‘/data/nginxinstall/conf’

cp conf/fastcgi_params         ‘/data/nginxinstall/conf/fastcgi_params.default’

test -f ‘/data/nginxinstall/conf/fastcgi.conf’         || cp conf/fastcgi.conf ‘/data/nginxinstall/conf’

cp conf/fastcgi.conf ‘/data/nginxinstall/conf/fastcgi.conf.default’

test -f ‘/data/nginxinstall/conf/uwsgi_params’         || cp conf/uwsgi_params ‘/data/nginxinstall/conf’

cp conf/uwsgi_params         ‘/data/nginxinstall/conf/uwsgi_params.default’

test -f ‘/data/nginxinstall/conf/scgi_params’         || cp conf/scgi_params ‘/data/nginxinstall/conf’

cp conf/scgi_params         ‘/data/nginxinstall/conf/scgi_params.default’

test -f ‘/data/nginxinstall/conf/nginx.conf’         || cp conf/nginx.conf ‘/data/nginxinstall/conf/nginx.conf’

cp conf/nginx.conf ‘/data/nginxinstall/conf/nginx.conf.default’

test -d ‘/data/nginxinstall/logs’         || mkdir -p ‘/data/nginxinstall/logs’

test -d ‘/data/nginxinstall/logs’ ||         mkdir -p ‘/data/nginxinstall/logs’

test -d ‘/data/nginxinstall/html’         || cp -R html ‘/data/nginxinstall’

test -d ‘/data/nginxinstall/logs’ ||         mkdir -p ‘/data/nginxinstall/logs’

make[1]: Leaving directory `/data/nginx/nginx-1.9.7′

[root@k8smaster nginx-1.9.7]#

[root@k8smaster conf]#

more nginx.conf  #查看配置文件

worker_processes  1;

events {


worker_connections  1024;

}

http {


include       mime.types;

default_type  application/octet-stream;

sendfile        on;

keepalive_timeout  65;

server {


listen       80;

server_name  localhost;

location / {


root   html;

index  index.html index.htm;

}

error_page   500 502 503 504  /50x.html;

location = /50x.html {


root   html;

}

}

}


[root@k8smaster conf]#

[root@k8smaster sbin]#

./nginx -t  #检查配置文件


nginx: the configuration file /data/nginxinstall/conf/nginx.conf syntax is ok

nginx: configuration file /data/nginxinstall/conf/nginx.conf test is successful

[root@k8smaster sbin]#

./nginx -t -c /data/nginxinstall/conf/nginx.conf  #检查配置文件,-c指定配置文件


nginx: the configuration file /data/nginxinstall/conf/nginx.conf syntax is ok

nginx: configuration file /data/nginxinstall/conf/nginx.conf test is successful

[root@k8smaster sbin]#

./nginx -c /data/nginxinstall/conf/nginx.conf  #启动nginx服务


[root@k8smaster sbin]# ps -ef|grep nginx

root     37385     1  0 01:23 ?        00:00:00 nginx: master process ./nginx -c /data/nginxinstall/conf/nginx.conf

nobody   37386 37385  0 01:23 ?        00:00:00 nginx: worker process

root     37388 19322  0 01:24 pts/0    00:00:00 grep –color=auto nginx

[root@k8smaster conf]#

../sbin/nginx -s reload #重新加载配置文件

[root@k8smaster nginx]#

rm -rf nginx-1.9.7  #清理nginx安装包文件


[root@k8smaster nginx]#

rm -rf openssl-1.0.2h  #清理openssl安装包文件

[root@k8smaster sbin]#

./nginx -V  #大V查看nginx安装的模块


nginx version: nginx/1.9.7

built by gcc 4.8.5 20150623 (Red Hat 4.8.5-39) (GCC)

built with OpenSSL 1.0.2h  3 May 2016

TLS SNI support enabled

configure arguments:

–prefix=/data/nginxinstall –with-openssl=/data/nginx/openssl-1.0.2h –without-http_rewrite_module –with-http_stub_status_module –with-http_ssl_module –with-http_realip_module –with-stream_ssl_module –with-http_gzip_static_module –with-stream


[root@k8smaster sbin]#

打开浏览器,可以正常访问

http://192.168.23.100/

,表示安装配置成功。

链接:https://pan.baidu.com/s/183-fE45HsZCgDAs78oF5SQ

提取码:7938



版权声明:本文为zhaikaiyun原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。