CentOS6.7上安装nginx1.8.0

主题:
	CentOS6.7上安装nginx1.8.0

环境准备:
	1.gcc-c++
		示例:yum install gcc-c++
		安装:gcc-c++
		gcc-c++编译工具

	2.PCRE(Perl Compatible Regular Expressions)
		示例:yum install -y pcre pcre-devel
		安装:pcre和pcre-devel

		PCRE(Perl Compatible Regular Expressions)是一个 Perl 库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库。pcre-devel 是使用 pcre 开发的一个二次开发库。nginx 也需要此库。

	3.zlib
		示例:yum install -y zlib zlib-devel
		安装:zlib和zlib-devel

	4.OpenSSL
		示例:yum install -y openssl openssl-devel
		安装:openssl和openssl-devel

		OpenSSL是一个强大的安全套接字层密码库,囊括主要的密码算法、常用的密钥和证书封装管理功能及 SSL 协议,并提供丰富的应用程序供测试或其它目的使用。nginx 不仅支持 http 协议,还支持 https(即在 ssl 协议上传输 http),所以需要在 linux安装 openssl 库

安装步骤:
	在nginx解压目录中,./configure&make&make install

	压缩包存放:
		/root/develop/
	解压目录:
		/root/develop/nginx-1.8.0

[[email protected] nginx-1.8.0]# pwd
/root/develop/nginx-1.8.0
[[email protected] nginx-1.8.0]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  Makefile  man  objs  README  src

配置帮助:
	1.help方式
		示例:# ./configure --help
	2.info方式
		示例:# info configure

help方式:
[[email protected] nginx-1.8.0]# ./configure --help

  --help                             print this message

  --prefix=PATH                      set installation prefix
  --sbin-path=PATH                   set nginx binary pathname
  --conf-path=PATH                   set nginx.conf pathname
  --error-log-path=PATH              set error log pathname
  --pid-path=PATH                    set nginx.pid pathname
  --lock-path=PATH                   set nginx.lock pathname

  --user=USER                        set non-privileged user for
                                     worker processes
  --group=GROUP                      set non-privileged group for
                                     worker processes

  --build=NAME                       set build name
  --builddir=DIR                     set build directory

info方式:
[[email protected] /]# info configure

File: configure.info,  Node: Top,  Next: Introduction,  Up: (dir)

GNU configure and build system
******************************

The GNU configure and build system.

* Menu:

* Introduction::                Introduction.
* Getting Started::             Getting Started.
* Files::                       Files.
* Configuration Names::         Configuration Names.
* Cross Compilation Tools::     Cross Compilation Tools.
* Canadian Cross::              Canadian Cross.
* Cygnus Configure::            Cygnus Configure.
* Multilibs::                   Multilibs.
* FAQ::                         Frequently Asked Questions.
* Index::                       Index.

configure参数:
./configure --prefix=/usr \                                                        指向安装目录
--sbin-path=/usr/sbin/nginx \                                 指向(执行)程序文件(nginx)
--conf-path=/etc/nginx/nginx.conf \                      指向配置文件
--error-log-path=/var/log/nginx/error.log \              指向log
--http-log-path=/var/log/nginx/access.log \            指向http-log
--pid-path=/var/run/nginx/nginx.pid \                      指向pid
--lock-path=/var/lock/nginx.lock \                         (安装文件锁定,防止安装文件被别人利用,或自己误操作。)
--user=nginx --group=nginx --with-http_ssl_module \                      启用ngx_http_ssl_module支持(使支持https请求,需已安装openssl)
--with-http_flv_module \                       启用ngx_http_flv_module支持(提供寻求内存使用基于时间的偏移量文件)
--with-http_stub_status_module \     启用ngx_http_stub_status_module支持(获取nginx自上次启动以来的工作状态)
--with-http_gzip_static_module \   启用ngx_http_gzip_static_module支持(在线实时压缩输出数据流)
--http-client-body-temp-path=/var/tmp/nginx/client/ \ 设定http客户端请求临时文件路径
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \ 设定http代理临时文件路径
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \ 设定http fastcgi临时文件路径
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \ 设定http uwsgi临时文件路径
--http-scgi-temp-path=/var/tmp/nginx/scgi \ 设定http scgi临时文件路径
--with-pcre 启用pcre库

实际使用的configure参数:
./configure --prefix=/usr/local/nginx --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-proxy-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fastcgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/temp/nginx/scgi

问题:
	描述:系统需要安装PCRE library
	方案:安装pcre-devel
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

[[email protected] nginx-1.8.0]# yum search pcre
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * extras: mirrors.cn99.com
 * updates: mirrors.163.com
================================================================================ N/S Matched: pcre =================================================================================
pcre-devel.i686 : Development files for pcre
pcre-static.i686 : Static library for pcre
pcre.i686 : Perl-compatible regular expression library

