首页  »   操作系统

centos7装配nginx

网友分享于:2015-07-22  浏览:0次
centos7安装nginx

第一步:下载nginx
[root@localhost liulangyu]# cd software/
[root@localhost software]# wget http://nginx.org/download/nginx-1.9.3.tar.gz
--2015-07-18 02:25:40--  http://nginx.org/download/nginx-1.9.3.tar.gz
正在解析主机 nginx.org (nginx.org)... 206.251.255.63, 2606:7100:1:69::3f
正在连接 nginx.org (nginx.org)|206.251.255.63|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:864430 (844K) [application/octet-stream]
正在保存至: “nginx-1.9.3.tar.gz”
100%[======================================>] 864,430     92.1KB/s 用时 13s   
2015-07-18 02:25:59 (64.8 KB/s) - 已保存 “nginx-1.9.3.tar.gz” [864430/864430])
第二步:解压nginx
[root@localhost software]# tar zxvf nginx-1.9.3.tar.gz
[root@localhost software]# ls
nginx-1.9.3  nginx-1.9.3.tar.gz
第三步:添加需要的依赖
[root@localhost software]# yum -y install pcre-devel openssl openssl-devel
第四步:./configure执行配置文件
[root@localhost nginx-1.9.3]# ./configure --prefix=/usr/local/nginx
checking for OS
 + Linux 3.10.0-123.el7.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.8.2 20140120 (Red Hat 4.8.2-16) (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 ... 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 md5 in system md library ... not found
checking for md5 in system md5 library ... not found
checking for md5 in system OpenSSL crypto library ... found
checking for sha1 in system md library ... not found
checking for sha1 in system OpenSSL crypto library ... found
checking for zlib library ... found
creating objs/Makefile

Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/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"

第五步:make 代码变成可执行文件
[root@localhost nginx-1.9.3]#make
第六步:make install进行软件安装
[root@localhost nginx-1.9.3]# make install
make -f objs/Makefile install
make[1]: 进入目录“/home/liulangyu/software/nginx-1.9.3”
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin'   || mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx'   || mv '/usr/local/nginx/sbin/nginx'    '/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf'   || mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types'   || cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params'   || cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params   '/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf'   || cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.default'
test -f '/usr/local/nginx/conf/uwsgi_params'   || cp conf/uwsgi_params '/usr/local/nginx/conf'
cp conf/uwsgi_params   '/usr/local/nginx/conf/uwsgi_params.default'
test -f '/usr/local/nginx/conf/scgi_params'   || cp conf/scgi_params '/usr/local/nginx/conf'
cp conf/scgi_params   '/usr/local/nginx/conf/scgi_params.default'
test -f '/usr/local/nginx/conf/nginx.conf'   || cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf'
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs'   || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' ||   mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html'   || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' ||   mkdir -p '/usr/local/nginx/logs'
make[1]: 离开目录“/home/liulangyu/software/nginx-1.9.3”
第七步 验证nginx的配置文件是否正确
[root@localhost nginx-1.9.3]# cd /usr/local/nginx
[root@localhost nginx]# ls
conf  html  logs  sbin
[root@localhost nginx]# cd sbin/
[root@localhost sbin]# ./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
第八步:启动nginx
[root@localhost sbin]# ./nginx
第九步:netstat 查看nginx端口是否启动
[root@localhost sbin]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2363/master        
tcp        0      0 0.0.0.0:111             0.0.0.0:*               LISTEN      1795/rpcbind       
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      54188/nginx: master
tcp        0      0 0.0.0.0:42321           0.0.0.0:*               LISTEN      1861/rpc.statd     
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      37040/sshd         
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      3203/cupsd         
tcp6       0      0 ::1:25                  :::*                    LISTEN      2363/master        
tcp6       0      0 :::111                  :::*                    LISTEN      1795/rpcbind       
tcp6       0      0 :::22                   :::*                    LISTEN      37040/sshd         
tcp6       0      0 ::1:631                 :::*                    LISTEN      3203/cupsd         
tcp6       0      0 :::43447                :::*                    LISTEN      1861/rpc.statd     
下面这句表示启动成功
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      54188/nginx: master

 

 

相关解决方案

最新解决方案