博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS6.9编译安装nginx1.4.7
阅读量:6860 次
发布时间:2019-06-26

本文共 8578 字,大约阅读时间需要 28 分钟。

1.系统安装开发包组和zlib-devel,关闭iptables

[root@bogon ~]# yum groupinstall -y "Development Tools"[root@bogon ~]# yum install -y zlib-devel[root@bogon ~]# yum install -y openssl[root@bogon ~]# service iptables stopiptables: Setting chains to policy ACCEPT: filter          [  OK  ]iptables: Flushing firewall rules:                         [  OK  ]iptables: Unloading modules:

2.下载nginx的源码包到本地

[root@bogon ~]# ll nginx-1.4.7.tar.gz -rw-r--r--. 1 root root 769153 Jun  1  2017 nginx-1.4.7.tar.gz

3.解压nginx源码包

[root@bogon ~]# tar -xf nginx-1.4.7.tar.gz

4.进入解压目录

[root@bogon ~]# cd nginx-1.4.7

5.开始编译,生成makefile文件

[root@bogon nginx-1.4.7]# ./configure --prefix=/usr\ --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/nginx.pid --lock-path=/var/lock/nginx.lock\ --user=nginx --group=nginx --with-http_flv_module\ --with-http_stub_status_module --with-http_gzip_static_module\ --http-client-body-temp-path=/var/tmp/nginx/client\ --http-proxy-temp-path=/var/tmp/nginx/proxy\ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/\ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi\ --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre\ --with-http_ssl_module\.....checking for socklen_t ... foundchecking for in_addr_t ... foundchecking for in_port_t ... foundchecking for rlim_t ... foundchecking for uintptr_t ... uintptr_t foundchecking for system byte ordering ... little endianchecking for size_t size ... 8 byteschecking for off_t size ... 8 byteschecking for time_t size ... 8 byteschecking for setproctitle() ... not foundchecking for pread() ... foundchecking for pwrite() ... foundchecking for sys_nerr ... foundchecking for localtime_r() ... foundchecking for posix_memalign() ... foundchecking for memalign() ... foundchecking for mmap(MAP_ANON|MAP_SHARED) ... foundchecking for mmap("/dev/zero", MAP_SHARED) ... foundchecking for System V shared memory ... foundchecking for POSIX semaphores ... not foundchecking for POSIX semaphores in libpthread ... foundchecking for struct msghdr.msg_control ... foundchecking for ioctl(FIONBIO) ... foundchecking for struct tm.tm_gmtoff ... foundchecking for struct dirent.d_namlen ... not foundchecking for struct dirent.d_type ... foundchecking for sysconf(_SC_NPROCESSORS_ONLN) ... foundchecking for openat(), fstatat() ... foundchecking for getaddrinfo() ... foundchecking for PCRE library ... foundchecking for PCRE JIT support ... not foundchecking for OpenSSL library ... foundchecking for zlib library ... foundcreating objs/MakefileConfiguration summary  + using system PCRE library  + using system OpenSSL library  + md5: using OpenSSL library  + sha1: using OpenSSL library  + using system zlib library  nginx 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/access.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: "/var/tmp/nginx/uwsgi"  nginx http scgi temporary files: "/var/tmp/nginx/scgi"

6.开始安装nginx

[root@bogon nginx-1.4.7]# make && make installmake -f objs/Makefilemake[1]: Entering directory `/root/nginx-1.4.7'cc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \        -o objs/src/core/nginx.o \        src/core/nginx.ccc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \        -o objs/src/core/ngx_log.o \        src/core/ngx_log.ccc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \        -o objs/src/core/ngx_palloc.o \        src/core/ngx_palloc.ccc -c -pipe  -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g  -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \        -o objs/src/core/ngx_array.o \        src/core/ngx_array.c....make[1]: Leaving directory `/root/nginx-1.4.7'make -f objs/Makefile manpagemake[1]: Entering directory `/root/nginx-1.4.7'sed -e "s|%%PREFIX%%|/usr|" \        -e "s|%%PID_PATH%%|/var/run/nginx/nginx.pid|" \        -e "s|%%CONF_PATH%%|/etc/nginx/nginx.conf|" \        -e "s|%%ERROR_LOG_PATH%%|/var/log/nginx/error.log|" \        < man/nginx.8 > objs/nginx.8make[1]: Leaving directory `/root/nginx-1.4.7'make -f objs/Makefile installmake[1]: Entering directory `/root/nginx-1.4.7'test -d '/usr' || mkdir -p '/usr'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/nginx'        || mkdir -p '/var/run/nginx'test -d '/var/log/nginx' ||         mkdir -p '/var/log/nginx'test -d '/usr/html'         || cp -R html '/usr'test -d '/var/log/nginx' ||         mkdir -p '/var/log/nginx'make[1]: Leaving directory `/root/nginx-1.4.7'