[[email protected] nginx-1.8.0]# yum install pcre-devel.i686
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.zju.edu.cn
 * extras: mirrors.cn99.com
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package pcre-devel.i686 0:7.8-7.el6 will be installed
--> Finished Dependency Resolution

问题:
	描述:HTTP gizp模块需要zlib库
	方案:安装zlib-devel
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

[[email protected] nginx-1.8.0]# yum list installed | grep zlib
zlib.i686                1.2.3-29.el6     @anaconda-CentOS-201508042139.i386/6.7

搜索zlib-devel包:
[[email protected] nginx-1.8.0]# yum search zlib
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * extras: mirrors.cn99.com
 * updates: mirrors.163.com
================================================================================ N/S Matched: zlib =================================================================================
jzlib.i686 : JZlib re-implementation of zlib in pure Java
jzlib-demo.i686 : Examples for jzlib
jzlib-javadoc.i686 : Javadoc for jzlib
perl-Compress-Raw-Zlib.i686 : Low-Level Interface to the zlib compression library
perl-Compress-Zlib.i686 : A module providing Perl interfaces to the zlib compression library
perl-IO-Zlib.i686 : Perl IO:: style interface to Compress::Zlib
zlib.i686 : The zlib compression and decompression library
zlib-devel.i686 : Header files and libraries for Zlib development
zlib-static.i686 : Static libraries for Zlib development
perl-IO-Compress-Zlib.i686 : Perl interface to allow reading and writing of gzip and zip data

安装zlib-devel包:
[[email protected] nginx-1.8.0]# yum install -y zlib-devel.i686
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: mirrors.cqu.edu.cn
 * extras: mirrors.cn99.com
 * updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package zlib-devel.i686 0:1.2.3-29.el6 will be installed
--> Finished Dependency Resolution

查看是否安装了zlib-devel包:
[[email protected] nginx-1.8.0]# yum list installed | grep zlib
Existing lock /var/run/yum.pid: another copy is running as pid 6999.
Another app is currently holding the yum lock; waiting for it to exit...
  The other application is: PackageKit
    Memory :  25 M RSS ( 72 MB VSZ)
    Started: Wed May 29 05:29:04 2019 - 00:06 ago
    State  : Sleeping, pid: 6999
zlib.i686                1.2.3-29.el6     @anaconda-CentOS-201508042139.i386/6.7
zlib-devel.i686          1.2.3-29.el6     @base

./configure执行结果:
Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using builtin md5 code
  + sha1 library is not found
  + 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: "/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/temp/nginx/client"
  nginx http proxy temporary files: "/var/temp/nginx/proxy"
  nginx http fastcgi temporary files: "/var/temp/nginx/fastcgi"
  nginx http uwsgi temporary files: "/var/temp/nginx/uwsgi"
  nginx http scgi temporary files: "/var/temp/nginx/scgi"

[[email protected] sbin]# ./nginx
nginx: [emerg] mkdir() "/var/temp/nginx/client" failed (2: No such file or directory)

执行命令目录为:
	/usr/local/nginx/sbin

启动nginx:
[[email protected] ~]# cd /usr/local/nginx/
[[email protected] nginx]# ls
conf  html  sbin
[[email protected] nginx]# cd sbin
[[email protected] sbin]# ls
nginx
[[email protected] sbin]# ./nginx

启动后查看进程:
	示例:# ps aux | grep nginx
[[email protected] nginx-1.8.0]# ps aux | grep nginx
root      3000  0.0  0.0   3200   524 ?        Ss   04:45   0:00 nginx: master process ./nginx
nobody    3001  0.0  0.1   3404  1184 ?        S    04:45   0:00 nginx: worker process
root      3230  0.0  0.0   4420   760 pts/2    S+   05:14   0:00 grep nginx

查看防火墙过滤规则:
	示例:# service iptables status

[[email protected] nginx-1.8.0]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
1    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:80
2    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:8080
3    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           tcp dpt:3306
4    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED
5    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0
6    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0
7    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22
8    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited

查看网络监听:
	示例:# netstat -ntlp

[[email protected] nginx-1.8.0]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1585/rpcbind
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      3000/nginx
tcp        0      0 0.0.0.0:43315               0.0.0.0:*                   LISTEN      1642/rpc.statd
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1832/sshd
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1681/cupsd
tcp        0      0 127.0.0.1:6010              0.0.0.0:*                   LISTEN      2746/sshd
tcp        0      0 127.0.0.1:6011              0.0.0.0:*                   LISTEN      2970/sshd
tcp        0      0 ::ffff:127.0.0.1:8005       :::*                        LISTEN      2797/java
tcp        0      0 :::8009                     :::*                        LISTEN      2797/java
tcp        0      0 :::3306                     :::*                        LISTEN      1990/mysqld
tcp        0      0 :::111                      :::*                        LISTEN      1585/rpcbind
tcp        0      0 :::8080                     :::*                        LISTEN      2797/java
tcp        0      0 :::22                       :::*                        LISTEN      1832/sshd
tcp        0      0 ::1:631                     :::*                        LISTEN      1681/cupsd
tcp        0      0 ::1:6010                    :::*                        LISTEN      2746/sshd
tcp        0      0 ::1:6011                    :::*                        LISTEN      2970/sshd
tcp        0      0 :::49662                    :::*                        LISTEN      1642/rpc.statd 

