RHEL/Centos7 Full build nginx-1.13.9 with openssl-1.1.0g and test

本文详细介绍Nginx从源码编译安装到配置运行的全过程,并解决常见错误,包括用户组配置、临时目录创建及端口冲突等问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

lake@localhost:~/Cloud/nginx/nginx-1.13.9$ ls -l ..
 
drwxr-xr-x  9 lake sys    4096 Mar 21 01:24 nginx-1.13.9
-rw-r--r--  1 lake sys  994802 Mar 20 04:23 nginx-1.13.9.tar.gz
lrwxrwxrwx  1 lake sys      14 Mar 20 04:34 openssl -> openssl-1.1.0g
drwxr-xr-x 19 lake sys    4096 Mar 21 01:26 openssl-1.1.0g
-rw-r--r--  1 lake sys 5404748 Nov  2 10:51 openssl-1.1.0g.tar.gz












lake@localhost:~/Cloud/nginx/nginx-1.13.9$  ./configure --with-openssl=../openssl --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib64/nginx/modules --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_v2_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-threads --with-stream --with-stream_ssl_module --with-http_slice_module --with-mail --with-mail_ssl_module --with-file-aio   --with-ipv6
checking for OS
 + Linux 3.10.0-327.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-4) (GCC) 
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for gcc builtin 64 bit byteswap ... 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 EPOLLEXCLUSIVE ... not 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 prctl(PR_SET_KEEPCAPS) ... found
checking for capabilities ... 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 sched_setaffinity() ... found
checking for SO_SETFIB ... not found
checking for SO_REUSEPORT ... found
checking for SO_ACCEPTFILTER ... not found
checking for SO_BINDANY ... not found
checking for IP_TRANSPARENT ... found
checking for IP_BINDANY ... not found
checking for IP_BIND_ADDRESS_NO_PORT ... not found
checking for IP_RECVDSTADDR ... not found
checking for IP_SENDSRCADDR ... not found
checking for IP_PKTINFO ... found
checking for IPV6_RECVPKTINFO ... 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 kqueue AIO support ... not found
checking for Linux AIO support ... 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 uint32_t ... found
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 AF_INET6 ... found
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for pwritev() ... 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 sysconf(_SC_LEVEL1_DCACHE_LINESIZE) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for zlib library ... found
creating objs/Makefile


Configuration summary
  + using threads
  + using system PCRE library
  + using OpenSSL library: ../openssl
  + using system zlib library


  nginx path prefix: "/etc/nginx"
  nginx binary file: "/usr/sbin/nginx"
  nginx modules path: "/usr/lib64/nginx/modules"
  nginx configuration prefix: "/etc/nginx"
  nginx configuration file: "/etc/nginx/nginx.conf"
  nginx pid file: "/var/run/nginx.pid"
  nginx error log file: "/var/log/nginx/error.log"
  nginx http access log file: "/var/log/nginx/access.log"
  nginx http client request body temporary files: "/var/cache/nginx/client_temp"
  nginx http proxy temporary files: "/var/cache/nginx/proxy_temp"
  nginx http fastcgi temporary files: "/var/cache/nginx/fastcgi_temp"
  nginx http uwsgi temporary files: "/var/cache/nginx/uwsgi_temp"
  nginx http scgi temporary files: "/var/cache/nginx/scgi_temp"


./configure: warning: the "--with-ipv6" option is deprecated
lake@localhost:~/Cloud/nginx/nginx-1.13.9$ 
 