7.测试nginx的配置语法

#查看nginx的帮助[root@bogon nginx-1.4.7]# /usr/sbin/nginx -hnginx version: nginx/1.4.7Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]Options:  -?,-h         : this help  -v            : show version and exit  -V            : show version and configure options then exit  -t            : test configuration and exit  -q            : suppress non-error messages during configuration testing  -s signal     : send signal to a master process: stop, quit, reopen, reload  -p prefix     : set prefix path (default: /usr/)  -c filename   : set configuration file (default: /etc/nginx/nginx.conf)  -g directives : set global directives out of configuration file#测试配置文件的语法[root@bogon nginx-1.4.7]# /usr/sbin/nginx -t#显示语法正确nginx: the configuration file /etc/nginx/nginx.conf syntax is ok#显示系统上没有nginx这个用户nginx: [emerg] getpwnam("nginx") failed#配置文件测试失败nginx: configuration file /etc/nginx/nginx.conf test failed

8.添加nginx这个系统用户,然后测试配置文件语法

#添加nginx这个系统用户[root@bogon nginx-1.4.7]# useradd -r nginx#测试配置文件语法[root@bogon nginx-1.4.7]# /usr/sbin/nginx -tnginx: the configuration file /etc/nginx/nginx.conf syntax is ok#显示/var/tmp/nginx这个临时目录不存在nginx: [emerg] mkdir() "/var/tmp/nginx/client" failed (2: No such file or directory)nginx: configuration file /etc/nginx/nginx.conf test failed

9.建立nginx的临时目录,然后测试配置文件的语法

#建立nginx临时目录[root@bogon nginx-1.4.7]# mkdir /var/tmp/nginx[root@bogon nginx-1.4.7]# /usr/sbin/nginx -t#显示nginx配置文件语法正确nginx: the configuration file /etc/nginx/nginx.conf syntax is ok#测试nginx配置文件成功nginx: configuration file /etc/nginx/nginx.conf test is successful

10.启动nginx

#启动nginx[root@bogon nginx-1.4.7]#  /usr/sbin/nginx#查看是否启动成功[root@bogon nginx-1.4.7]# ss -tnl | grep 80LISTEN     0      128                       *:80                       *:*

11.查看系统IP地址,打开nginx的本地网页

[root@bogon ~]# ifconfig eth0eth0      Link encap:Ethernet  HWaddr 00:0C:29:9C:2B:A5            inet addr:192.168.16.87  Bcast:192.168.16.255  Mask:255.255.255.0          inet6 addr: fe80::20c:29ff:fe9c:2ba5/64 Scope:Link          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1          RX packets:1648500 errors:0 dropped:0 overruns:0 frame:0          TX packets:2193 errors:0 dropped:0 overruns:0 carrier:0          collisions:0 txqueuelen:1000           RX bytes:1606718906 (1.4 GiB)  TX bytes:176876 (172.7 KiB)

img_d57da40ea8c88eed951c1a10c62a963e.png

转载地址:http://voxyl.baihongyu.com/

你可能感兴趣的文章
《DBA修炼之道:数据库管理员的第一本书》——1.15节回顾
查看>>
Visual Studio之UI界面测试
查看>>
企业为什么需要IT配置管理及其如何使用
查看>>
《深入理解Spark:核心思想与源码分析》——3.13节创建DAGSchedulerSource和BlockManagerSource...
查看>>
Nginx 将增加动态模块,用户可修改服务器
查看>>
《Adobe Photoshop CS5中文版经典教程(全彩版)》—第1课1.7节检查更新
查看>>
《微课实战:Camtasia Studio入门精要》——2.3 录制屏幕
查看>>
码云周一见 | 老司机教你如何麻溜地搭建网站
查看>>
bingoJS 2.x | AmazeUI 后台 SPA 管理框架
查看>>
《NTFS文件系统扇区存储探秘》——导读
查看>>
一个易用的 WPF 自动完成文本框 【已翻译100%】
查看>>
红帽7000万欧元收购开源云计算商eNovance
查看>>
《Storm分布式实时计算模式》——1.5 理解数据流分组
查看>>
《计算机系统:系统架构与操作系统的高度集成》——2.3 常见的高级语言功能集...
查看>>
《电脑音乐制作实战指南:伴奏、录歌、MTV全攻略》——问答
查看>>
《Excel 职场手册:260招菜鸟变达人》一第 39 招 筛选后粘贴
查看>>
《Cisco IOS XR技术精要》一本章小结
查看>>
《C语言解惑》—— 第3章 基本数据类型
查看>>
oracle中schema指的是什么?
查看>>
【PMP认证考试之个人总结】 第 13 章 PMP计算题汇总
查看>>