关闭nginx:
	方式1:./nginx -s stop
	方式2:./nginx -s quit

	错误示例:
[[email protected] sbin]# ./nginx -s exit
nginx: invalid option: "-s exit"

重启nginx:
	示例:./nginx -s reload

执行命令目录为:
	/usr/local/nginx/sbin

原文地址:https://www.cnblogs.com/mozq/p/10952071.html

时间: 2024-10-10 23:35:18

CentOS6.7上安装nginx1.8.0的相关文章

ubuntu14.04上安装Nginx1.8.0+php5-fpm

1.download nginx源码 2. tar –xvf nginx.tar.gz 3.nginx需要prec和zlib库 sudo apt-get prec3 prec3-dev sudo apt-get zlib1g zlib1g-dev 4.安装配置 cd nginx sudo ./configure 安装内容 Configuration summary   +using system PCRE library   +OpenSSL library is not used   +usi

在Centos6.9上安装oracle11.2.0.4

本文内容的来源包含并不限于如下几位数据库大神的视频课堂或博客,由本人或原文转载.或二次整理,在此由衷感谢! 小麦苗博客:http://blog.itpub.net/26736162/ 风哥博客:http://blog.51cto.com/oracle18c 乐沙弥博客http://blog.csdn.net/leshami 1. Linux的安装(Centos6.9) 2. Oracle软件单机安装和卸载 3. 创建和删除数据库 4. 管理工具的使用 5. Oracle ASM的安装 原文地址:

基于CentOS6.5环境之下的LNMP之编译安装Nginx1.8.0 stable(稳定版)

LNMP之编译安装Nginx1.8.0 stable(稳定版) 1.yum安装nginx所欲要的生存环境,也就是库文件 yum -y install make gcc gcc-c++ glibc glibc-devel automake autoconf libtool make 2.给nginx添加系统用户 useradd -s /sbin/nologin -M -r nginx 3.解压安装nginx1.8.0 tar xf nginx-1.8.0.tar.gz  cd nginx-1.8.

centos6.5安装nginx1.16.0

参考:   centos7 编译安装nginx1.16.0( 完整版 ) https://blog.csdn.net/weixin_37773766/article/details/80290939   nginx安装好后,无法通过ip进行访问 1.安装依赖环境 yum install -y gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel 提示需要root权限,使用root权限安装完成: 2.下载nginx  :

一、Centos6.7编译安装Nginx1.81

声明:本系列教程由马哥教育提供指导: Centos6.7编译安装Nginx1.81 +mysql-5.5.33 + php-5.5 1.nginx简介: Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行.由俄罗斯的程序设计师Igor Sysoev所开发,供俄国大型的入口网站及搜索引擎Rambler(俄文:Рамблер)使用.其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表

CentOS6.2下安装Qt5.1.0

因为要将程序实现跨平台,所以只能在CentOS6.2上再安装一次Qt,为了保证一致性,我使用了和windows下版本一样的Qt5.1.0,可以到此处下载. 下载好,复制到虚拟机上后,直接双击运行,一切良好,安装完毕,可是却无法启动,于是在网上搜解决方案,将遇到的问题及解决办法记下来. 1.从application>Programming>Qt Creator点击,结果没有反应,只能使用命令行到安装目录下,启动,提示错误如下: /usr/lib64/libstdc++.so.6: version

CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14

转载自http://www.osyunwei.com/archives/7891.html 准备篇: CentOS 7.0系统安装配置图解教程 http://www.osyunwei.com/archives/7829.html 一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙. 1.关闭firewall: systemctl stop firewalld.service #停止firewall systemc

CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14方法分享

一.配置防火墙,开启80端口.3306端口CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙.1.关闭firewall: systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 2.安装iptables防火墙 yum install iptables-services #安装 vi /etc/sysconfig/ipta

CentOS6.9上安装cobbler2.6实现自动化安装Linux系统

CentOS6.9上安装cobbler2.6实现自动化安装Linux系统 cobbler可以批量部署Linux系统,并实现无人值守安装. cobbler依赖的服务:dhcp,tftp,http,pxe,kickstart 服务对应的端口号为dhcp--67,68;tftp--69;http--80;cobbler--25151 1.环境准备:最小化安装centos6.9mini,配置固定IP和本地yum源,关闭防火墙和selinux iptables -F setenforce 0 chkcon