lake@localhost:~/Cloud/nginx/nginx-1.13.9$ 
lake@localhost:~/Cloud/nginx/nginx-1.13.9$ 
lake@localhost:~/Cloud/nginx/nginx-1.13.9$ make -j32
............
......
objs/ngx_modules.o \
-ldl -lpthread -lpthread -lcrypt -lpcre ../openssl/.openssl/lib/libssl.a ../openssl/.openssl/lib/libcrypto.a -ldl -lz \
-Wl,-E
make[1]: Leaving directory `/home/lake/Cloud/nginx/nginx-1.13.9'






lake@localhost:~/Cloud/nginx/nginx-1.13.9$ sudo make install  
make -f objs/Makefile install
make[1]: Entering directory `/home/lake/Cloud/nginx/nginx-1.13.9'
test -d '/etc/nginx' || mkdir -p '/etc/nginx'
test -d '/usr/sbin' \
|| mkdir -p '/usr/sbin'
test ! -f '/usr/sbin/nginx' \
|| mv '/usr/sbin/nginx' \
'/usr/sbin/nginx.old'
cp objs/nginx '/usr/sbin/nginx'
test -d '/etc/nginx' \
|| mkdir -p '/etc/nginx'
cp conf/koi-win '/etc/nginx'
cp conf/koi-utf '/etc/nginx'
cp conf/win-utf '/etc/nginx'
test -f '/etc/nginx/mime.types' \
|| cp conf/mime.types '/etc/nginx'
cp conf/mime.types '/etc/nginx/mime.types.default'
test -f '/etc/nginx/fastcgi_params' \
|| cp conf/fastcgi_params '/etc/nginx'
cp conf/fastcgi_params \
'/etc/nginx/fastcgi_params.default'
test -f '/etc/nginx/fastcgi.conf' \
|| cp conf/fastcgi.conf '/etc/nginx'
cp conf/fastcgi.conf '/etc/nginx/fastcgi.conf.default'
test -f '/etc/nginx/uwsgi_params' \
|| cp conf/uwsgi_params '/etc/nginx'
cp conf/uwsgi_params \
'/etc/nginx/uwsgi_params.default'
test -f '/etc/nginx/scgi_params' \
|| cp conf/scgi_params '/etc/nginx'
cp conf/scgi_params \
'/etc/nginx/scgi_params.default'
test -f '/etc/nginx/nginx.conf' \
|| cp conf/nginx.conf '/etc/nginx/nginx.conf'
cp conf/nginx.conf '/etc/nginx/nginx.conf.default'
test -d '/var/run' \
|| mkdir -p '/var/run'
test -d '/var/log/nginx' \
|| mkdir -p '/var/log/nginx'
test -d '/etc/nginx/html' \
|| cp -R html '/etc/nginx'
test -d '/var/log/nginx' \
|| mkdir -p '/var/log/nginx'
make[1]: Leaving directory `/home/lake/Cloud/nginx/nginx-1.13.9' 


            
lake@localhost:~/Cloud/nginx/nginx-1.13.9$ vi /etc/nginx/nginx.conf
lake@localhost:~/Cloud/nginx/nginx-1.13.9$ sudo /usr/sbin/nginx  
nginx: [emerg] getpwnam("nginx") failed  <<<<<<<<<<<< user/group nginx is needed




lake@localhost:~/Cloud/nginx/nginx-1.13.9$ sudo  useradd -s /sbin/nologin -M nginx
lake@localhost:~/Cloud/nginx/nginx-1.13.9$ sudo /usr/sbin/nginx  
nginx: [emerg] mkdir() "/var/cache/nginx/client_temp" failed (2: No such file or directory)


lake@localhost:~/Cloud/nginx/nginx-1.13.9$ sudo  mkdir -p  /var/cache/nginx/client_temp 
lake@localhost:~/Cloud/nginx/nginx-1.13.9$ sudo /usr/sbin/nginx  
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)  <<< need to stop Apache/httpd


lake@localhost:~/Cloud/nginx/nginx-1.13.9$ sudo  systemctl  stop    httpd.service 
lake@localhost:~/Cloud/nginx/nginx-1.13.9$ sudo /usr/sbin/nginx  

 

# Browser visit localhost for nginx test page

 

 


root@localhost # lsof -i:80
COMMAND   PID  USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
nginx   29643  root    6u  IPv4 31201664      0t0  TCP *:http (LISTEN)
nginx   29644 nginx    6u  IPv4 31201664      0t0  TCP *:http (LISTEN)
root@localhost # ps -aux |grep nginx 
root     29643  0.0  0.0  23452   904 ?        Ss   00:51   0:00 nginx: master process /usr/sbin/nginx
nginx    29644  0.0  0.0  25996  1924 ?        S    00:51   0:00 nginx: worker process
root     31001  0.0  0.0 112648   956 pts/8    S+   00:58   0:00 grep --color=auto nginx
root@localhost # 







 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值