CentOS6.9编译安装nginx1.4.7

简介: 1.系统安装开发包组和zlib-devel,关闭iptables[root@bogon ~]# yum groupinstall -y "Development Tools"[root@bogon ~]# yum install -y zlib-devel[root@bogon ~]# yum...

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 stop
iptables: 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 ... 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 ... 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
  + 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 install
make -f objs/Makefile
make[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.c
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/ngx_log.o \
        src/core/ngx_log.c
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/ngx_palloc.o \
        src/core/ngx_palloc.c
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/ngx_array.o \
        src/core/ngx_array.c

....
make[1]: Leaving directory `/root/nginx-1.4.7'
make -f objs/Makefile manpage
make[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.8
make[1]: Leaving directory `/root/nginx-1.4.7'
make -f objs/Makefile install
make[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 -h
nginx version: nginx/1.4.7
Usage: 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 -t
nginx: 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 80
LISTEN     0      128                       *:80                       *:*    

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

[root@bogon ~]# ifconfig eth0
eth0      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

目录
相关文章
|
2月前
|
负载均衡 应用服务中间件 Linux
nginx学习,看这一篇就够了:下载、安装。使用:正向代理、反向代理、负载均衡。常用命令和配置文件,很全
这篇博客文章详细介绍了Nginx的下载、安装、配置以及使用,包括正向代理、反向代理、负载均衡、动静分离等高级功能,并通过具体实例讲解了如何进行配置。
164 4
nginx学习,看这一篇就够了:下载、安装。使用:正向代理、反向代理、负载均衡。常用命令和配置文件,很全
|
29天前
|
关系型数据库 MySQL Linux
在 CentOS 7 中通过编译源码方式安装 MySQL 数据库的详细步骤,包括准备工作、下载源码、编译安装、配置 MySQL 服务、登录设置等。
本文介绍了在 CentOS 7 中通过编译源码方式安装 MySQL 数据库的详细步骤,包括准备工作、下载源码、编译安装、配置 MySQL 服务、登录设置等。同时,文章还对比了编译源码安装与使用 RPM 包安装的优缺点,帮助读者根据需求选择最合适的方法。通过具体案例,展示了编译源码安装的灵活性和定制性。
84 2
|
2月前
|
tengine 关系型数据库 MySQL
Tengine、Nginx安装MySQL数据库命令教程
本指南详细介绍了在Linux系统上安装与配置MySQL数据库的步骤。首先通过下载并安装MySQL社区版本,接着启动MySQL服务,使用`systemctl start mysqld.service`命令。若启动失败,可尝试使用`sudo /etc/init.d/mysqld start`。利用`systemctl status mysqld.service`检查MySQL的服务状态,确保其处于运行中。通过日志文件获取初始密码,使用该密码登录数据库,并按要求更改初始密码以增强安全性。随后创建一个名为`tengine`的数据库,最后验证数据库创建是否成功以及完成整个设置流程。
|
2月前
|
tengine 应用服务中间件 Linux
Tengine、Nginx安装PHP命令教程
要在阿里云Linux上安装PHP,请先更新YUM源并启用PHP 8.0仓库,然后安装PHP及相关扩展。通过`php -v`命令验证安装成功后,需修改Nginx配置文件以支持PHP,并重启服务。最后,创建`phpinfo.php`文件测试安装是否成功。对于CentOS系统,还需安装EPEL源和Remi仓库,其余步骤类似。完成上述操作后,可通过浏览器访问`http://IP地址/phpinfo.php`测试安装结果。
|
2月前
|
应用服务中间件 Linux nginx
Mac os 安装 nginx 教程(success)
这篇文章是关于如何在Mac OS系统上使用Homebrew安装nginx及其依赖,并解决安装过程中可能出现的权限问题。
128 0
Mac os 安装 nginx 教程(success)
|
2月前
|
安全 Linux 编译器
Centos 7.9如何使用源码编译安装curl最新版本
通过上述步骤,您就能在CentOS 7.9上成功地从源代码编译并安装curl的最新版本。这种方法不仅提供了灵活性,允许您定制编译选项,还确保了软件的最新功能和安全更新得到应用。
69 1
|
2月前
|
Ubuntu 搜索推荐 应用服务中间件
Nginx安装与使用
Nginx安装与使用
|
2月前
|
负载均衡 算法 应用服务中间件
Nginx安装及配置详解
Nginx安装及配置详解
|
2月前
|
应用服务中间件 程序员 开发工具
mac下安装nginx
mac下安装nginx
|
2月前
|
应用服务中间件 Linux nginx
CentOS7安装Nginx
CentOS7安装Nginx