需求描述:
记录在linux平台,nginx安装的过程.
环境描述:
操作系统:Red Hat Enterprise Linux Server release 6.6 (Santiago)
操作内核版本:2.6.32-504.el6.x86_64
nginx版本:nginx-1.14.0
安装过程:
1.下载nginx的源码包
软件分享(百度云):
https://pan.baidu.com/s/1305ocsP2gHXdLR6PHmhDBA
2.将nginx源码包上传到服务器上
[root@testvm software]# pwd
/opt/software
[root@testvm software]# ls -ltr
total
-rw-r--r--. root root Apr : nginx-1.14..tar.gz
3.创建nginx软件安装路径
mkdir -p /opt/app/nginx
4.解压nginx源码包,并进入解压后的目录
[root@testvm software]# tar -zxf nginx-1.14..tar.gz
[root@testvm software]# ls -l
total
drwxr-xr-x. Apr : nginx-1.14.
-rw-r--r--. root root Apr : nginx-1.14..tar.gz
[root@testvm software]# cd nginx-1.14.
[root@testvm nginx-1.14.]# ls -l
total
drwxr-xr-x. Apr : auto
-rw-r--r--. Apr : CHANGES
-rw-r--r--. Apr : CHANGES.ru
drwxr-xr-x. Apr : conf
-rwxr-xr-x. Apr : configure
drwxr-xr-x. Apr : contrib
drwxr-xr-x. Apr : html
-rw-r--r--. Apr : LICENSE
drwxr-xr-x. Apr : man
-rw-r--r--. Apr : README
drwxr-xr-x. Apr : src
5.安装nginx编译,安装时需要的依赖软件包
5.1安装开发者工具组"Development tools"
yum groupinstall "Development tools" --assumeyes
5.2安装zlib,zlib-devel,openssl,openss-devel,pcre,pcre-devel软件包
yum install -y zlib zlib-devel openssl openssl-devel pcre pcre-devel
6.创建nginx用户,用户组
useradd nginx
id nginx
7.进入nginx源码包解压后的目录,配置nginx
./configure --prefix=/opt/app/nginx \
--user=nginx \
--group=nginx \
--sbin-path=/opt/app/nginx/sbin/nginx \
--conf-path=/opt/app/nginx/conf/nginx.conf \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--error-log-path=/opt/app/nginx/log/error.log \
--http-log-path=/opt/app/nginx/log/access.log \
--with-http_gzip_static_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre \
--with-file-aio \
--with-http_realip_module \
--without-http_scgi_module \
--without-http_uwsgi_module
备注:配置过程,可以设置不同的组件.
执行过程:
[root@testvm nginx-1.14.0]# ./configure --prefix=/opt/app/nginx \
> --user=nginx \
> --group=nginx \
> --sbin-path=/opt/app/nginx/sbin/nginx \
> --conf-path=/opt/app/nginx/conf/nginx.conf \
> --pid-path=/var/run/nginx.pid \
> --lock-path=/var/run/nginx.lock \
> --error-log-path=/opt/app/nginx/log/error.log \
> --http-log-path=/opt/app/nginx/log/access.log \
> --with-http_gzip_static_module \
> --with-http_stub_status_module \
> --with-http_ssl_module \
> --with-pcre \
> --with-file-aio \
> --with-http_realip_module \
> --without-http_scgi_module \
> --without-http_uwsgi_module
checking for OS
+ Linux 2.6.32-504.el6.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.4.7 20120313 (Red Hat 4.4.7-11) (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 ... not 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 ... not 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 clock_gettime(CLOCK_MONOTONIC) ... not found
checking for clock_gettime(CLOCK_MONOTONIC) in librt ... 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 ... not found
checking for OpenSSL library ... found
checking for zlib library ... found
creating objs/Makefile Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library nginx path prefix: "/opt/app/nginx"
nginx binary file: "/opt/app/nginx/sbin/nginx"
nginx modules path: "/opt/app/nginx/modules"
nginx configuration prefix: "/opt/app/nginx/conf"
nginx configuration file: "/opt/app/nginx/conf/nginx.conf"
nginx pid file: "/var/run/nginx.pid"
nginx error log file: "/opt/app/nginx/log/error.log"
nginx http access log file: "/opt/app/nginx/log/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的安装路径,启动用户,配置文件的路径,日志文件路径
8.编译,安装
make
make install
9.安装完成之后,查看nginx目录中内容
[root@testvm nginx]# pwd
/opt/app/nginx
[root@testvm nginx]# ll
total
drwxr-xr-x. root root Apr : conf
drwxr-xr-x. root root Apr : html
drwxr-xr-x. root root Apr : log
drwxr-xr-x. root root Apr : sbin
10.启动nginx,查看启动后的后台进程信息
[root@testvm nginx]# ps -ef | grep nginx
root 4259 1307 0 10:22 pts/0 00:00:00 grep nginx
[root@testvm nginx]# /opt/app/nginx/sbin/nginx -c /opt/app/nginx/conf/nginx.conf
[root@testvm nginx]# ps -ef | grep nginx
root 4261 1 0 10:22 ? 00:00:00 nginx: master process /opt/app/nginx/sbin/nginx -c /opt/app/nginx/conf/nginx.conf
nginx 4262 4261 0 10:22 ? 00:00:00 nginx: worker process
root 4264 1307 0 10:22 pts/0 00:00:00 grep nginx
11.通过浏览器页面进行查看
备注:已经能够通过页面进行访问,nginx安装正确.
文档创建时间:2018年4月24日10:23:57